Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Project does not define required minimum version of Maven" with versions-maven-plugin 2.7

I'm facing the following error executing mvn versions:display-plugin-updates. Basing on this discussion, that was fixed in 2.6, but I'm using 2.7 (tried with 2.6 but with no success).

[ERROR] Project does not define required minimum version of Maven.
[ERROR] Update the pom.xml to contain maven-enforcer-plugin to
[ERROR] force the Maven version which is needed to build this project.
[ERROR] See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html
[ERROR] Using the minimum version of Maven: 3.0.5

Here's my <pluginManager> plugins:

<pluginManagement>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-enforcer-plugin</artifactId>
      <version>3.0.0-M2</version>
      <executions>
        <execution>
          <id>enforce-versions</id>
          <goals>
            <goal>enforce</goal>
          </goals>
          <configuration>
            <rules>
              <requireMavenVersion>
                <version>3.5.4</version>
              </requireMavenVersion>
            </rules>
          </configuration>
        </execution>
      </executions>
    </plugin>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>versions-maven-plugin</artifactId>
      <version>2.7</version>
      <configuration>
        <generateBackupPoms>false</generateBackupPoms>
      </configuration>
    </plugin>
  </plugins>
</pluginManagement>
like image 904
sys463 Avatar asked Nov 12 '18 18:11

sys463


People also ask

How do I change my Maven version?

Setting the Maven versionAdd an environment variable to your development system called ATLAS_MVN. Set the value of ATLAS_MVN to your Maven executable. Keep in mind this should be the Maven executable, not the Maven home. Verify the configuration by running the atlas-version command.

What is versions Maven plugin?

The Versions Maven Plugin is a Maven plugin which provides you the information of which libraries could be updated.

What is Maven clean plugin?

The Maven Clean Plugin, as the name implies, attempts to clean the files and directories generated by Maven during its build. While there are plugins that generate additional files, the Clean Plugin assumes that these files are generated inside the target directory.

What does Maven enforcer plugin do?

The Enforcer plugin provides goals to control certain environmental constraints such as Maven version, JDK version and OS family along with many more built-in rules and user created rules.


1 Answers

Even if you have pluginManagement for a given plugin, you still need to declare the plugin in your pom's build->plugins section for the configuration to take effect. While some plugins, e.g. maven-compiler-plugin are added to the project by default, this is clearly not the case for maven-enforcer-plugin (as shown by your experiment).

I'm not sure if there is a list of plugins that don't need to be explicitly added, but I assume it's the most common ones like maven-surefire-plugin and maven-clean-plugin.

like image 74
gjoranv Avatar answered Sep 23 '22 07:09

gjoranv