diff --git a/.github/workflows/build-and-publish.yaml b/.github/workflows/build-and-publish.yaml index c9c66a1..a327d2c 100644 --- a/.github/workflows/build-and-publish.yaml +++ b/.github/workflows/build-and-publish.yaml @@ -8,7 +8,7 @@ on: jobs: build-and-publish: name: Java Gradle - uses: bakdata/ci-templates/.github/workflows/java-gradle-plugin.yaml@1.40.8 + uses: bakdata/ci-templates/.github/workflows/java-gradle-plugin.yaml@1.41.0 secrets: sonar-token: ${{ secrets.SONARCLOUD_TOKEN }} sonar-organization: ${{ secrets.SONARCLOUD_ORGANIZATION }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ff57711..86fe9aa 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -16,7 +16,7 @@ on: jobs: java-gradle-release: name: Java Gradle - uses: bakdata/ci-templates/.github/workflows/java-gradle-release.yaml@1.40.8 + uses: bakdata/ci-templates/.github/workflows/java-gradle-release.yaml@1.41.0 with: release-type: "${{ inputs.release-type }}" diff --git a/build.gradle.kts b/build.gradle.kts index 955e415..42564b1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,7 +3,7 @@ plugins { id("net.researchgate.release") version "3.0.2" // eat your own dog food - apply the plugins to this plugin project id("com.bakdata.sonar") version "1.1.17" - id("com.bakdata.sonatype") version "1.1.18" + id("com.bakdata.sonatype") version "1.2.1" id("org.hildan.github.changelog") version "1.13.1" id("org.gradle.kotlin.kotlin-dsl") version "2.1.6" apply false id("com.gradle.plugin-publish") version "1.2.1" apply false diff --git a/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt b/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt index 70f8ad9..0d28e2c 100644 --- a/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt +++ b/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt @@ -24,12 +24,12 @@ package com.bakdata.gradle -import io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository import io.github.gradlenexus.publishplugin.NexusPublishExtension import org.gradle.api.GradleException import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.api.UnknownTaskException +import org.gradle.api.Task +import org.gradle.api.attributes.DocsType.JAVADOC import org.gradle.api.logging.Logging import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.publish.PublishingExtension @@ -38,7 +38,7 @@ import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven import org.gradle.api.publish.maven.tasks.GenerateMavenPom import org.gradle.api.publish.maven.tasks.PublishToMavenLocal import org.gradle.api.publish.plugins.PublishingPlugin -import org.gradle.api.tasks.SourceSetContainer +import org.gradle.api.tasks.SourceSet import org.gradle.api.tasks.bundling.Jar import org.gradle.kotlin.dsl.* import org.gradle.plugins.signing.Sign @@ -220,16 +220,22 @@ class SonatypePlugin : Plugin { apply(plugin = "signing") apply(plugin = "org.gradle.maven-publish") - tasks.findByName("dokka")?.apply { - tasks.creating(Jar::class) { - archiveClassifier.set("javadoc") - from(this) + // Java and Dokka plugins might not have been applied yet + project.afterEvaluate { + tasks.findByName("dokka")?.apply { + val javadocTask: Task = this + val main: SourceSet = + the().sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME) + tasks.create(main.javadocJarTaskName) { + archiveClassifier.set(JAVADOC) + from(javadocTask) + } } - } - configure { - withSourcesJar() - withJavadocJar() + configure { + withSourcesJar() + withJavadocJar() + } } configure {