Hi, is it somehow possible to disable the sources ...
# gradle
w
Hi, is it somehow possible to disable the sources jar Maven publication for Kotlin Multiplatform projects? Also with Kotlin 1.8.21 the
android { publishing { ... } }
block also doesn’t respect when you leave out
withSourcesJar()
. Kotlin seems to always publish the sources, no matter what you set.
t
cc @Anton Lakotka [JB]
a
In 1.9 it will be possible with this DSL:
withSourcesJar(publish = false)
check related issue https://youtrack.jetbrains.com/issue/KT-55881 For 1.8.20 let me think how can I help you with disabling it
e
disabling the sources jar task (
tasks.named("...").configure { isEnabled = false }
) might work? not sure if it might still appear somehow though, didn't test...
w
Didn’t expect this would work, but it seems to turn off publishing correctly. Thank you!
BTW, for anyone also having this issue: you need to do this within
afterEvaluate { ... }
and use
tasks.findAll
to filter out all sourcesJar tasks because they might be prefixed like debugSourcesJar
e
Copy code
tasks.withType<org.gradle.jvm.tasks.Jar>().configureEach {
    onlyIf("Do not publish sources") { archiveClassifier.getOrNull() != "sources" }
}
should work without any
afterEvaluate
197 Views