【发布时间】:2017-10-11 04:30:35
【问题描述】:
我在具有 main 方法的 java 类中有一个文件定义,我希望能够从 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 类中,它是相对于源的根目录。
有没有办法覆盖 Ant 任务中的基本目录?
【问题讨论】: