"Could not resolve all files for configuration" after upgrading Gradle

Viewed 713

I have a Gradle script that downloads the latest snapshot artifact from a Nexus server. It's been working fine with Gradle 5.4 but doesn't seem to be willing to work after upgrading to Gradle 6.5.

These are the build.gradle contents:

apply plugin: "java"
  repositories {
    maven {
        url "https://somerepo.com/repository/app-snapshot/"
                credentials {
                username 'a-user'
                password 'a-password'
            }
        authentication {
            basic(BasicAuthentication)
        }

    }
}

configurations.all {
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

  configurations {
    component
}
  dependencies {
    component group: "com.bla.ble, name: "component-name", version: "${version}-SNAPSHOT"

}
  task copyComponent(type: Copy) {
    from configurations.component
    into "/some/local/path"
}

Gradle fails as follows:

Execution failed for task ':copyWorkflow'.
> Could not resolve all files for configuration ':workflow'.
   > Could not find com.bla.ble:component-name:3.2.0-SNAPSHOT.
     Searched in the following locations:
       - https://somerepo.com/repository/app-snapshot/com/bla/ble/component-name/3.2.0-SNAPSHOT/maven-metadata.xml
       - https://somerepo.com/repository/app-snapshot/com/bla/ble/component-name/3.2.0-SNAPSHOT/component-name-3.2.0-20201130.163046-11.pom
     Required by:
         project :

I've I navigate to https://somerepo.com/repository/app-snapshot/com/bla/ble/component-name/3.2.0-SNAPSHOT/maven-metadata.xml this provides a valid metadata file and points to a snapshot that actually has a valid file.

I've then tried downgrading again to Gradle 5.4 and worked OK. I was also trying to find any deprecated options in Gradle 6.x but couldn't find what it makes it fail.

1 Answers

Found the solution through this post: https://discuss.gradle.org/t/how-to-fetch-maven-artifact-without-pom-file-in-gradle-6-0/33836/2

Short history: A breaking change introduced in Gradle 6.x prevents the artifacts from being downloaded if the POM is not present. To go around this requirement, the following needs to be added to the maven definition:

        metadataSources {
            artifact()
        }

More info: https://docs.gradle.org/current/userguide/upgrading_version_5.html?_ga=2.181891495.1612153887.1606754101-263409462.1606754101#maven_or_ivy_repositories_are_no_longer_queried_for_artifacts_without_metadata_by_default

Related