简体   繁体   English

从 gradle 到 maven 的转换,在依赖项的依赖项的版本名称中解析通配符“+”?

[英]gradle to maven conversion, resolve wildcard "+" in version name of dependencies of dependencies?

I have read other questions but they are not exactly my question.我已经阅读了其他问题,但它们不完全是我的问题。

I have set of projects which are currently build using Gradle and I am trying to switch everything to maven,as projects are based on Gradle naturally in versioning of the artifacts wildcard of "+" is used.我有一组当前正在使用 Gradle 构建的项目,我正在尝试将所有内容都切换到 maven,因为项目自然地基于 Gradle,在使用“+”的工件通配符的版本控制中。 I can solve this problem while generating the single pom of " BaseProject " and convert:我可以在生成“ BaseProject ”的单个pom并转换时解决这个问题:

"projectA-1.0.+" --> "projectA-1.0.0"

and it works fine.它工作正常。 but my problem is that, " projectA-1.0.0 " itself depends on " projectC-1.0.+ " , " projectD-1.0.+ " and " projectE-1.0.+ " and naturally I get compile error.但我的问题是, “了projectA-1.0.0”本身取决于“项目C-1.0 +”, “projectD-1.0 +”“projectE-1.0 +”自然我得到的编译错误。 the problem is that each project depends on another one and of course it does not look so interesting to edit all other projects.问题是每个项目都依赖于另一个项目,当然编辑所有其他项目看起来并不那么有趣。

"projectA-1.0.0"--> "projectC-1.0.+"
               \--> "projectD-1.0.+"
               \--> "projectE-1.0.+"--> "projectX-1.0.+" 
                                   \--> "projectZ-1.0.+" 

is there any possible solution or workaround for this problem?这个问题有什么可能的解决方案或解决方法吗?

Update 1更新 1

here is the picture of my error log, pay attention that these mentioned artifacts are not directly used in my project and I do not have them in my pom file.这是我的错误日志的图片,注意这些提到的工件并没有直接在我的项目中使用,而且我的 pom 文件中没有它们。 I think they are dependencies of my projects dependencies.我认为它们是我的项目依赖项的依赖项。

在此处输入图片说明

update 2更新 2

here is parts of the pom of the secondary dependency:这是次要依赖项的 pom 的一部分:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>mygroup</groupId>
  <artifactId>Myartifact</artifactId>
  <version>1808.0.0</version>
  <dependencies>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
      <version>2.6.2</version>
      <scope>compile</scope>
    </dependency>

    <dependency>
      <groupId>mygroup</groupId>
      <artifactId>mysecondaryartifact</artifactId>
      <version>1805.0.0+</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
</project>

versions resolved with "+" and it is not just in this one pom, this problem exists in all dependencies that translated from gradle.用“+”解决的版本,它不仅仅是在这个 pom 中,这个问题存在于从 gradle 翻译的所有依赖项中。

update 3更新 3

as you can see in the dependency tree, all versions are translated to maven understandable version, and they are understood by maven but only some of them are not being understood by maven.正如您在依赖关系树中看到的,所有版本都被转换为 Maven 可理解的版本,并且它们被 Maven 理解,但只有其中一些不被 Maven 理解。

+--- mygroup:myartifact:1808.0.+ -> 1808.0.0
|    +--- org.apache.logging.log4j:log4j-api:2.6.2
|    +--- org.apache.logging.log4j:log4j-core:2.6.2 (*)
|    +--- mygroup:mysecondaryartifactA:1805.0.0+ -> 1805.0.0 (*)    Resolves
|    +--- mygroup:mysecondaryartifactB:1805.0.+ -> 1902.0.0 (*)   Resolves
|    +--- mygroup:mysecondaryartifactC:1808.0.+ -> 1907.0.0       Resolves
|    \--- mygroup:mysecondaryartifactD:2.0.+ -> 2.0.0  Does not Resolve --> Missing artifact mygroup:mysecondaryartifactD:2.0.+
|         \--- commons-primitives:commons-primitives:1.0  

使用 maven 5.2.1 或更高版本,有一个名为 publishtoMavenLocal 的任务,它在看到的后面使用版本映射器,使用此版本的 maven 发布将解析位于 build\\publications\\mavenjava 中创建的 pom 中插件的实际使用版本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM