11

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

pixel
  • 24,905
  • 36
  • 149
  • 251
Borja Gorriz
  • 143
  • 9
  • 1
    dont you have to put the RELEASE version that you are interested in? "RELEASE" is not enough.... – OhadR Jan 31 '18 at 16:17
  • I think this is a duplicate: https://stackoverflow.com/questions/10370422/gradle-getting-the-latest-release-version-of-a-dependency – OhadR Jan 31 '18 at 16:19
  • Possible duplicate of [Gradle - getting the latest release version of a dependency](https://stackoverflow.com/questions/10370422/gradle-getting-the-latest-release-version-of-a-dependency) – OhadR Jan 31 '18 at 16:19
  • It seems like the same problem was exposed here: https://discuss.gradle.org/t/how-to-exclude-parent-poms-from-dependency-resolution-for-maven-artifact/5988 but I haven't found a suitable solution. – Borja Gorriz Jan 31 '18 at 16:22
  • And this is also the same issue, but no idea how to solve it: https://discuss.gradle.org/t/how-to-ignore-parent-pom-for-dependency-resolution/6155 – Borja Gorriz Jan 31 '18 at 17:13
  • You should simply put a literal version in there instead of using `RELEASE` something like `3.2.6`? – khmarbaise Jan 31 '18 at 18:27
  • I am trying to find another way, because I do not own the real project b code. but I am starting to belive there is no other way – Borja Gorriz Jan 31 '18 at 18:46
  • Could you verify if http://company:8081/artifactory/repository/org/company/projectA/ is listed in your artifactory? – ahasbini Feb 14 '18 at 11:06
  • Yes it exists but under it only the different versions folders are found, no pom. I mean there is only "company:8081/artifactory/repository/org/company/projectA/0.1" and "company:8081/artifactory/repository/org/company/projectA/0.2" folders – Borja Gorriz Feb 14 '18 at 13:32
  • Can you give us all your build.gradle files, even the project level one, not only the module level ones. If you didn't do it yet, put maven repository in the build.gradle file at level project either in the build section and in the dependencies section. – shadowsheep Feb 15 '18 at 14:38
  • Only the called project C is in gradle. I will edit to write the full gradle file. Why would I need the local maven repo on the build section if I need this as a dependency? Anyway I tried it and didn't solve the issue. – Borja Gorriz Feb 19 '18 at 11:47

1 Answers1

0

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

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142