Search code examples
mavengradlebuild-dependencies

Gradle cannot find Maven parent dependency with version RELEASE


I've got a "project B" with a pom.xml like this:

<parent>
    <groupId>org.company</groupId>
    <artifactId>projectA</artifactId>
    <version>RELEASE</version>
</parent>

<artifactId>projectB</artifactId>
<version>0.0.1</version>

where "project B" has "project A" as parent project pom.

I am trying to create a new "project C" using gradle now and if I want to use "project B" as a dependency, I specify build.gradle like this :

repositories {
    maven {
         url "http://mycompany:8081/artifactory/repository"
    }
}

dependencies {
    compile group: 'org.company', name: 'projectB', version: '0.0.1'
}

But I get the following error:

Could not resolve org.company:projectB:0.0.1.

Could not parse POM http://company:8081/artifactory/repository/org/company/projectB/0.0.1/projectB-0.0.1.pom

Could not find org.company:projectA:RELEASE.

Appart from setting my projectA version number to an specific one, is there a way to make this build work with gradle?

Is there a way gradle could find the correct version like maven is doing right now? My other maven projects have no problem finding the correct version.

I do not want to get the latests version of project A, maybe downloading the full project B jar would be enough.

P.D I am using gradle version 4.5 and maven version 3.5.2 on my local computer


Solution

  • I would do the following:

    • Download the jar and pom of projectB from your artifactory.
    • Change the pom by replacing "RELEASE" by a concrete version and the version tag of projectB by something new (like replacing version 1.2.3 by 1.2.3-manipulated).
    • Upload the jar and the new pom to your artifactory.
    • Reference version 1.2.3-manipulated from Gradle.

    AFAIK you do not need to change the original jar or its content, it is enough to change and redeploy the pom file (with a different version that indicates your manipulation).