Aleon Q
01/08/2023, 2:14 PMsources.jar
from being published in a kotlin multiplatform [androidJvm target] project? I have a requirement not to publish the source code with the artifacts on sonatype but I can not get the setup to skip publishing sources.jar. I would eventually like to replace the sources.jar with an empty-sources.jar (to satisfy maven central’s constraints), but I cant get to remove the sources.jar from being published to begin with.
Here is what I tried:
• I checked that I am not adding sources.jar artifact in publications closure.
• I created a task that finalizes the sourcesjar task to delete the generated sources.jar, but gradle smartly recognizes that some files are deleted and it re-creates the sources.jar.
• I also created a task that creates an empty-sources.jar which I then added to publications closure like so artifact(emptySourcesJar.get())
but I get an error saying : Invalid publication ‘androidRelease’: multiple artifacts with the identical extension and classifier (‘jar’, ‘sources’). which is really nice error messaging since that tells me that I can not have multiple sources.jars, but I tried this thinking it could replace the one automatically being generated by the multiplatform plugin.
• I tried searching the channel, stackoverflow for any similar discussions but couldnt find any (they were mostly looking to publish missing sources.jar)
I am using multiplatform version 1.7.21 and followed the guilde here to publish to maven central. The guile is well written and works like a charm, just that I need not to publish sources.jar.
It would be really cool if someone could point me in the right direction here.
Thanksephemient
01/09/2023, 3:02 AMephemient
01/09/2023, 3:02 AMephemient
01/09/2023, 3:40 AM// needs to be fully-qualified in buildscripts because org.gradle.api.tasks.bundling.Jar is a default import
tasks.withType<org.gradle.jvm.tasks.Jar>()
// sources JARs from all variants
.matching { it.name.endsWith("sourcesJar", ignoreCase = true) }
.configureEach {
// use this if you want to prevent publication
enabled = false
// use this if you want to publish an empty JAR
exclude("*")
}
Aleon Q
01/09/2023, 7:26 AMAleon Q
01/17/2023, 6:07 AM