As part of Dokka upgrade V2 I need to publish an HTML jar of documentation from Dokka. I use this block to generate that jar:
val htmlJarTask = tasks.register<Jar>("htmlJar") {
archiveClassifier.set("htmldoc")
dependsOn(tasks.dokkaGeneratePublicationHtml)
from(project.layout.buildDirectory.dir("dokka/html"))
}
I then include this task as an artifact in the publishing block. This is a kotlin multiplatform project with Android, JVM, and Linux targets to be published. There are other targets but only these build on the linux host where this is being run. The signing plugin is defined simply like this:
signing {
isRequired = true
sign(publishing.publications)
}
Attempting to run publishToMavenLocal then fails with this error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':KmpIO:signKotlinMultiplatformPublication' (type 'Sign').
- Gradle detected a problem with the following location: '/mnt/Projects/KmpIO/KmpIO/build/libs/KmpIO-0.1.8-htmldoc.jar.asc'.
Reason: Task ':KmpIO:publishJvmPublicationToMavenLocal' uses this output of task ':KmpIO:signKotlinMultiplatformPublication' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
Possible solutions:
1. Declare task ':KmpIO:signKotlinMultiplatformPublication' as an input of ':KmpIO:publishJvmPublicationToMavenLocal'.
2. Declare an explicit dependency on ':KmpIO:signKotlinMultiplatformPublication' from ':KmpIO:publishJvmPublicationToMavenLocal' using Task#dependsOn.
3. Declare an explicit dependency on ':KmpIO:signKotlinMultiplatformPublication' from ':KmpIO:publishJvmPublicationToMavenLocal' using Task#mustRunAfter.
Each target platform should use the same jar for itself and sign its copy during build. Why does gradle detect these target platforms crossovers? In this case the “JVM” target should need no dependency from the “Multiplatform” target. The jar should be copied for each target’s publication.
FYI as far as I can tell this is nearly identical to how I did a javadoc jar from Doka V1, and that worked fine. I don’t know why this HTML jar artifact is different.
Thanks in advance for any info/help.