为什么 ANT javac 任务一次又一次地重新编译我的 .java
将递归扫描源目录和目标目录 要编译的 Java 源文件。仅 Java 文件没有 相应的 .class 文件或类文件早于 .java 文件将被编译。
以上内容来自javac Task,ANT Apache。但我真的不明白为什么在我的例子中 .java 会一次又一次地重新编译。
我的工作目录是.../trunk
我的源文件(.java)位于 trunk/src
我的目标文件(.class)位于 trunk/bin
我的.java 文件使用默认包,即没有包声明。
javac 任务在
<javac srcdir="${src}"
destdir="${bin}"
includeantruntime="false">
<classpath>
<pathelement location="${bin}"/>
<pathelement path="${java.class.path}"/>
</classpath>
</javac>
我定义的
<property name="src" value="src"/>
<property name="bin" value="bin/"/>
build.xml 中以这种方式使用似乎一切正常,但每次我运行 ANT 时,它都会重新编译 .java 文件。真是奇怪啊!有人愿意告诉我为什么吗?谢谢。
The source and destination directory will be recursively scanned for
Java source files to compile. Only Java files that have no
corresponding .class file or where the class file is older than the
.java file will be compiled.
The above is from javac Task, ANT Apache. But I really don't see why in my case .java is recompiled again and again.
My working directory is .../trunk
My source (.java) is located at trunk/src
My target (.class) is located at trunk/bin
My .java files use default package, namely, no package declaration.
The javac task is used this way in my build.xml
<javac srcdir="${src}"
destdir="${bin}"
includeantruntime="false">
<classpath>
<pathelement location="${bin}"/>
<pathelement path="${java.class.path}"/>
</classpath>
</javac>
where I have defined
<property name="src" value="src"/>
<property name="bin" value="bin/"/>
It seems everything is ok, but each time I run ANT, it recompiles the .java files. Really strange! Anyone would like to tell me why? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哦,我得到了答案。抱歉我没有把上面的故事全部讲完。实际上,在“javac”部分之前我有一个 antlr 词法分析器/解析器生成。为此,我应该添加“-make”选项,以便词法分析器和解析器不会使用更新的时间戳再次生成。 (来自 将 ANT 用于 ANTLR3< /a>
Oh, I got the answer. Sorry I did not tell all the story above. Actually, I have an antlr lexer/parser generation before the "javac" part. And for that, I should have added the "-make" option so that the lexer and parser will not be generated again with a more recent timestamp. (from Use ANT for ANTLR3