Speakers: Chandra Gunter and Rodrigo Graciano
@CGuntur and @rodrigograciano
For more, see the 2024 DevNexus Blog Table of Contents
General
- Apache Maven 4 is still in alpha
- Avoid profiles where can
- Shoutout for mvn verify (vs maven install)
- Sample code: https://github.com/c-guntur/maven4
Pain Points in Maven 3
- Painful to maintain versions in multi module projects – flatten-maven-plugin helps with child versions but has hissues with profile interpolation. ci-friendly-flatten-maven-plugin solves profile interpolation problem but requires including third party plugin
- No implicit way to separate build info from consumer info. Why do consumers need SCM location and Jira link – flatten-maven-plugin and c-friendly-flatten-maven-plugin help
- Handling versions of sibling modules is a chore
- We use default versions for plugins. Ex: compiler version has default so not everyone specifies.
Creating BOM (Bill of Materials) not easy. No way to identify that default version is in use
Maven 4
- Requires Java 17+ to run Maven and Java 17 to compile (but can use Java 17 to compile earlier version)
- New schema version in <project> xmlns
- <moduleVersion> is now 4.1.0
- Can use <version>${revision}</version> without plugin – can pass from root pom or command line
- Get warning in build log if use the default version number of any plugins
- Two poms in .m2 for artifact. artifact-version-build.pom is what is used to build and artifact-version.pom is the consumer pom that goes to the repo when deploy
- No need to specify version number of parent in multi module project. Figures out automatically. Version is still allowed. It is an optional field so can specify older version at will.
- Build caching is improved so faster performance. ex: less re-compiling
My take
I didn’t take notes on Maven itself only the differences between Maven 3 and 4. I know it was necessary to get everyone on the same page. Given everyone raised their hand on using Maven, I wonder if could have been briefer. (Got to limitations of Maven 3 at 20 minute mark) I liked the interaction between the presenters to make it a conversation. The list of Maven 3 problems was great. And the demo of how Maven 4 fixes was good.