How does maven compile only the modified java files?

11,575

Solution 1

I believe the Maven compiler plugin uses last modified dates on the source and class files to determine whether recompilation is necessary.

The compiler website is rather short on information, but the compiler:compile goal page has information on the following attribute, which finely tunes the staleness calculations: http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#staleMillis. That's about the only official statement regarding staleness.

Solution 2

Without knowing much about maven, I can tell you that generally speaking, "make"-like tools use the "last changed" timestamp, which would explain the issue you had with svn ( see Wikipedia on Subversion's weaknesses.

Share:
11,575

Related videos on Youtube

Senthil Kumar
Author by

Senthil Kumar

Software Engineer

Updated on September 14, 2022

Comments

  • Senthil Kumar
    Senthil Kumar about 1 year

    I was just curious to know this, when i give mvn install without doing 'clean', maven compiles only the modified java files. How does maven identify a java file is modified or not? I believe it is not using the last modified property of the file.

    Reason for my belief: I had a module, after merging a change from svn, i gave mvn install and it didn't compile the modified file and when i looked at the change i saw that 'long' were modified to 'Long' in getters and setters.

    So i just want to know how maven identifies if a java file has changed or not?

    (P.S I'm using Apache Maven 3.0.3, if that matters)

  • Senthil Kumar
    Senthil Kumar over 11 years
    Guess my belief is wrong and it does use last modified property. Thanks for the link!
  • George Birbilis
    George Birbilis over 5 years
    just noticed at maven.apache.org/plugins/maven-compiler-plugin/…, that the "useIncrementalCompilation" says "since 3.1"
  • J Mas
    J Mas almost 5 years
    @duncan-jones where modified date is saved. I didn't find information in "target" folder. for example I changed two classes in one hour run compile, than in one hour change one of two classes. how manen find out what is the files is changed