Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp94831 committed Feb 28, 2024
1 parent 525ac68 commit 065826b
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 39 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
```
59 changes: 28 additions & 31 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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<GradlePluginDevelopmentExtension> {
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<com.gradle.publish.PluginBundleExtension> {
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<GradlePluginDevelopmentExtension> {
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")
}
}

Expand Down
15 changes: 7 additions & 8 deletions sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,17 @@ class SonatypePlugin : Plugin<Project> {
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<Jar>("javadocJar") {
archiveClassifier.set(JAVADOC)
from(javadocTask)
}
}

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 065826b

Please sign in to comment.