Reputation: 10204
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.
Upvotes: 1
Views: 360
Reputation: 10204
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
The ANLTR3 command-line option "-make" only generates new files in case they are older than the grammar. This behaviour might have an effect on dependent tasks like "compile", which could result in nothing to be processed because it is up to date.
Upvotes: 3