Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt the recipe-library Gradle plugin #5

Merged
merged 3 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .github/workflows/gradle-wrapper-validation.yml

This file was deleted.

101 changes: 6 additions & 95 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
import nebula.plugin.contacts.Contact
import nebula.plugin.contacts.ContactsExtension
import nebula.plugin.release.NetflixOssStrategies
import nebula.plugin.release.git.base.ReleasePluginExtension
import java.net.URI

plugins {
id("org.openrewrite.build.recipe-library") version "latest.release"
}

configure<ReleasePluginExtension> {
defaultVersionStrategy = NetflixOssStrategies.SNAPSHOT(project)
}

group = "net.sghill.jenkins"
description = "Jenkins Rewrite recipes."

repositories {
mavenCentral()
}
group = "org.openrewrite.recipe"
description = "A rewrite module automating migrations for Jenkins"

val rewriteVersion = rewriteRecipe.rewriteVersion.get()
dependencies {
compileOnly("org.projectlombok:lombok:latest.release")
compileOnly("com.google.code.findbugs:jsr305:latest.release")
annotationProcessor("org.projectlombok:lombok:latest.release")
implementation(platform(libs.rewrite.recipe.bom))
implementation(platform(libs.rewrite.bom))

implementation(platform("org.openrewrite:rewrite-bom:$rewriteVersion"))

implementation("org.rocksdb:rocksdbjni:7.2.2")
implementation("org.openrewrite:rewrite-java")
Expand All @@ -36,13 +23,10 @@ dependencies {
implementation("com.google.inject:guice:6.+")
implementation("org.eclipse.sisu:org.eclipse.sisu.inject:latest.release")
implementation("org.apache.maven.wagon:wagon-http-lightweight:latest.release")
// implementation("org.eclipse.aether:aether-api:latest.release")
// implementation("org.eclipse.aether:aether-impl:latest.release")
// implementation("org.apache.maven:waggon-http-lightweight:latest.release")

testImplementation("org.ow2.asm:asm:latest.release")

testImplementation(platform(libs.junit.bom))
testImplementation(platform("org.junit:junit-bom:latest.release"))
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-params")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
Expand All @@ -55,76 +39,3 @@ dependencies {
testRuntimeOnly("com.google.code.findbugs:jsr305:3.0.2")
testRuntimeOnly("org.slf4j:slf4j-simple:1.7.36")
}

tasks.test {
useJUnitPlatform()
jvmArgs = listOf("-XX:+UnlockDiagnosticVMOptions", "-XX:+ShowHiddenFrames")
}

configure<ContactsExtension> {
val j = Contact("[email protected]")
j.moniker("Steve Hill")
j.github("sghill")
people["[email protected]"] = j
}

tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
options.compilerArgs.addAll(listOf("-parameters"))
}

configure<PublishingExtension> {
publications {
named("nebula", MavenPublication::class.java) {
suppressPomMetadataWarningsFor("runtimeElements")
}
}
}

val targetRepo: Provider<URI> = providers.provider {
if (version.toString().endsWith("SNAPSHOT")) {
uri("https://oss.sonatype.org/content/repositories/snapshots/")
} else {
uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
}
}

publishing {
repositories {
repositories {
maven {
url = targetRepo.get()
credentials {
username = providers.gradleProperty("ossrhUsername").getOrElse("Unknown user")
password = providers.gradleProperty("ossrhPassword").getOrElse("Unknown password")
}
}
}
}
publications {
named<MavenPublication>("nebula") {
pom {
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
scm {
connection.set("scm:git:https://github.com/sghill/rewrite-jenkins.git")
developerConnection.set("scm:git:[email protected]:sghill/rewrite-jenkins.git")
url.set("https://github.com/sghill/rewrite-jenkins")
}
}
}
}
}

signing {
sign(publishing.publications["nebula"])
useGpgCmd()
}

tasks.withType<Sign>() {
onlyIf { gradle.taskGraph.hasTask(":publish") }
}
46 changes: 39 additions & 7 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,45 @@
rootProject.name = "rewrite-jenkins"

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
library("junit-bom", "org.junit", "junit-bom").version {
strictly("[5.9.1, 6.0.0[")
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
}
}

plugins {
id("com.gradle.enterprise") version "latest.release"
id("com.gradle.common-custom-user-data-gradle-plugin") version "latest.release"
}

gradleEnterprise {
val isCiServer = System.getenv("CI")?.equals("true") ?: false
server = "https://ge.openrewrite.org/"
val gradleCacheRemoteUsername: String? = System.getenv("GRADLE_ENTERPRISE_CACHE_USERNAME")
val gradleCacheRemotePassword: String? = System.getenv("GRADLE_ENTERPRISE_CACHE_PASSWORD")

buildCache {
remote(HttpBuildCache::class) {
url = uri("https://ge.openrewrite.org/cache/")
isPush = isCiServer
if (!gradleCacheRemoteUsername.isNullOrBlank() && !gradleCacheRemotePassword.isNullOrBlank()) {
credentials {
username = gradleCacheRemoteUsername
password = gradleCacheRemotePassword
}
}
library("rewrite-bom", "org.openrewrite:rewrite-bom:8.1.2")
library("rewrite-recipe-bom", "org.openrewrite.recipe:rewrite-recipe-bom:2.0.1")
}
}

buildScan {
capture {
isTaskInputFiles = true
}

isUploadInBackground = !isCiServer

publishAlways()
this as com.gradle.enterprise.gradleplugin.internal.extension.BuildScanExtensionWithHiddenFeatures
publishIfAuthenticated()
}
}