From 065826bbeaa10d0bb93aed18b8ccda22ff1e149b Mon Sep 17 00:00:00 2001 From: Philipp Schirmer Date: Wed, 28 Feb 2024 13:19:01 +0100 Subject: [PATCH] Update --- README.md | 20 +++++++ build.gradle.kts | 59 +++++++++---------- .../com/bakdata/gradle/SonatypePlugin.kt | 15 +++-- 3 files changed, 55 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index d19caac..adff819 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,24 @@ A collection of small gradle plugin, mostly focused on deployment. **Sonar** Some defaults for easy integration of sonar on multi-module projects **Sonatype** is used for uploading to sonatype repos and ultimately publish to Maven Central +## Development +Snapshot versions of these plugins are published to Sonatype. +You can use them in your project by adding the following snippet to your `build.gradle.kts` + +``` +buildscript { + repositories { + maven { + url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots") + } + } + dependencies { + classpath("com.bakdata.gradle:sonar:0.0.1-SNAPSHOT") + classpath("com.bakdata.gradle:sonatype:0.0.1-SNAPSHOT") + } +} + +apply(plugin = "com.bakdata.sonar") +apply(plugin = "com.bakdata.sonatype") +``` diff --git a/build.gradle.kts b/build.gradle.kts index 42564b1..a3bd0d9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -52,42 +52,39 @@ subprojects { targetCompatibility = JavaVersion.VERSION_11 } - dependencies { - "testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:5.3.0") - "testImplementation"("org.junit.jupiter:junit-jupiter-api:5.3.0") - "testImplementation"("org.assertj", "assertj-core", "3.11.1") - "testImplementation"("org.junit-pioneer", "junit-pioneer", "0.3.0") + apply(plugin = "java-gradle-plugin") + + // config for gradle plugin portal doesn't support snapshot, so we add config only if release version + if (!version.toString().endsWith("-SNAPSHOT")) { + apply(plugin = "com.gradle.plugin-publish") } -} -// config for gradle plugin portal -// doesn't support snapshot, so we add config only if release version -if (!version.toString().endsWith("-SNAPSHOT")) { - subprojects.forEach { project -> - with(project) { - // com.gradle.plugin-publish depends on java-gradle-plugin, but it screws a bit this project - apply(plugin = "java-gradle-plugin") - apply(plugin = "com.gradle.plugin-publish") - project.afterEvaluate { - // java-gradle-plugin requires this block, but we already added the definitions in META-INF for unit testing... - configure { - plugins { - create("${project.name.capitalize()}Plugin") { - id = "com.bakdata.${project.name}" - implementationClass = "com.bakdata.gradle.${project.name.capitalize()}Plugin" - description = project.description - displayName = "Bakdata $name plugin" - } - } - } - // actual block of plugin portal config, need to be done on each subproject as the plugin does not support multi-module projects yet... - configure { - website = "https://github.com/bakdata/gradle-plugins" - vcsUrl = "https://github.com/bakdata/gradle-plugins" - tags = listOf("bakdata", name) + // description is only ready after evaluation + afterEvaluate { + configure { + plugins { + create("${project.name.capitalize()}Plugin") { + id = "com.bakdata.${project.name}" + implementationClass = "com.bakdata.gradle.${project.name.capitalize()}Plugin" + description = project.description + displayName = "Bakdata $name plugin" } } } + + extensions.findByType(com.gradle.publish.PluginBundleExtension::class)?.apply { + // actual block of plugin portal config, need to be done on each subproject as the plugin does not support multi-module projects yet... + website = "https://github.com/bakdata/gradle-plugins" + vcsUrl = "https://github.com/bakdata/gradle-plugins" + tags = listOf("bakdata", name) + } + } + + dependencies { + "testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:5.3.0") + "testImplementation"("org.junit.jupiter:junit-jupiter-api:5.3.0") + "testImplementation"("org.assertj", "assertj-core", "3.11.1") + "testImplementation"("org.junit-pioneer", "junit-pioneer", "0.3.0") } } diff --git a/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt b/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt index 0b83d9d..14c7a1a 100644 --- a/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt +++ b/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt @@ -222,18 +222,17 @@ class SonatypePlugin : Plugin { apply(plugin = "org.gradle.maven-publish") project.plugins.matching { it is JavaPlugin }.all { - project.tasks.matching { it.name == "dokka" }.all { - val javadocTask: Task = this - tasks.create("javadocJar") { - archiveClassifier.set(JAVADOC) - from(javadocTask) - } - } - configure { withSourcesJar() withJavadocJar() } + + project.tasks.matching { it.name == "dokkaJavadoc" }.all { + val javadocTask: Task = this + tasks.named("javadocJar") { + from(javadocTask) + } + } } configure {