1
我有一个Java类中的文件定义,它有一个主要方法,我希望能够从Eclipse运行菜单以及使用相对路径从Ant构建文件运行。我如何使用Ant的相对路径运行java类?
这只能从Eclipse运行菜单运行的主要方式时,工作原理:在Ant中运行时,
private static final File location = new File("./implementation/src/xml/data");
这仅适用:
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任务内的基本目录?
这工作,但我也不得不设置fork =“true” –