Skip to content

Commit 065826b

Browse files
committed
Update
1 parent 525ac68 commit 065826b

File tree

3 files changed

+55
-39
lines changed

3 files changed

+55
-39
lines changed

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,24 @@ A collection of small gradle plugin, mostly focused on deployment.
1010
**Sonar** Some defaults for easy integration of sonar on multi-module projects
1111
**Sonatype** is used for uploading to sonatype repos and ultimately publish to Maven Central
1212

13+
## Development
1314

15+
Snapshot versions of these plugins are published to Sonatype.
16+
You can use them in your project by adding the following snippet to your `build.gradle.kts`
17+
18+
```
19+
buildscript {
20+
repositories {
21+
maven {
22+
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots")
23+
}
24+
}
25+
dependencies {
26+
classpath("com.bakdata.gradle:sonar:0.0.1-SNAPSHOT")
27+
classpath("com.bakdata.gradle:sonatype:0.0.1-SNAPSHOT")
28+
}
29+
}
30+
31+
apply(plugin = "com.bakdata.sonar")
32+
apply(plugin = "com.bakdata.sonatype")
33+
```

build.gradle.kts

+28-31
Original file line numberDiff line numberDiff line change
@@ -52,42 +52,39 @@ subprojects {
5252
targetCompatibility = JavaVersion.VERSION_11
5353
}
5454

55-
dependencies {
56-
"testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:5.3.0")
57-
"testImplementation"("org.junit.jupiter:junit-jupiter-api:5.3.0")
58-
"testImplementation"("org.assertj", "assertj-core", "3.11.1")
59-
"testImplementation"("org.junit-pioneer", "junit-pioneer", "0.3.0")
55+
apply(plugin = "java-gradle-plugin")
56+
57+
// config for gradle plugin portal doesn't support snapshot, so we add config only if release version
58+
if (!version.toString().endsWith("-SNAPSHOT")) {
59+
apply(plugin = "com.gradle.plugin-publish")
6060
}
61-
}
6261

63-
// config for gradle plugin portal
64-
// doesn't support snapshot, so we add config only if release version
65-
if (!version.toString().endsWith("-SNAPSHOT")) {
66-
subprojects.forEach { project ->
67-
with(project) {
68-
// com.gradle.plugin-publish depends on java-gradle-plugin, but it screws a bit this project
69-
apply(plugin = "java-gradle-plugin")
70-
apply(plugin = "com.gradle.plugin-publish")
71-
project.afterEvaluate {
72-
// java-gradle-plugin requires this block, but we already added the definitions in META-INF for unit testing...
73-
configure<GradlePluginDevelopmentExtension> {
74-
plugins {
75-
create("${project.name.capitalize()}Plugin") {
76-
id = "com.bakdata.${project.name}"
77-
implementationClass = "com.bakdata.gradle.${project.name.capitalize()}Plugin"
78-
description = project.description
79-
displayName = "Bakdata $name plugin"
80-
}
81-
}
82-
}
83-
// actual block of plugin portal config, need to be done on each subproject as the plugin does not support multi-module projects yet...
84-
configure<com.gradle.publish.PluginBundleExtension> {
85-
website = "https://github.com/bakdata/gradle-plugins"
86-
vcsUrl = "https://github.com/bakdata/gradle-plugins"
87-
tags = listOf("bakdata", name)
62+
// description is only ready after evaluation
63+
afterEvaluate {
64+
configure<GradlePluginDevelopmentExtension> {
65+
plugins {
66+
create("${project.name.capitalize()}Plugin") {
67+
id = "com.bakdata.${project.name}"
68+
implementationClass = "com.bakdata.gradle.${project.name.capitalize()}Plugin"
69+
description = project.description
70+
displayName = "Bakdata $name plugin"
8871
}
8972
}
9073
}
74+
75+
extensions.findByType(com.gradle.publish.PluginBundleExtension::class)?.apply {
76+
// actual block of plugin portal config, need to be done on each subproject as the plugin does not support multi-module projects yet...
77+
website = "https://github.com/bakdata/gradle-plugins"
78+
vcsUrl = "https://github.com/bakdata/gradle-plugins"
79+
tags = listOf("bakdata", name)
80+
}
81+
}
82+
83+
dependencies {
84+
"testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:5.3.0")
85+
"testImplementation"("org.junit.jupiter:junit-jupiter-api:5.3.0")
86+
"testImplementation"("org.assertj", "assertj-core", "3.11.1")
87+
"testImplementation"("org.junit-pioneer", "junit-pioneer", "0.3.0")
9188
}
9289
}
9390

sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt

+7-8
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,17 @@ class SonatypePlugin : Plugin<Project> {
222222
apply(plugin = "org.gradle.maven-publish")
223223

224224
project.plugins.matching { it is JavaPlugin }.all {
225-
project.tasks.matching { it.name == "dokka" }.all {
226-
val javadocTask: Task = this
227-
tasks.create<Jar>("javadocJar") {
228-
archiveClassifier.set(JAVADOC)
229-
from(javadocTask)
230-
}
231-
}
232-
233225
configure<JavaPluginExtension> {
234226
withSourcesJar()
235227
withJavadocJar()
236228
}
229+
230+
project.tasks.matching { it.name == "dokkaJavadoc" }.all {
231+
val javadocTask: Task = this
232+
tasks.named<Jar>("javadocJar") {
233+
from(javadocTask)
234+
}
235+
}
237236
}
238237

239238
configure<PublishingExtension> {

0 commit comments

Comments
 (0)