Does Maven support incremental builds?

I can’t quite figure out the dynamic that drives the Maven community but it isn’t one that’s friendly to having fine-grained control over your build-process.

Anyhow, after digging around I found an answer that worked for me here: http://www.codesenior.com/en/tutorial/Java-Maven-Compile-Only-Changed-Files

Note that setting the value to false confused me at first, but an explanation is given here: https://stackoverflow.com/a/19653164/409638

Reproduced here for convenience:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.2</version>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
        <useIncrementalCompilation>false</useIncrementalCompilation>
    </configuration>
</plugin>

It’s the useIncrementalCompilation set to false that is key here.

I can confirm that when I run my build I have gone from:

[INFO] Changes detected - recompiling the module!
[INFO] Compiling 114 source files to /home/vagrant/workspace/splat/target/classes

to

[INFO] Compiling 1 source file to /home/vagrant/workspace/splat/target/classes

which has shaved a few seconds of my incremental build. Now all I’ve got to do is figure out how to disable all the other unnecessary cruft that’s slowing down my edit/evaluate cycles …

Leave a Comment