mavengwtmaven-war-plugingwt-maven-plugin

How can I find the reason that Maven is rebuilding?


When I run Maven after changing nothing, maven-compiler-plugin often recompiles Java files; or maven-war-plugin rebuilds or copies a war even though nothing changed; or gwt-maven-plugin builds Google Web Toolkit code (on some computers, not others), even though nothing changed.

How can I see the reason that Maven decides to rebuild something? For example, which files it thinks (incorrectly) have changed?

Here is an example: maven-compiler-plugin is recopying the war resources every time, even when nothing has changed. It is using "exploded" war to save time in development, but this occurs even with regular war.

But my question is more generally how to find out why a Maven goal chooses to rebuild rather than use existing output.

[INFO] Processing war project
[INFO] Copying webapp webResources [d:\dev\proj1/war/WEB-INF] to [d:\dev\proj1\target\proj1-0.0.1-SNAPSHOT]
[INFO]  Copying webapp webResources [d:\dev\proj1/lib/libs] to [d:\dev\proj1\target\proj1-0.0.1-SNAPSHOT]
[INFO]  Copying webapp resources [d:\dev\proj1\war]
 Webapp assembled in [37919 msecs]

Solution

  • Maven plugins have to implement staleness checks by their own (possibly using helpers) and they're free to log the reasons or not, so there's no generic answer (contrary to, say, Gradle). On the whole, Maven incremental build support is rather poor (see https://cwiki.apache.org/confluence/display/MAVEN/Incremental+Builds for instance, which is quite old, but still mostly correct AFAICT), and heavily dependent on each plugin (and their version)

    You could try running Maven with debug logs (mvn -X) and dig into the logs. But first try using the latest versions of the plugins. That doesn't mean you'd have your answer as to why the inputs were considered staled, or that it'd fix the observed behavior; but apart from debugging the plugins themselves, there's really no other solution.