为什么在gradle:3.2.1上发生未知属性'bundleRelease'错误?

时间:2018-10-15 07:17:10

标签: android maven gradle maven-plugin maven-publish

classpath 'com.android.tools.build:gradle:3.1.4'更新为classpath 'com.android.tools.build:gradle:3.2.1'

发生错误:

FAILURE: Build failed with an exception.

* What went wrong:
Exception thrown while executing model rule: PublishingPlugin.Rules#publishing(ExtensionContainer)
> Could not get unknown property 'bundleRelease' for object of type org.gradle.api.publish.maven.internal.publication.DefaultMavenPublication.

错误出现在文件 mavenCustom.gradle

apply plugin: 'maven-publish'
apply plugin: 'signing'

publishing {
    publications {
        androidLibrary(MavenPublication) {
            groupId publishedGroupId
            artifactId artifact
            version libraryVersion

            artifact bundleRelease// IN THIS LINE
            artifact sourcesJar
            artifact javadocJar

            // Add your description here
            pom.withXml {
                def projectTag = asNode()
                projectTag.appendNode('name', libraryName)
                projectTag.appendNode('description', libraryDescription)
                projectTag.appendNode('url', siteUrl)
                // Set your license
                def licenseTag = projectTag.appendNode('licenses').appendNode('license')
                licenseTag.appendNode('name', licenseName)
                licenseTag.appendNode('url', licenseUrl)
                def developerTag = projectTag.appendNode('developers').appendNode('developer')
                developerTag.appendNode('id', developerId)
                developerTag.appendNode('name', developerName)
                developerTag.appendNode('email', developerEmail)
                def scmTag = projectTag.appendNode('scm')
                scmTag.appendNode('connection', gitUrl)
                scmTag.appendNode('developerConnection', gitUrl)
                scmTag.appendNode('url', siteUrl)
            }

            pom.withXml {
                final dependenciesNode = asNode().appendNode('dependencies')

                ext.addDependency = { Dependency dep, String scope ->
                    if (dep.group == null || dep.version == null || dep.name == null || dep.name == "unspecified")
                        return // ignore invalid dependencies

                    final dependencyNode = dependenciesNode.appendNode('dependency')
                    dependencyNode.appendNode('groupId', dep.group)
                    dependencyNode.appendNode('artifactId', dep.name)
                    dependencyNode.appendNode('version', dep.version)
                    dependencyNode.appendNode('scope', scope)

                    if (!dep.transitive) {
                        // If this dependency is transitive, we should force exclude all its dependencies them from the POM
                        final exclusionNode = dependencyNode.appendNode('exclusions').appendNode('exclusion')
                        exclusionNode.appendNode('artifactId', '*')
                        exclusionNode.appendNode('groupId', '*')
                    } else if (!dep.properties.excludeRules.empty) {
                        // Otherwise add specified exclude rules
                        final exclusionsNode = dependencyNode.appendNode('exclusions')
                        dep.properties.excludeRules.each { ExcludeRule rule ->
                            def exclusion = exclusionsNode.appendNode('exclusion')
                            exclusion.appendNode('artifactId', rule.module ?: '*')
                            exclusion.appendNode('groupId', rule.group ?: '*')
                        }
                    }
                }

                // List all "compile" dependencies (for old Gradle)
                configurations.compile.getAllDependencies().each { dep -> addDependency(dep, "compile") }
                // List all "api" dependencies (for new Gradle) as "compile" dependencies
                configurations.api.getAllDependencies().each { dep -> addDependency(dep, "compile") }
//                // List all "implementation" dependencies (for new Gradle) as "runtime" dependencies
                configurations.implementation.getAllDependencies().each { dep -> addDependency(dep, "runtime") }
            }
        }
    }

    repositories {
        maven {
            // change URLs to point to your repos, e.g. http://my.org/repo
            def mavenCustom = uri("d:/repository")
            url = mavenCustom
            name = 'mavenCustom'
        }
    }
}

0 个答案:

没有答案