From 28038a8d46015c9fa8f16819c1be79089f82d248 Mon Sep 17 00:00:00 2001 From: Philipp Schirmer Date: Wed, 28 Feb 2024 09:03:05 +0100 Subject: [PATCH 1/6] Register javadoc and sources after evaluating project --- .../main/kotlin/com/bakdata/gradle/SonatypePlugin.kt | 11 +++++++---- .../gradle-plugins/com.bakdata.sonatype.properties | 0 2 files changed, 7 insertions(+), 4 deletions(-) rename sonatype/src/{test => main}/resources/META-INF/gradle-plugins/com.bakdata.sonatype.properties (100%) diff --git a/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt b/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt index 70f8ad9..8c99c5b 100644 --- a/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt +++ b/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt @@ -221,15 +221,18 @@ class SonatypePlugin : Plugin { apply(plugin = "org.gradle.maven-publish") tasks.findByName("dokka")?.apply { - tasks.creating(Jar::class) { + tasks.create("javadocJar", Jar::class.java) { archiveClassifier.set("javadoc") from(this) } } - configure { - withSourcesJar() - withJavadocJar() + // JavaPlugin might not have been applied yet + project.afterEvaluate { + configure { + withSourcesJar() + withJavadocJar() + } } configure { diff --git a/sonatype/src/test/resources/META-INF/gradle-plugins/com.bakdata.sonatype.properties b/sonatype/src/main/resources/META-INF/gradle-plugins/com.bakdata.sonatype.properties similarity index 100% rename from sonatype/src/test/resources/META-INF/gradle-plugins/com.bakdata.sonatype.properties rename to sonatype/src/main/resources/META-INF/gradle-plugins/com.bakdata.sonatype.properties From a404eb9baa3dc5c13aba2beba646ac380e164a1a Mon Sep 17 00:00:00 2001 From: Philipp Schirmer Date: Wed, 28 Feb 2024 09:14:12 +0100 Subject: [PATCH 2/6] Register javadoc and sources after evaluating project --- .../kotlin/com/bakdata/gradle/SonatypePlugin.kt | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt b/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt index 8c99c5b..037c876 100644 --- a/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt +++ b/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt @@ -24,12 +24,10 @@ 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.logging.Logging import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.publish.PublishingExtension @@ -38,7 +36,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,15 +218,14 @@ class SonatypePlugin : Plugin { apply(plugin = "signing") apply(plugin = "org.gradle.maven-publish") - tasks.findByName("dokka")?.apply { - tasks.create("javadocJar", Jar::class.java) { + // Java and Dokka plugins might not have been applied yet + project.afterEvaluate { + val main: SourceSet = the().sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME) + tasks.create(main.javadocJarTaskName) { archiveClassifier.set("javadoc") - from(this) + from(from(tasks.findByName("javadoc") ?: tasks.findByName("dokka"))) } - } - // JavaPlugin might not have been applied yet - project.afterEvaluate { configure { withSourcesJar() withJavadocJar() From 7b431121f84946e7031df340bcf1d1ebc3655347 Mon Sep 17 00:00:00 2001 From: Philipp Schirmer Date: Wed, 28 Feb 2024 09:16:03 +0100 Subject: [PATCH 3/6] Register javadoc and sources after evaluating project --- sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt b/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt index 037c876..d72b6cf 100644 --- a/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt +++ b/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt @@ -223,7 +223,7 @@ class SonatypePlugin : Plugin { val main: SourceSet = the().sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME) tasks.create(main.javadocJarTaskName) { archiveClassifier.set("javadoc") - from(from(tasks.findByName("javadoc") ?: tasks.findByName("dokka"))) + from(tasks.findByName("javadoc") ?: tasks.findByName("dokka")) } configure { From ceec5f929efd22bb1370702a472c1f9a492f5696 Mon Sep 17 00:00:00 2001 From: Philipp Schirmer Date: Wed, 28 Feb 2024 09:33:31 +0100 Subject: [PATCH 4/6] Register javadoc and sources after evaluating project --- .../kotlin/com/bakdata/gradle/SonatypePlugin.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt b/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt index d72b6cf..0d28e2c 100644 --- a/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt +++ b/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt @@ -28,6 +28,8 @@ 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.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 @@ -220,10 +222,14 @@ class SonatypePlugin : Plugin { // Java and Dokka plugins might not have been applied yet project.afterEvaluate { - val main: SourceSet = the().sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME) - tasks.create(main.javadocJarTaskName) { - archiveClassifier.set("javadoc") - from(tasks.findByName("javadoc") ?: tasks.findByName("dokka")) + 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 { From a389d077df334b15fed3a6584b026cd155e97645 Mon Sep 17 00:00:00 2001 From: Philipp Schirmer Date: Wed, 28 Feb 2024 10:01:25 +0100 Subject: [PATCH 5/6] Register javadoc and sources after evaluating project --- .../META-INF/gradle-plugins/com.bakdata.sonatype.properties | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sonatype/src/{main => test}/resources/META-INF/gradle-plugins/com.bakdata.sonatype.properties (100%) diff --git a/sonatype/src/main/resources/META-INF/gradle-plugins/com.bakdata.sonatype.properties b/sonatype/src/test/resources/META-INF/gradle-plugins/com.bakdata.sonatype.properties similarity index 100% rename from sonatype/src/main/resources/META-INF/gradle-plugins/com.bakdata.sonatype.properties rename to sonatype/src/test/resources/META-INF/gradle-plugins/com.bakdata.sonatype.properties From 38e75034ad0599dab53086be9abd50de8881c18d Mon Sep 17 00:00:00 2001 From: Philipp Schirmer Date: Wed, 28 Feb 2024 10:02:02 +0100 Subject: [PATCH 6/6] Register javadoc and sources after evaluating project --- .github/workflows/build-and-publish.yaml | 2 +- .github/workflows/release.yaml | 2 +- build.gradle.kts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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