From 7c2fd4ed9888e0556e357a0e139ca6e1b97ee42b Mon Sep 17 00:00:00 2001 From: Philipp Schirmer Date: Mon, 11 Mar 2024 09:00:27 +0100 Subject: [PATCH] Listen for Java and Dokka plugin setup (#46) --- .github/workflows/build-and-publish.yaml | 3 +-- .github/workflows/release.yaml | 2 +- build.gradle.kts | 15 +------------ settings.gradle | 3 +-- .../com/bakdata/gradle/SonatypePlugin.kt | 21 ++++++++----------- 5 files changed, 13 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build-and-publish.yaml b/.github/workflows/build-and-publish.yaml index 3082cb3..6bf697b 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.42.0 + uses: bakdata/ci-templates/.github/workflows/java-gradle-plugin.yaml@1.43.0 secrets: sonar-token: ${{ secrets.SONARCLOUD_TOKEN }} sonar-organization: ${{ secrets.SONARCLOUD_ORGANIZATION }} @@ -19,5 +19,4 @@ jobs: ossrh-username: ${{ secrets.SONATYPE_OSSRH_USERNAME }} gradle-publish-key: ${{ secrets.GRADLE_PLUGIN_PUBLISH_KEY }} gradle-publish-secret: ${{ secrets.GRADLE_PLUGIN_PUBLISH_SECRET }} - github-username: ${{ secrets.GH_USERNAME }} github-token: ${{ secrets.GH_TOKEN }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2e0e77a..84bacfd 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.42.0 + uses: bakdata/ci-templates/.github/workflows/java-gradle-release.yaml@1.43.0 with: release-type: "${{ inputs.release-type }}" diff --git a/build.gradle.kts b/build.gradle.kts index 196f411..89725ad 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,10 +1,9 @@ plugins { // release - id("net.researchgate.release") version "3.0.2" + id("com.bakdata.release") version "1.3.0" // 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.2.2" - 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 } @@ -38,12 +37,6 @@ configure { } } -configure { - githubUser = "bakdata" - futureVersionTag = findProperty("changelog.releaseVersion")?.toString() - sinceTag = findProperty("changelog.sinceTag")?.toString() -} - subprojects { apply(plugin = "java") @@ -88,11 +81,5 @@ subprojects { } } -release { - git { - requireBranch.set("master") - } -} - val sonarqube by tasks sonarqube.enabled = false //FIXME requires Java 17 diff --git a/settings.gradle b/settings.gradle index 78d1b80..e517796 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,7 +1,6 @@ pluginManagement { repositories { - maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } - maven { url 'https://plugins.gradle.org/m2/' } + gradlePluginPortal() } } diff --git a/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt b/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt index 0d28e2c..14c7a1a 100644 --- a/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt +++ b/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt @@ -31,6 +31,7 @@ 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.JavaPlugin import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.maven.MavenPublication @@ -220,22 +221,18 @@ class SonatypePlugin : Plugin { apply(plugin = "signing") apply(plugin = "org.gradle.maven-publish") - // 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) - } - } - + project.plugins.matching { it is JavaPlugin }.all { configure { withSourcesJar() withJavadocJar() } + + project.tasks.matching { it.name == "dokkaJavadoc" }.all { + val javadocTask: Task = this + tasks.named("javadocJar") { + from(javadocTask) + } + } } configure {