Can Maven (jar/war) packaging be avoided if there are no source file changes?
I would like to be able to intelligently decide whether a web application has changed开发者_Go百科 and needs to be redeployed, but can't determine an effective way of doing so with Maven2.
For a given Java web application Maven won't recompile unchanged source files, but it will always repackage the .war artifact, thereby updating its timestamp. With an updated timestamp, I have to assume the artifact represents an updated snapshot version.
Is it possible to have Maven avoid repackaging where no source files have changed and a previously packaged .war file is still present in the target folder? At the very least, is it possible to have Maven avoid overwriting the previously packaged .war file if no changes were found?
You can try the setting of the maven-war-plugin which is by default set to true (force). But be carefull and read the warnings about the force flag in the docs.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<forced>false</forced>
</archive>
</configuration>
精彩评论