How does maven compile only the modified java files?

Senthil Kumar picture Senthil Kumar · Aug 2, 2012 · Viewed 11.1k times · Source

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)

Answer

Duncan Jones picture Duncan Jones · Aug 2, 2012

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.