在我的一个项目中,我试图在maven执行插件中使用DependencyConvergence规则。我注意到,如果我使用Maven 3.6.1,那么执行程序在下面的错误中失败了,但是maven 3.6.2的执行程序也很好。
有人能让我知道Maven 3.6.2中发生了哪些变化,导致DependencyConvergence传入3.6.2,但在小于3.6.2的其他maven版本中失败吗?
我已经在GitHub上放置了一个示例项目,在那里这个问题可以被复制。
Debrajs-MacBook-Air:es-plugins debrajmanna$ java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)maven-enforcer plugin- 3.0.0-M2
Debrajs-MacBook-Air:es-plugins debrajmanna$ ~/Downloads/apache-maven-3.6.1/bin/mvn validate
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] es-plugins [pom]
[INFO] dedup [jar]
[INFO]
[INFO] -----------------------< org.example:es-plugins >-----------------------
[INFO] Building es-plugins 1.0-SNAPSHOT [1/2]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (javaversion-dependencyconvergence) @ es-plugins ---
[INFO]
[INFO] -------------------------< org.example:dedup >--------------------------
[INFO] Building dedup 1.0-SNAPSHOT [2/2]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (javaversion-dependencyconvergence) @ dedup ---
[WARNING]
Dependency convergence error for com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.7.1 paths to dependency are:
+-org.example:dedup:1.0-SNAPSHOT
+-org.elasticsearch.test:framework:7.7.1
+-com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.7.1
and
+-org.example:dedup:1.0-SNAPSHOT
+-org.elasticsearch.test:framework:7.7.1
+-org.apache.lucene:lucene-test-framework:8.5.1
+-com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.7.2
[WARNING]
Dependency convergence error for commons-logging:commons-logging:1.2 paths to dependency are:
+-org.example:dedup:1.0-SNAPSHOT
+-org.elasticsearch.test:framework:7.7.1
+-org.elasticsearch.client:elasticsearch-rest-client:7.7.1
+-org.apache.httpcomponents:httpclient:4.5.10
+-commons-logging:commons-logging:1.2
and
+-org.example:dedup:1.0-SNAPSHOT
+-org.elasticsearch.test:framework:7.7.1
+-org.elasticsearch.client:elasticsearch-rest-client:7.7.1
+-org.apache.httpcomponents:httpasyncclient:4.1.4
+-commons-logging:commons-logging:1.2
and
+-org.example:dedup:1.0-SNAPSHOT
+-org.elasticsearch.test:framework:7.7.1
+-org.elasticsearch.client:elasticsearch-rest-client:7.7.1
+-commons-logging:commons-logging:1.1.3
and
+-org.example:dedup:1.0-SNAPSHOT
+-org.elasticsearch.test:framework:7.7.1
+-org.elasticsearch.client:elasticsearch-rest-client-sniffer:7.7.1
+-commons-logging:commons-logging:1.1.3
and
+-org.example:dedup:1.0-SNAPSHOT
+-org.elasticsearch.test:framework:7.7.1
+-commons-logging:commons-logging:1.1.3
[WARNING]
Dependency convergence error for org.apache.httpcomponents:httpcore:4.4.12 paths to dependency are:
+-org.example:dedup:1.0-SNAPSHOT
+-org.elasticsearch.test:framework:7.7.1
+-org.elasticsearch.client:elasticsearch-rest-client:7.7.1
+-org.apache.httpcomponents:httpclient:4.5.10
+-org.apache.httpcomponents:httpcore:4.4.12
and
+-org.example:dedup:1.0-SNAPSHOT
+-org.elasticsearch.test:framework:7.7.1
+-org.elasticsearch.client:elasticsearch-rest-client:7.7.1
+-org.apache.httpcomponents:httpcore:4.4.12
and
+-org.example:dedup:1.0-SNAPSHOT
+-org.elasticsearch.test:framework:7.7.1
+-org.elasticsearch.client:elasticsearch-rest-client:7.7.1
+-org.apache.httpcomponents:httpasyncclient:4.1.4
+-org.apache.httpcomponents:httpcore:4.4.10
and
+-org.example:dedup:1.0-SNAPSHOT
+-org.elasticsearch.test:framework:7.7.1
+-org.elasticsearch.client:elasticsearch-rest-client-sniffer:7.7.1
+-org.apache.httpcomponents:httpcore:4.4.12
[WARNING]
Dependency convergence error for org.apache.httpcomponents:httpclient:4.5.10 paths to dependency are:
+-org.example:dedup:1.0-SNAPSHOT
+-org.elasticsearch.test:framework:7.7.1
+-org.elasticsearch.client:elasticsearch-rest-client:7.7.1
+-org.apache.httpcomponents:httpclient:4.5.10
and
+-org.example:dedup:1.0-SNAPSHOT
+-org.elasticsearch.test:framework:7.7.1
+-org.elasticsearch.client:elasticsearch-rest-client:7.7.1
+-org.apache.httpcomponents:httpasyncclient:4.1.4
+-org.apache.httpcomponents:httpclient:4.5.6
and
+-org.example:dedup:1.0-SNAPSHOT
+-org.elasticsearch.test:framework:7.7.1
+-org.elasticsearch.client:elasticsearch-rest-client-sniffer:7.7.1
+-org.apache.httpcomponents:httpclient:4.5.10
[WARNING]
Dependency convergence error for org.apache.httpcomponents:httpcore-nio:4.4.10 paths to dependency are:
+-org.example:dedup:1.0-SNAPSHOT
+-org.elasticsearch.test:framework:7.7.1
+-org.elasticsearch.client:elasticsearch-rest-client:7.7.1
+-org.apache.httpcomponents:httpasyncclient:4.1.4
+-org.apache.httpcomponents:httpcore-nio:4.4.10
and
+-org.example:dedup:1.0-SNAPSHOT
+-org.elasticsearch.test:framework:7.7.1
+-org.elasticsearch.client:elasticsearch-rest-client:7.7.1
+-org.apache.httpcomponents:httpcore-nio:4.4.12
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.DependencyConvergence failed with message:
Failed while enforcing releasability. See above detailed error message.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for es-plugins 1.0-SNAPSHOT:
[INFO]
[INFO] es-plugins ......................................... SUCCESS [ 3.047 s]
[INFO] dedup .............................................. FAILURE [ 0.856 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.131 s
[INFO] Finished at: 2020-08-29T11:41:55+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M2:enforce (javaversion-dependencyconvergence) on project dedup: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :dedup同样,Maven 3.6.2也可以正常工作。
Debrajs-MacBook-Air:es-plugins debrajmanna$ ~/Downloads/apache-maven-3.6.2/bin/mvn validate
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] es-plugins [pom]
[INFO] dedup [jar]
[INFO]
[INFO] -----------------------< org.example:es-plugins >-----------------------
[INFO] Building es-plugins 1.0-SNAPSHOT [1/2]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (javaversion-dependencyconvergence) @ es-plugins ---
[INFO]
[INFO] -------------------------< org.example:dedup >--------------------------
[INFO] Building dedup 1.0-SNAPSHOT [2/2]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (javaversion-dependencyconvergence) @ dedup ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for es-plugins 1.0-SNAPSHOT:
[INFO]
[INFO] es-plugins ......................................... SUCCESS [ 1.743 s]
[INFO] dedup .............................................. SUCCESS [ 0.510 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.462 s
[INFO] Finished at: 2020-08-29T11:42:06+05:30
[INFO] ------------------------------------------------------------------------发布于 2020-08-30 11:30:54
它与MENFORCER-195和MNG-6713有关,它们都是Maven 3.6.2中的bug。
如果您使用的是3.6.2,请小心,因为这个区域有进一步回归,直到3.6.3才修复(不影响您的示例)。
我是如何找到那些票的:
让我们单独看一看每一次失败。从第一个开始是有意义的:
Dependency convergence error for com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.7.1 paths to dependency are:
+-org.example:dedup:1.0-SNAPSHOT
+-org.elasticsearch.test:framework:7.7.1
+-com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.7.1
and
+-org.example:dedup:1.0-SNAPSHOT
+-org.elasticsearch.test:framework:7.7.1
+-org.apache.lucene:lucene-test-framework:8.5.1
+-com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.7.2让我们看看[医] POM的相关部分
<dependency>
<groupId>com.carrotsearch.randomizedtesting</groupId>
<artifactId>randomizedtesting-runner</artifactId>
<version>2.7.1</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-test-framework</artifactId>
<version>8.5.1</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>显然,我们可以看到,所有的传递依赖的Lucene应该被排除。但是,如果我们回到错误的这一部分,执行器插件所抱怨的2.7.2版本甚至不应该在依赖树中!
...
+-org.apache.lucene:lucene-test-framework:8.5.1
+-com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.7.2当我为Maven的两个版本(3.6.1和3.6.2)打印Maven依赖树时,我看到的randomizedtesting-runner的唯一实例是2.7.1版本,所以这里有些可疑之处。
我的直觉告诉我,通配符排除很可能是罪魁祸首,所以从那以后,它只是一个简单的问题,在发布说明搜索类似的“排斥”或“通配符”。原来我是对的。
https://stackoverflow.com/questions/63644201
复制相似问题