Search code examples
javamavengradledependenciespom.xml

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. I can solve this problem while generating the single pom of "BaseProject" and convert:

"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. 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

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. I think they are dependencies of my projects dependencies.

enter image description here

update 2

here is parts of the pom of the secondary dependency:

<?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.

update 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.

+--- 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  

Solution

  • using maven 5.2.1 or higher, there is a task named publishtoMavenLocal which uses version mapper behind the seen and publishing with this version of maven will resolve the actually used version of the plugins in created pom that located in build\publications\mavenjava