配置getByName在将POM文件发布到Artifactory时无法在gradle中工作

时间:2017-11-03 12:51:39

标签: android build.gradle artifactory

我在build.gradle文件中使用发布部分将Android库发布到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)
                }
            }
        }
    }
}

失败并出现以下错误:

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

这对Android v2.x来说不是问题。我升级到Android Studio v3时出现问题(我猜Gradle v3.0.0也是如此)。

我猜测配置不再与_releaseCompile名称一起存储。

有谁知道新的"名称"应该是吗?

感谢。

1 个答案:

答案 0 :(得分:13)

刚想通了。您必须将其更改为:

bytesRead = read(gps_fd, buf, sizeof(buf) - 1);