Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error during publishing: No source set found for :modules:mockk:dokkaJavadoc/commonMain #2598

Closed
aSemy opened this issue Jul 30, 2022 · 2 comments · Fixed by #2728
Closed
Labels
bug documentation An issue/PR related to Dokka's external or internal documentation

Comments

@aSemy
Copy link
Contributor

aSemy commented Jul 30, 2022

Describe the bug

When I run ./gradlew publish I get an error

> Task :modules:mockk-agent:publishAllPublicationsToLocalProjectDirRepository
> Task :modules:mockk:compileKotlinJvm

> Task :modules:mockk:dokkaJavadoc
Transforming documentation model before merging
Merging documentation models
Transforming documentation model after merging
Creating pages

> Task :modules:mockk:dokkaJavadoc FAILED
> Task :modules:mockk:compileJava NO-SOURCE
> Task :modules:mockk:jvmMainClasses
> Task :modules:mockk:jvmJar UP-TO-DATE
> Task :modules:mockk:generateMetadataFileForJvmPublication

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':modules:mockk:dokkaJavadoc'.
> No source set found for :modules:mockk:dokkaJavadoc/commonMain 
...
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':modules:mockk:dokkaJavadoc'.
...
Caused by: java.lang.IllegalStateException: No source set found for :modules:mockk:dokkaJavadoc/commonMain 
	at org.jetbrains.dokka.javadoc.JavadocPageCreator.nodeForJvm(JavadocPageCreator.kt:197)
	at org.jetbrains.dokka.javadoc.JavadocPageCreator.signatureForNode(JavadocPageCreator.kt:210)
	at org.jetbrains.dokka.javadoc.JavadocPageCreator.pageForClasslike(JavadocPageCreator.kt:69)
	at org.jetbrains.dokka.javadoc.JavadocPageCreator.pageForPackage(JavadocPageCreator.kt:37)
	at org.jetbrains.dokka.javadoc.JavadocPageCreator.pageForModule(JavadocPageCreator.kt:30)
...

To Reproduce
Steps to reproduce the behavior, ideally with an example project

Here's the full project: mockk.zip

run ./gradlew publishAllPublicationsToLocalProjectDirRepository

Dokka configuration

I'm using buildSrc convention plugins.

Because I want to publish to Maven Central, I need a Javadoc jar.

package buildsrc.convention

import org.gradle.jvm.tasks.Jar

// buildsrc/convention/kotlin-multiplatform.gradle.kts
buildsrc/convention/kotlin-multiplatform.gradle.kts

plugins {
    kotlin("multiplatform")

    id("org.jetbrains.dokka")

    id("buildsrc.convention.base")
}

kotlin {
    targets.configureEach {
        compilations.configureEach {
            kotlinOptions {
                apiVersion = "1.5"
                languageVersion = "1.7"
            }
        }
    }
}

val javadocJar by tasks.registering(Jar::class) {
    from(tasks.dokkaJavadoc)
    archiveClassifier.set("javadoc")
}

I'm also using a convention plugin to set up the publishing config.

// buildsrc/convention/mockk-publishing.gradle.kts
package buildsrc.convention

import buildsrc.config.createMockKPom
import buildsrc.config.credentialsAction
import org.gradle.api.tasks.bundling.Jar

publishing {
    repositories {
        // publish to local dir, for testing
        maven(rootProject.layout.buildDirectory.dir("maven-internal")) {
            name = "LocalProjectDir"
        }
    }
    publications.withType<MavenPublication>().configureEach {
        createMockKPom()

        artifact(tasks.provider<Jar>("javadocJar"))

        signing.sign(this)
//        tasks.withType<Jar>().matching { it.archiveClassifier.orNull == "javadoc" }
    }
}

signing {
    if (signingKeyId.isPresent() && signingKey.isPresent() && signingPassword.isPresent()) {
        logger.lifecycle("[${project.displayName}] Signing is enabled")
        useInMemoryPgpKeys(signingKeyId.get(), signingKey.get(), signingPassword.get())
    }
}

// workaround for https://github.com/gradle/gradle/issues/16543
inline fun <reified T : Task> TaskContainer.provider(taskName: String): Provider<T> =
    providers.provider { taskName }
        .flatMap { named<T>(it) }

Installation

  • Operating system: Windows
  • Build tool: Gradle 7.5
  • Dokka version: 1.7.10
  • Kotlin Multiplatform 1.7.10
@aSemy aSemy added the bug label Jul 30, 2022
@aSemy
Copy link
Contributor Author

aSemy commented Jul 31, 2022

I fixed this by changing the JavadocJar task

val javadocJar by tasks.registering(Jar::class) {
//    from(tasks.dokkaJavadoc) // doesn't work
    from(tasks.dokkaHtml) // works!
    archiveClassifier.set("javadoc")
}

The error and the documentation wasn't clear on which task should be used.

@IgnatBeresnev IgnatBeresnev added the documentation An issue/PR related to Dokka's external or internal documentation label Aug 3, 2022
@IgnatBeresnev
Copy link
Member

Hi! Glad to hear it's been resolved

I'll close this for now, but I'll add this use case to the list of things that need to be documented with examples of configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug documentation An issue/PR related to Dokka's external or internal documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants