我如何 运行 a java class 与 Ant 的相对路径?
How can I run a java class with a relative path from Ant?
我在 java class 中有一个文件定义,它有一个主要方法,我希望能够 运行 从 Eclipse 运行菜单以及使用相对路径的 Ant 构建文件。
这仅在 运行从 Eclipse 运行 菜单中调用主要方法时有效:
private static final File location = new File("./implementation/src/xml/data");
这仅在 运行在 Ant 中运行时有效:
private static final File location = new File("./src/xml/data");
项目结构如下:
MyProject
|
|
implementation
| |
| |
src build.xml
这是 Ant 任务:
<target name="run">
<java classname="test.XMLCreator" classpathref="compile-classpath" >
<classpath>
<pathelement location="${classes}" />
</classpath>
</java>
</target>
我理解这是因为在 Ant 中,路径是相对于构建文件的位置,而在 java class 中它是相对于源代码的根目录。
有没有办法覆盖 Ant 任务中的基本目录?
我在 java class 中有一个文件定义,它有一个主要方法,我希望能够 运行 从 Eclipse 运行菜单以及使用相对路径的 Ant 构建文件。
这仅在 运行从 Eclipse 运行 菜单中调用主要方法时有效:
private static final File location = new File("./implementation/src/xml/data");
这仅在 运行在 Ant 中运行时有效:
private static final File location = new File("./src/xml/data");
项目结构如下:
MyProject
|
|
implementation
| |
| |
src build.xml
这是 Ant 任务:
<target name="run">
<java classname="test.XMLCreator" classpathref="compile-classpath" >
<classpath>
<pathelement location="${classes}" />
</classpath>
</java>
</target>
我理解这是因为在 Ant 中,路径是相对于构建文件的位置,而在 java class 中它是相对于源代码的根目录。
有没有办法覆盖 Ant 任务中的基本目录?