why android gradle maven publish artifact bundleRelease not found

前端 未结 2 801
逝去的感伤
逝去的感伤 2020-12-10 04:47

When i sync project, android studio warn could not get unknown property \'bundleRelease\' for object of type org.gradle.api.publish.maven.internal.publication.DefaultM

2条回答
  •  清歌不尽
    2020-12-10 05:36

    So the answer from Artem Zunnatullin is correct. Just one addition, the project.afterEvaluate{//block} is necessary to make it work. This information can be overlooked very easily.

    Complete example:

    project.afterEvaluate {
        publishing {
            publications {
                mavenDebugAAR(MavenPublication) {
                    artifact bundleDebugAar
    
                    pom.withXml {
                        def dependenciesNode = asNode().appendNode('dependencies')
                        configurations.api.allDependencies.each { ModuleDependency dp ->
                            def dependencyNode = dependenciesNode.appendNode('dependency')
                            dependencyNode.appendNode('groupId', dp.group)
                            dependencyNode.appendNode('artifactId', dp.name)
                            dependencyNode.appendNode('version', dp.version)
    
                            if (dp.excludeRules.size() > 0) {
                                def exclusions = dependencyNode.appendNode('exclusions')
                                dp.excludeRules.each { ExcludeRule ex ->
                                    def exclusion = exclusions.appendNode('exclusion')
                                    exclusion.appendNode('groupId', ex.group)
                                    exclusion.appendNode('artifactId', ex.module)
                                }
                            }
                        }
                    }
                }
    
                mavenReleaseAAR(MavenPublication) {
                    artifact bundleReleaseAar
    
                    pom.withXml {
                        def dependenciesNode = asNode().appendNode('dependencies')
                        configurations.api.allDependencies.each { ModuleDependency dp ->
                            def dependencyNode = dependenciesNode.appendNode('dependency')
                            dependencyNode.appendNode('groupId', dp.group)
                            dependencyNode.appendNode('artifactId', dp.name)
                            dependencyNode.appendNode('version', dp.version)
    
                            if (dp.excludeRules.size() > 0) {
                                def exclusions = dependencyNode.appendNode('exclusions')
                                dp.excludeRules.each { ExcludeRule ex ->
                                    def exclusion = exclusions.appendNode('exclusion')
                                    exclusion.appendNode('groupId', ex.group)
                                    exclusion.appendNode('artifactId', ex.module)
                                }
                            }
                        }
                    }
                }
            }
    
            repositories {
    
                maven {
                    name 'nexusSnapshot'
                    credentials {
                        username ''
                        password ''
                    }
                    url ''
                }
    
                maven {
                    name 'nexusRelease'
                    credentials {
                        username ''
                        password ''
                    }
                    url ''
                }
            }
        }
    }
    

提交回复
热议问题