While at various conference sessions, or as a participant in development workshops, one of the sad realities to which I’m constantly reminded is that there are a large number of very experienced enterprise Java developers out there who simply don’t know how Maven works. As organizations start to plot a course on their DevOps roadmap, more and more Maven-based and Maven-integrated technologies will be introduced into the workforce. If developers don’t learn Maven and don’t get properly up to speed on Maven fundamentals, DevOps transitions will leave those developers in the dust.
A lack of Maven fundamentals
A lack of familiarity with Maven fundamentals among my enterprise Java compatriots is understandable. Java developers who cut their teeth on J2EE frameworks dealt heavily with Apache ANT and never got the chance to learn Maven. By the time Maven started pushing ANT out of the picture, there was tooling built directly into IDEs such as NetBeans and Eclipse that abstracted away the Maven underpinnings. This largely hid how Maven worked, so it was not necessary to learn Maven fundamentals in order to build a complex application.
Given the seamless integration of Maven with IntelliJ or JDeveloper, a software developer had no compelling reason to dig down into the weeds and learn Maven by finding out how a Maven repository functions or how a maven dependency gets resolved. But in this brave new world of DevOps tooling, that lack of understanding of Maven fundamentals will come back to bite. An understanding how Maven works is more important than ever as organizations introduce DevOps tools like Jenkins and Gradle to the application lifecycle, both of which lean heavily on Maven repositories to store third-party libraries and Maven dependency management techniques.
Doing DevOps? Then learn Maven
For example, the most commonly run Jenkins build jobs are created using the Maven plugin. If a developer is thrown into playing the role of a DevOps engineer doesn’t understand Maven fundamentals, it will be tricky to read through a Jenkins log file and troubleshoot broken builds. And while Gradle can certainly be considered a competitor to Maven in the build tool space, many of the tasks a Gradle script performs are tied directly to Maven. A Gradle script might connect to a Maven repository, call upon Maven to resolve dependencies and reference Maven hosted JAR files and libraries during the build.
Learn Maven’s key concepts
Of course, the curator of the CI build doesn’t have to be a DevOps master. A strong understanding of Maven fundamentals is important, but being able to play the Maven game on expert level isn’t necessary either. The key Maven concepts every Java developer should be adept with include:
- How the project object model (POM) file works. This is the pom.xml file that sits at the root of every Maven project.
- The basic structure of a Maven project, and how Maven archetypes can be used to structure different types of projects, be it a a J2SE, Jakarta EE or Spring Boot app.
- The purpose of the commonly used Maven lifecycle phases and hooks, including: clean, compile, test, package, install and deploy.
- How dependencies are configured in the pom.xml file and how Maven resolves and links to external libraries at runtime.
- The role of the local Maven repository and the benefits that can be garnered through the use of a shared binary repository such as Apache Archiva, Sonatype’s Nexus repository manager or JFrog’s Artifactory.
That may sound like a tall order, but it’s actually not. Any software developer or member of the operations team could easily take a few hours on a Friday afternoon when they’re doing nothing other than pretending to work and just download Apache Maven, install the tool and configure the requisite MAVEN_HOME and M2_HOME system variables. Then take the rest of the afternoon to play around with the mvn command tool, create a Maven project or two, run a few Maven tasks and add a logging framework dependency to a piece of code. Within an hour or two, they’d likely know more about Maven than the captain of the DevOps team.
It’s not hard to learn Maven. It is worth a developer’s time to invest a few hours into playing with the build tool and mastering the Maven fundamentals, especially if the adoption of DevOps tools like Jenkins or Gradle are on the horizon.
How to become a Jenkins expert
Struggling to learn Jenkins? Check out these great, step-by-step Jenkins CI tutorials. They’ll make you a Jenkins CI expert in not time.
Step 1 — Download Jenkins and install the CI tool
Step 2 — Create your first Jenkins build job tutorial
Step 3 — Inject Jenkins environment variables into your scripts
Step 4 — Fix annoying Jenkins plugin errors
Step 5 — Put the Jenkins vs Maven debate behind you
Step 6 — Learn to use Boolean and String Jenkins parameters
Step 7 — Do a Jenkins Git plugin GitHub pull
Step 8 — Add knowledge of basic Git commands to your DevOps skillset