Christoph Forster
Christoph Forster

Reputation: 1858

Gradle Dependency Problem when Upgrading to Gradle 6

I have a gradle Project where I have a dependency on "hudson-core 3.3.3"

compile group: 'org.eclipse.hudson', name: 'hudson-core', version: '3.3.3'

This works without a problem when using Gradle 5.6.2

When I upgrade to Gradle 6.0.1 I receive the following error:

Could not resolve org.eclipse.hudson:hudson-remoting:3.0.3.
 Required by:
     project : > org.eclipse.hudson:hudson-core:3.3.3
     project : > org.eclipse.hudson:hudson-core:3.3.3 > org.eclipse.hudson:hudson-cli:3.3.3
  > Could not resolve org.eclipse.hudson:hudson-remoting:3.0.3.
     > inconsistent module metadata found. Descriptor: org.eclipse.hudson:hudson-remoting:3.0.4-SNAPSHOT Errors: bad version: expected='3.0.3' found='3.0.4-SNAPSHOT'

The Repository is always the same:

repositories {
mavenCentral()
maven {
    url 'http://repo.jenkins-ci.org/public/'
}

}

Any Ideas why this error happens?

Upvotes: 1

Views: 1341

Answers (3)

Anže Sodja
Anže Sodja

Reputation: 101

Another option is to define a repository that will download only a jar:

repositories {
    mavenCentral() {
        name = "Download only jar repo"
        metadataSources { artifact() }
        content {
            // Use this repository only for org.eclipse.hudson:hudson-remoting
            includeVersion("org.eclipse.hudson", "hudson-remoting", "3.0.3")
        }
    }
    mavenCentral()
}

Also since pom is not downloaded you would have to add hudson-remoting dependencies by hand to build.gradle. But luckily for this particular case hudson-core already contains the only dependency commons-codec:commons-codec:1.4 that hudson-remoting needs, so this is not needed.

Note: the order of repositories is important, although in that case it will work either way. If you don't want to care about the order when using repositories with filter check exclusive content filtering.

Upvotes: 2

froblesmartin
froblesmartin

Reputation: 1861

As said by @ToYonos, the problem is in the dependency itself.

Not perfect solutions, but 2 workarounds can be done as explained in Gradle's documentation (v6.7.1):

  1. Exclude that transitive dependency, for example in the current Gradle versions using implementation instead of compile:

    implementation('org.eclipse.hudson:hudson-core:3.3.3') { 
        exclude group: 'org.eclipse.hudson'
        exclude module: 'hudson-remoting'
    }
    
  2. Override that transitive dependency version:

    implementation('org.eclipse.hudson:hudson-remoting') {
        version {
            strictly '3.0.2' // As 3.0.3 is having the issue
        }
    }
    

Upvotes: 2

ToYonos
ToYonos

Reputation: 16833

In the pom.xml file of hudson-remoting 3.0.3, the version is <version>3.0.4-SNAPSHOT</version>

The issue is quite clear.

I tried with an old Gradle 4.4.1 and I am having the exact same issue. Likewise with Gradle 5.1.1 and your version, 5.6.2

I'm quite sure that if you clean your artefact cache for Gradle 5.6.2, it won't work anymore.

The error is on the repository side.

Upvotes: 1

Related Questions