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

1

11

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>
Scoles answered 12/11, 2018 at 18:13 Comment(8)
plugins element is not closed.Lidda
Have you declared the plugins in the build->plugins section of your pom?Elutriate
Thanks @OrtomalaLokni, seems like it was lost while creating a post. It's closed in my pomScoles
@gjoranv, no I have not. Does it make any sense, since I've declared in <pluginManagement>?Scoles
It's easy to verify. Either, move the 'plugins' block directly under 'build' instead of 'pluginManagement'. Or just add the plugins inside 'build' without any version or config, which will then be "inherited" from pluginManagement.Elutriate
@Elutriate Wow! Declaring versions-maven-plugin inside "build -> plugins" works well! But I still cannot understand why it doesn't work inside <pluginManagement>....Scoles
@Scoles To understand read Maven: What is pluginManagement?Lidda
@Scoles Good to hear. I tried to distill this into an answer.Elutriate
E
12

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.

Elutriate answered 13/11, 2018 at 15:58 Comment(1)
Re: "I'm not sure if there is a list of plugins that don't need to be explicitly added" ⟶ Introduction to the Build Lifecycle – Built-in Lifecycle BindingsUnderbelly

© 2022 - 2024 — McMap. All rights reserved.