Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/listener
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp94831 committed Mar 5, 2024
2 parents d37ccc1 + 0ebcca8 commit 6e986cc
Show file tree
Hide file tree
Showing 11 changed files with 339 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .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.41.0
uses: bakdata/ci-templates/.github/workflows/java-gradle-plugin.yaml@1.42.0
secrets:
sonar-token: ${{ secrets.SONARCLOUD_TOKEN }}
sonar-organization: ${{ secrets.SONARCLOUD_ORGANIZATION }}
Expand Down
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.41.0
uses: bakdata/ci-templates/.github/workflows/java-gradle-release.yaml@1.42.0
with:
release-type: "${{ inputs.release-type }}"

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

- no changes!

- no changes!


## [1.1.11](https://github.com/bakdata/gradle-plugins/tree/1.1.11) (2024-01-29)
[Full Changelog](https://github.com/bakdata/gradle-plugins/compare/1.1.10...1.1.11)
Expand Down
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,32 @@
bakdata gradle plugins
======================

A collection of small gradle plugin, mostly focused on deployment.
A collection of small Gradle plugins, 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
- **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
- **Release** adds configurable push behavior for version bumping

## 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")
classpath("com.bakdata.gradle:release:0.0.1-SNAPSHOT")
}
}
apply(plugin = "com.bakdata.sonar")
apply(plugin = "com.bakdata.sonatype")
apply(plugin = "com.bakdata.release")
```
61 changes: 29 additions & 32 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id("net.researchgate.release") version "3.0.2"
// 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.1"
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 @@ -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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=1.2.3-SNAPSHOT
version=1.3.1-SNAPSHOT
org.gradle.caching=true
org.gradle.parallel=true
12 changes: 12 additions & 0 deletions release/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
plugins {
kotlin("jvm")
id("org.jetbrains.dokka") version "1.9.10"
}
apply(plugin = "org.gradle.kotlin.kotlin-dsl")

description = "Configures Gradle Release plugin for usage in CI"

dependencies {
implementation("net.researchgate", "gradle-release", "3.0.2")
implementation("gradle.plugin.org.hildan.gradle", "gradle-github-changelog", "1.12.1")
}
81 changes: 81 additions & 0 deletions release/src/main/kotlin/com/bakdata/gradle/ReleasePlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* The MIT License
*
* Copyright (c) 2024 bakdata GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.bakdata.gradle

import net.researchgate.release.ReleaseExtension
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.hildan.github.changelog.plugin.GitHubChangelogExtension

class ReleasePlugin : Plugin<Project> {

companion object {
const val DISABLE_PUSH_TO_REMOTE = "release.disablePushToRemote"
const val REQUIRE_BRANCH = "release.requireBranch"
const val GITHUB_REPOSITORY = "changelog.githubRepository"
const val FUTURE_VERSION_TAG = "changelog.futureVersionTag"
const val SINCE_TAG = "changelog.sinceTag"
}

override fun apply(rootProject: Project) {
if (rootProject.parent != null) {
throw GradleException("Apply this plugin only to the top-level project.")
}

with(rootProject) {
apply(plugin = "net.researchgate.release")

val disablePushToRemote: String? = project.findProperty(DISABLE_PUSH_TO_REMOTE)?.toString()
val branch: String? = project.findProperty(REQUIRE_BRANCH)?.toString()
configure<ReleaseExtension> {
git {
if (disablePushToRemote?.toBoolean() == true) {
pushToRemote.set(false)
}
branch?.also {
requireBranch.set(it)
}
}
}

apply(plugin = "org.hildan.github.changelog")

configure<GitHubChangelogExtension> {
project.findProperty(GITHUB_REPOSITORY)?.toString()?.also {
githubRepository = it
}
project.findProperty(FUTURE_VERSION_TAG)?.toString()?.also {
futureVersionTag = it
}
project.findProperty(SINCE_TAG)?.toString()?.also {
sinceTag = it
}
}
}
}
}
Loading

0 comments on commit 6e986cc

Please sign in to comment.