Provide a minimal version of Maven

Can I specify in POM the minimum version of Maven needed to create a project?

We spent a lot of time overcoming problems with people building our project due to bugs in older versions of Maven that cause massive artifacts (> 2 GB) to silently truncate. They tend to cause unsurprising, weird and ruined behavior in the final product.

Yes, we stated that 3.2.5 is the minimum version that we intend to support, but I wonder: is there a way to ask Maven to enlist if the version is less than this? I believe that I can easily write a plugin for this, but that seems redundant. So, I was hoping there was an easier way.

+4
source share
2 answers

You can use maven-enforcer-pluginand enforcespecify the minimum required version of Maven:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-enforcer-plugin</artifactId>
  <version>1.4.1</version>
  <executions>
    <execution>
      <id>enforce-maven</id>
      <goals>
        <goal>enforce</goal>
      </goals>
      <configuration>
        <rules>
          <requireMavenVersion>
            <version>3.2.5</version>
          </requireMavenVersion>
        </rules>
      </configuration>
    </execution>
  </executions>
</plugin>

If someone tries to build a project with a version of Maven less than 3.2.5, the build will fail.

With this plugin you can apply many different rules (Java version, OS ...); see the full list in the plugin documentation .

+8
source

If you only need the maven version, the prerequisites should already be doing the job:

see https://maven.apache.org/pom.html#Prerequisites

For something more than this will require a forced plugin (see another answer).

0
source

Source: https://habr.com/ru/post/1610437/


All Articles