Controlling the constraints

One of the requirements for a build tool is to be able to generate repeatable builds. In a project, the build tool should behave identically for all team members. While a project guideline can be made on the version of Java or Maven to be used, it would be easier if it could be enforced automatically.

This is where the Maven Enforcer plugin comes in.

How to do it...

  1. Open a simple project (project-with-enforcer).
  2. Add the following plugin configuration:
     <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <version>1.3.1</version> <executions> <execution> <id>enforce-versions</id> <goals> <goal>enforce</goal> </goals> <configuration> <rules> <requireMavenVersion> <version>3.2.3</version> ...

Get Apache Maven Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.