版本:display-plugin-updates不了解maven-enforcer-plugin

Ric*_*cho 25 java maven maven-enforcer-plugin

所以,我正在尝试使用最新版本的一些插件.之前我已经使用了先决条件标签,但是很多资源(例子)说它应该被认为是弃用的,而且应该使用maven-enforcer-plugin.这是我的配置:

<plugin>
  <inherited>true</inherited>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-enforcer-plugin</artifactId>
  <version>1.3.1</version>
  <executions>
    <execution>
      <id>enforce-maven-3</id>
      <goals>
        <goal>enforce</goal>
      </goals>
      <configuration>
        <rules>
          <requireMavenVersion>
            <version>3.0.4</version>
          </requireMavenVersion>
        </rules>
        <fail>true</fail>
      </configuration>
    </execution>
  </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

但是,当我运行mvn版本时:display-plugin-updates我仍然得到这个文本:

[ERROR] Project does not define required minimum version of Maven.
[ERROR] Update the pom.xml to contain
[ERROR]     <prerequisites>
[ERROR]       <maven>3.0</maven>
[ERROR]     </prerequisites>
[INFO]
[INFO] Require Maven 2.0.6 to use the following plugin updates:
[INFO]   maven-jar-plugin ................................................ 2.4
[INFO]   maven-shade-plugin ............................................ 1.7.1
[INFO]
[INFO] Require Maven 2.2.1 to use the following plugin updates:
[INFO]   maven-jar-plugin ................................................ 2.6
[INFO]
[INFO] Require Maven 3.0 to use the following plugin updates:
[INFO]   maven-shade-plugin .............................................. 2.3
Run Code Online (Sandbox Code Playgroud)

使用先决条件标签代替工作.

Ric*_*cho 11

看来这个问题已经在这里报道(为了找到这个,可以去Aleksandr M).

显然,display-dependency-updates目标依赖于该prerequisites元素来找出当前项目所需的Maven版本并完全忽略enforcer-plugin,即使不能正常使用prerequisites-tag,它也是必需的.让依赖插件按预期运行.

  • 现在可以在https://github.com/mojohaus/versions-maven-plugin/issues/48找到该错误 (2认同)

UR6*_*LAD 7

为了避免这个消息,我使用了版本的maven-plugin的最新版本

mvn org.codehaus.mojo:versions-maven-plugin:2.7:display-plugin-updates
Run Code Online (Sandbox Code Playgroud)

请注意,它仍然需要对除项目之外的所有项目使用maven-enforcer-pluginmaven-plugin,或者对prerequisites包含项目的项目使用标记maven-plugin.