Skip to content

Commit

Permalink
Listen for Java and Dokka plugin setup (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp94831 authored Mar 11, 2024
1 parent 0ebcca8 commit 7c2fd4e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 31 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build-and-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down
15 changes: 1 addition & 14 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down Expand Up @@ -38,12 +37,6 @@ configure<com.bakdata.gradle.SonatypeSettings> {
}
}

configure<org.hildan.github.changelog.plugin.GitHubChangelogExtension> {
githubUser = "bakdata"
futureVersionTag = findProperty("changelog.releaseVersion")?.toString()
sinceTag = findProperty("changelog.sinceTag")?.toString()
}

subprojects {
apply(plugin = "java")

Expand Down Expand Up @@ -88,11 +81,5 @@ subprojects {
}
}

release {
git {
requireBranch.set("master")
}
}

val sonarqube by tasks
sonarqube.enabled = false //FIXME requires Java 17
3 changes: 1 addition & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pluginManagement {
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url 'https://plugins.gradle.org/m2/' }
gradlePluginPortal()
}
}

Expand Down
21 changes: 9 additions & 12 deletions sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -220,22 +221,18 @@ class SonatypePlugin : Plugin<Project> {
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<JavaPluginExtension>().sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME)
tasks.create<Jar>(main.javadocJarTaskName) {
archiveClassifier.set(JAVADOC)
from(javadocTask)
}
}

project.plugins.matching { it is JavaPlugin }.all {
configure<JavaPluginExtension> {
withSourcesJar()
withJavadocJar()
}

project.tasks.matching { it.name == "dokkaJavadoc" }.all {
val javadocTask: Task = this
tasks.named<Jar>("javadocJar") {
from(javadocTask)
}
}
}

configure<PublishingExtension> {
Expand Down

0 comments on commit 7c2fd4e

Please sign in to comment.