I have just upgraded my Gradle to 5.x and I'm having a new error when I try to sync my library project. This error is coming from a publishing block that I need to publish my library to maven local.
This is what I used to do with Gradle 4 and it worked just fine :
apply plugin: 'maven-publish'
publishing {
publications {
library(MavenPublication) {
groupId = 'myGroupId'
artifactId = 'myArtifactId'
version = android.defaultConfig.versionName
artifact bundleDebugAar
}
}
}
With Gradle 5, I now have an error about the artifact when I sync the gradle project:
ERROR: Could not get unknown property 'bundleDebugAar' for object of type org.gradle.api.publish.maven.internal.publication.DefaultMavenPublication.
When I remove the artifact line, I can sync the project but when I'm trying to publishToMavenLocal my build is failing :
Execution failed for task ':mypackage:generatePomFileForLibraryPublication'.
No value has been specified for this provider.
I looked in the gradle upgrading guide but I don't know how to solve my issue: https://docs.gradle.org/5.0/userguide/upgrading_version_4.html#rel5.0:pom_compile_runtime_separation
Can anybody tell me what's changed in this new version that I'm not seeing please ? Thanks.
Bookmark this question. Show activity on this post.
Short answer: yes. There's no conflict between having two independent build scripts for the same project, one in Maven and one in Gradle.
In Gradle, the groupId is known just as group , the artifactId is known as name , and the version is identically version .
you may try this.
project.afterEvaluate {
publishing {
publications {
library(MavenPublication) {
groupId = 'myGroupId'
artifactId = 'myArtifactId'
version = android.defaultConfig.versionName
artifact bundleDebugAar
}
}
}
}
With gradle 4.8+ you have to enclose the publishing{}
block inside a project.afterEvaluate
project.afterEvaluate {
publishing {
publications {
aar(MavenPublication) {
//...
artifact bundleReleaseAar
}
}
}
}
You can find the official doc here:
Prior to Gradle 4.8, the publishing {} block was implicitly treated as if all the logic inside it was executed after the project was evaluated. This was confusing, because it was the only block that behaved that way. As part of the stabilization effort in Gradle 4.8, we are deprecating this behavior and asking all users to migrate their build.
Put this inside project.afterEvaluate:
project.afterEvaluate {
publishing {
publications {
mavenDebugAAR(MavenPublication) {
artifact bundleDebugAar
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With