Can't publish Library
swapnil-musale opened this issue · comments
I have created the library using this web wizard. After doing the initial release code and setting up sonatype config on project. i was trying to release the initial version by running the ./gradlew publishAllPublicationsToSonatypeRepository
which is giving me an error.
Seems like there is some issue in task linking with each other or may be something else on my side. For better understanding I'm attaching screenshot of the error.
Can you please guide me what is the issue and how can i fix it.
Please, never take a screenshots of logs!
try to add this code block to the end of ./convention-plugins/src/main/kotlin/convention.publication.gradle.kts
afterEvaluate {
tasks.all {
if (name.startsWith("compileTestKotlin")) {
val target = name.substring("compileTestKotlin".length)
val sign = try {
tasks.named("sign${target}Publication")
} catch (e: Throwable) {
null
}
if (sign != null) {
dependsOn(sign)
}
}
}
}
if it helps, i will add the fix to the wizard
try to add this code block to the end of
./convention-plugins/src/main/kotlin/convention.publication.gradle.kts
afterEvaluate { tasks.all { if (name.startsWith("compileTestKotlin")) { val target = name.substring("compileTestKotlin".length) val sign = try { tasks.named("sign${target}Publication") } catch (e: Throwable) { null } if (sign != null) { dependsOn(sign) } } } }
Above mentioned code didn't worked but following different solution mentioned in the gradle
Below code worked for me
val signingTasks = tasks.withType<Sign>()
tasks.withType<AbstractPublishToMaven>().configureEach {
mustRunAfter(signingTasks)
}
thank you. I will add it
Although project is compiling with this change but I'm not able to see my lib on sonatype website
So not sure this is working or not
Have you tried to follow this tutorial?
https://dev.to/kotlin/how-to-build-and-publish-a-kotlin-multiplatform-library-going-public-4a8k
Hey @terrakok
Just for demo purpose I've created a dummy library with sample code base and tried to publish the library and hoilla it works.
Dummy Library : implementation("io.github.swapnil-musale.klibrary:kLibrary:1.0")
Just found 2 issue in the template code
- To fix the above mentioned error have add below code in
./convention-plugins/src/main/kotlin/convention.publication.gradle.kts
this file :
val signingTasks = tasks.withType<Sign>()
tasks.withType<AbstractPublishToMaven>().configureEach {
mustRunAfter(signingTasks)
}
- Command mentioned in the README.md file is not correct synthetically. Need to remove the
:dodo:
from the original command. So it will be become like./gradlew publishAllPublicationsToSonatypeRepository
.
If you want I can work on these 2 changes.
yes, please! it would be awesome 👍