Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

configurations getByName not working in gradle when publishing POM file to Artifactory

I'm using a publishing section in my build.gradle file for publishing an Android library to Artifactory:

publishing {
  publications {
    aar(MavenPublication) {
        groupId packageName
        version = libraryVersion
        artifactId project.getName()

        // Tell maven to prepare the generated "*.aar" file for publishing
        artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")

        pom.withXml {
                def dependencies = asNode().appendNode('dependencies')
                configurations.getByName("_releaseCompile").getResolvedConfiguration().getFirstLevelModuleDependencies().each {
                    def dependency = dependencies.appendNode('dependency')
                    dependency.appendNode('groupId', it.moduleGroup)
                    dependency.appendNode('artifactId', it.moduleName)
                    dependency.appendNode('version', it.moduleVersion)
                }
            }
        }
    }
}

It fails with the following error:

Execution failed for task ':smartcardsdk:generatePomFileForAarPublication'.
> Could not apply withXml() to generated POM
> Configuration with name '_releaseCompile' not found.

This was not a problem with Android v2.x. Problem started when I upgraded to Android Studio v3 (and I guess Gradle v3.0.0 as well).

I'm guessing that the configurations are no longer stored with the _releaseCompile name.

Does anyone know what the new "name" should be?

Thanks.

like image 373
Nick Wright Avatar asked Nov 03 '17 12:11

Nick Wright


1 Answers

Just figured it out. You have to change it to:

"releaseCompileClasspath"
like image 194
Roberto Betancourt Avatar answered Nov 07 '22 11:11

Roberto Betancourt