how to compile only changed source files using ANT

后端 未结 2 2082
伪装坚强ぢ
伪装坚强ぢ 2021-02-09 10:28

I am trying to write ant build for compiling source folder here is my script target for compiling.

 

        
2条回答
  •  醉梦人生
    2021-02-09 11:28

    As I understand, compiling only the modified java files is the default behavior of ant javac task. Ant uses the timestamp of a .java file and its corresponding .class file to determine if the a Java file needs to be recompiled. I have used it in many projects and never have issues.

    Here are a few things you can check

    1. Is your source tree directory structure matching your Java package structure? Please see Why does ant always recompile all my Java files?. This is probably the number 1 reason since it is in the FAQ.

    2. I see your compile target depends on init target? What does the init target do? Does it depends on any clean target or does it cleanup the .class files?

    3. What is your ant version? Can you try a different ant version to see if you still have the same problem?

    4. If none of the above fixes your issue, after the compilation, can you manually check the .class file timestamp and compare it with the timestamp of the corresponding .java file?

提交回复
热议问题