Working on an AWS CodeBuild today for a project and I kept running into issues building a Java project. The build environment is Ubuntu 18.x running Java 1.8. The application included the mvnw (and mvnw.cmd) Maven helper wrappers. Time after time the build would work complete successfully on my local WSL Ubuntu 18 but in the pristine build environment it would fail over and over again. This is very likely due to some configuration locally since the build instance is re-created from scratch on every build.
So, I changed the build command from ‘./mvnw package’ to ‘mvn package’ to allow the package build target use the same Maven binary. The process now uses the same binary for clean, test, and package steps. I like this approach over the the original configuration as every step that requires Maven uses the same binary; and it does so via the same invocation vector.
Hope you find this helpful. Do you have any tips or bits of knowledge you would like to share? Let me know in the comments below.