When building maven webapp by using mvn install
or mvn compile war:war
on two different machines resulting WAR files have 20MB difference and their build times are 1 and a half minutes apart (30s vs 2min)
By inspecting war files using WinRAR I've noticed that smaller WAR does not contain WEB-INF\\classes\\WEB-INF and WEB-INF\\classes\\resource folders.
The whole codebase is the same. POM.xml contains maven-compiler-plugin
, webapp and unit tests run well on both apps with difference that smaller WAR seems to not have included properties files for language locality.
Most likely one of the machines stores corrupted artifacts in the local maven repository or points to a mirror server with broken artifacts. When artifact has invalid pom.xml
or parent's pom.xml
can't be resolved you will get a warning:
The POM for is invalid, transitive dependencies (if any) will not be available
Inspect the console output and confirm there are no such warnings. See this answer for further reading .
It also could be Maven version used differs on both machines. This could result in Maven War Plugin running in different versions, one of them could be affected by a bug. Ensure that both builds use the same Maven version and configuration eg with Maven Wrapper .
There is also a chance that you have a non standard build with modules being bound manually to phases eg Maven Assembly Plugin bound to test
phase. Ensure that both machines build the artifact with exactly the same command.
Above generally illustrates why one should have a CI server to get reproducible builds.
The differences between the two machines may be the maven settings located in ~/.m2/settings.xml
consider adding a maven wrapper to your project @see : https://www.baeldung.com/maven-wrapper
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.