Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why android gradle maven publish artifact bundleRelease not found

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

I add project.afterEvaluate{//block},but it doesn't work. What should i do to set the artifact

like image 516
neuyuandaima Avatar asked Jul 20 '18 01:07

neuyuandaima


People also ask

How to publish build info and artifacts from a Gradle Android project?

How to Publish Build Info and Artifacts from a Gradle Android Project into Artifactory? 1 Execute a Git clone in your client machine from here. 2 In the gradle-android example HERE, make sure the following settings are in place before running the gradle publish... More ...

Does bundlereleaseaar exist in./gradlew?

However, I am able to see that bundleReleaseAar does indeed exist when I run ./gradlew tasks, and I can execute that task just fine. What is preventing it from being used as an artifact in my deployment now?

How to publish Android apps using Maven publish plugin?

To start using Maven Publish plugin in your Android project simply add this code to the module’s build.gradle which you’re going to publish: As mentioned in Android guide for using this plugin, you can do not only library publication artifacts, using this script, but also application artifacts.

What is the use of Maven compatible in Gradle?

mavenCompatible = true //Convert any dots in an [organization] layout value to path separators, similar to Maven's groupId-to-path conversion. True if not specified // Reference to Gradle publications defined in the build script.


2 Answers

Android Gradle Plugin 3.3.x (at least -alpha releases at the time of writing this answer) has breaking change, task bundleRelease was renamed to bundleReleaseAar

So the solution is to use: bundleReleaseAar instead of bundleRelease.

Note: "release" in the task name is buildType/flavor combination, thus it might be different in your setup.


Generic answer: bundleRelease is a task, to find its new name you can run ./gradlew tasks --all

like image 55
Artem Zinnatullin Avatar answered Sep 21 '22 18:09

Artem Zinnatullin


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 '<User with deployment rights>'
                    password '<User password>'
                }
                url '<URL to nexus>'
            }

            maven {
                name 'nexusRelease'
                credentials {
                    username '<User with deployment rights>'
                    password '<User password>'
                }
                url '<URL to nexus>'
            }
        }
    }
}
like image 39
Satarus Avatar answered Sep 22 '22 18:09

Satarus