pernilla
10/24/2023, 12:49 PMafterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release
groupId = 'com.example.android'
artifactId = 'test'
version = '0.0.1'
}
debug(MavenPublication) {
from components.debug
groupId = 'com.example.android'
artifactId = 'test-debug'
version = '0.0.1'
}
}
}
}
But this doesn’t compile for my project. release(MavenPublication) is not found. Tried this way as well, but then I get error on aar-file:
create<MavenPublication>("maven") {
groupId = "com.example.android"
artifactId = "test"
version = "0.1.1"
artifact("$buildDir/outputs/aar/lib-debug.aar")
}
Vampire
10/24/2023, 1:10 PMafterEvaluate
is almost always a bad idea, but does just symptom treatment for the price of adding ordering problems, timing problems, and race conditions. I have no idea about multiplatform, so don't know whether it uses afterEvaluate
itself which might cause a need to follow suit with the bad practice.
But besides that, the upper syntax is Groovy DSL, the lower is Kotlin DSL.
So if you put the upper in a Kotlin DSL build script, it will of course fail, yes.Vampire
10/24/2023, 1:11 PMcreate<MavenPublication>("release") {
and create<MavenPublication>("debug") {
.Vampire
10/24/2023, 1:12 PMartifact(...)
, that is bad practice too.
Especially when there are components that you can publish, so even in the Kotlin DSL version publish the components, not hard-coded artifacts that then will not be built, or will be stale, and just be unreliable that way.pernilla
10/24/2023, 1:16 PMVampire
10/24/2023, 1:19 PMcomponents["debug"]
as documented in the Gradle docs ;-)Vampire
10/24/2023, 1:20 PMhow would I then enforce only publish debug for instance
publishDebugPublicationToMavenLocal
Vampire
10/24/2023, 1:20 PMpublishToMavenLocal
is just a convenience lifecycle task to publish all publications to maven localVampire
10/24/2023, 1:22 PMpernilla
10/24/2023, 1:31 PMcreate<MavenPublication>("debug") {
groupId = "groupid"
artifactId = "artifactid"
version = "0.1-SNAPSHOT"
from(components["debug"])
}
gives me: SoftwareComponentInternal with name 'debug' not found.
So the component specification seems missing or wrong.pernilla
10/24/2023, 1:38 PMVampire
10/24/2023, 1:40 PMartifact
Vampire
10/24/2023, 1:40 PMafterEvaluate
so you might indeed need to use it tooVampire
10/24/2023, 1:41 PMafterEvaluate
?pernilla
10/24/2023, 1:46 PMfrom(_components_["DebugAar"])
Vampire
10/24/2023, 3:17 PMDebugAar
? I thought debug
Vampire
10/24/2023, 3:18 PMpernilla
10/24/2023, 7:32 PMcreate<MavenPublication>("ReleaseAar") {
groupId = "com.company"
artifactId = "library"
version = project.version.toString()
val artifactFile = "$buildDir/outputs/aar/${project.name}-release.aar"
artifact(artifactFile)
}
And a println on components gives me:
components.forEach { c ->
println("Components: ${c.name}")
}
Components: kotlinVampire
10/24/2023, 7:38 PMVampire
10/24/2023, 7:39 PMpernilla
10/24/2023, 8:29 PMVampire
10/24/2023, 9:41 PMVampire
10/24/2023, 9:44 PMpernilla
10/25/2023, 7:41 AM