3
以下是我的ant脚本的简化版本(它有项目元素等)。ant javac找不到其他项目编译类
我是新来的蚂蚁,无法弄清楚为什么'compileTests'不编译,而'compileFoo'呢。
我得到的错误是'程序包不存在',因为compileTests项目中的类无法在compileFoo项目中找到已编译的类,尽管它们已经编译好了,我可以在文件系统上看到它们并且它们的路径被列在类路径中(我认为这是必要的?)
显然有一些基本的东西我不明白。有人可以请解释帮忙吗?
<path id="build_classpath">
<fileset dir="${other_required_jars}" includes="**/*.jar" />
<fileset dir="${foo_build_location}" includes="**/*.class" />
</path>
<target name="compileFoo" description="compile">
<javac srcdir="${foo_source_directory}\test-src" includeantruntime="false" destdir="${foo_build_location}" includes="**/*.java" excludes="" debug="on" optimize="off" deprecation="on" verbose="on">
<classpath refid="build_classpath" />
</javac>
</target>
<target name="compileTests" description="compile">
<javac srcdir="${test_source_directory}\test-src" includeantruntime="false" destdir="${test_build_location}" includes="**/*.java" excludes="" debug="on" optimize="off" deprecation="on" verbose="on">
<classpath refid="build_classpath" />
</javac>
</target>
JB Nizet,谢谢你的回复。我编辑过这个表明build_classpath对于其他jar仍然是必需的,所以我不能删除它,因为测试项目也需要这些。你知道如何编辑它,以便它使用现有的罐子和foo项目中的类吗? – 2013-04-30 12:24:54
我编辑了我的答案,向您展示如何将目录本身添加到类路径中,而不是所有的.class文件。 – 2013-04-30 12:28:33
绝对正确!感谢那。这可能是一个糟糕的借口,因为每个人都必须处理相同的情况,但ant文档并不是非常有用,因为它包含的所有信息都是我甚至没有使用过的java类的信息。我只是假设会有像元素列表和适用的元素在每个地方有效。非常感谢你的帮助! – 2013-04-30 12:36:09