From 996cb6bbfabd822b59338decc5edba823098f786 Mon Sep 17 00:00:00 2001 From: Andrew Oberstar Date: Wed, 9 Feb 2022 19:45:22 -0600 Subject: [PATCH] Switch to gradle-defaults --- build.gradle.kts | 2 +- buildSrc/build.gradle.kts | 23 ----- .../kotlin/java-library-convention.gradle.kts | 93 ------------------- .../main/kotlin/locking-convention.gradle.kts | 28 ------ .../kotlin/spotless-convention.gradle.kts | 26 ------ grgit-core/build.gradle.kts | 2 +- grgit-gradle/build.gradle.kts | 25 ++--- .../org.ajoberstar.grgit-service.properties | 1 - .../org.ajoberstar.grgit.properties | 1 - settings.gradle.kts | 9 +- 10 files changed, 13 insertions(+), 197 deletions(-) delete mode 100644 buildSrc/build.gradle.kts delete mode 100644 buildSrc/src/main/kotlin/java-library-convention.gradle.kts delete mode 100644 buildSrc/src/main/kotlin/locking-convention.gradle.kts delete mode 100644 buildSrc/src/main/kotlin/spotless-convention.gradle.kts delete mode 100644 grgit-gradle/src/main/resources/META-INF/gradle-plugins/org.ajoberstar.grgit-service.properties delete mode 100644 grgit-gradle/src/main/resources/META-INF/gradle-plugins/org.ajoberstar.grgit.properties diff --git a/build.gradle.kts b/build.gradle.kts index 9c8e77f5..f54e692a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { reckon { scopeFromProp() - stageFromProp("alpha", "beta", "rc", "final") + stageFromProp("beta", "rc", "final") } jbake { diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts deleted file mode 100644 index f7d85af3..00000000 --- a/buildSrc/build.gradle.kts +++ /dev/null @@ -1,23 +0,0 @@ -plugins { - `kotlin-dsl` -} - -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(17)) - } -} - -tasks.withType { - kotlinOptions { - jvmTarget = "17" - } -} - -repositories { - mavenCentral() -} - -dependencies { - implementation("com.diffplug.spotless:spotless-plugin-gradle:6.0.0") -} diff --git a/buildSrc/src/main/kotlin/java-library-convention.gradle.kts b/buildSrc/src/main/kotlin/java-library-convention.gradle.kts deleted file mode 100644 index 5e083ebd..00000000 --- a/buildSrc/src/main/kotlin/java-library-convention.gradle.kts +++ /dev/null @@ -1,93 +0,0 @@ -plugins { - `java-library` - `maven-publish` - `signing` - id("locking-convention") - id("spotless-convention") -} - -group = "org.ajoberstar.grgit" -description = "The Groovy way to use Git." - -repositories { - mavenCentral() -} - -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) - } - withSourcesJar() - withJavadocJar() -} - -publishing { - repositories { - maven { - name = "CentralReleases" - url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") - credentials { - username = System.getenv("OSSRH_USERNAME") - password = System.getenv("OSSRH_PASSWORD") - } - } - - maven { - name = "CentralSnapshots" - url = uri("https://oss.sonatype.org/content/repositories/snapshots/") - credentials { - username = System.getenv("OSSRH_USERNAME") - password = System.getenv("OSSRH_PASSWORD") - } - } - } - - publications { - create("main") { - from(components["java"]) - - versionMapping { - usage("java-api") { - fromResolutionOf("runtimeClasspath") - } - usage("java-runtime") { - fromResolutionResult() - } - } - - pom { - name.set("GrGit") - description.set("The Groovy way to use Git.") - url.set("https://github.com/ajoberstar/grgit") - - developers { - developer { - name.set("Andrew Oberstar") - email.set("ajoberstar@gmail.com") - } - } - - licenses { - license { - name.set("The Apache Software License, Version 2.0") - url.set("http://www.apache.org/licenses/LICENSE-2.0") - } - } - - scm { - url.set("https://github.com/ajoberstar/grgit") - connection.set("scm:git:git@github.com:ajoberstar/grgit.git") - developerConnection.set("scm:git:ssh:git@github.com:ajoberstar/grgit.git") - } - } - } - } -} - -signing { - setRequired(System.getenv("CI")) - val signingKey: String? by project - val signingPassphrase: String? by project - useInMemoryPgpKeys(signingKey, signingPassphrase) - sign(publishing.publications["main"]) -} diff --git a/buildSrc/src/main/kotlin/locking-convention.gradle.kts b/buildSrc/src/main/kotlin/locking-convention.gradle.kts deleted file mode 100644 index 28cd999a..00000000 --- a/buildSrc/src/main/kotlin/locking-convention.gradle.kts +++ /dev/null @@ -1,28 +0,0 @@ -plugins { - `java-base` -} - -java { - sourceSets.configureEach { - val confNames = listOf(compileClasspathConfigurationName, runtimeClasspathConfigurationName) - confNames.forEach { confName -> - val conf = configurations.named(confName) - conf.resolutionStrategy.activateDependencyLocking() - } - } -} - -tasks.register("lock") { - doFirst { - require(gradle.startParameter.isWriteDependencyLocks) - } - doLast { - sourceSets.configureEach { - val confNames = listOf(compileClasspathConfigurationName, runtimeClasspathConfigurationName) - confNames.forEach { confName -> - val conf = configurations.named(confName) - conf.resolve() - } - } - } -} diff --git a/buildSrc/src/main/kotlin/spotless-convention.gradle.kts b/buildSrc/src/main/kotlin/spotless-convention.gradle.kts deleted file mode 100644 index 804cf270..00000000 --- a/buildSrc/src/main/kotlin/spotless-convention.gradle.kts +++ /dev/null @@ -1,26 +0,0 @@ -plugins { - id("com.diffplug.spotless") -} - -spotless { - plugins.withId("java") { - java { - importOrder("java", "javax", "") - eclipse().configFile(project.rootProject.file("gradle/eclipse-java-formatter.xml")) - } - } - plugins.withId("groovy") { - format("groovy") { - target("src/**/*.groovy") - trimTrailingWhitespace() - indentWithSpaces(2) - endWithNewline() - } - } - format("gradle") { - target("**/*.gradle") - trimTrailingWhitespace() - indentWithSpaces(2) - endWithNewline() - } -} diff --git a/grgit-core/build.gradle.kts b/grgit-core/build.gradle.kts index 1b157b15..41957e30 100644 --- a/grgit-core/build.gradle.kts +++ b/grgit-core/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("java-library-convention") + id("org.ajoberstar.defaults.java-library") groovy id("org.gradle.test-retry") } diff --git a/grgit-gradle/build.gradle.kts b/grgit-gradle/build.gradle.kts index 46dc2fc4..1c4de260 100644 --- a/grgit-gradle/build.gradle.kts +++ b/grgit-gradle/build.gradle.kts @@ -1,9 +1,7 @@ plugins { - id("java-library-convention") - id("java-gradle-plugin") + id("org.ajoberstar.defaults.gradle-plugin") groovy - id("com.gradle.plugin-publish") id("org.ajoberstar.stutter") } @@ -62,30 +60,19 @@ tasks.named("check") { dependsOn(tasks.named("compatTest")) } -pluginBundle { - website = "https://github.com/ajoberstar/grgit" - vcsUrl = "https://github.com/ajoberstar/grgit.git" - description = "The Groovy way to use Git" +gradlePlugin { plugins { create("grgitPlugin") { id = "org.ajoberstar.grgit" displayName = "The Groovy way to use Git" - tags = listOf("git", "groovy") + description = "The Groovy way to use Git" + implementationClass = "org.ajoberstar.grgit.gradle.GrgitPlugin" } create("grgitServicePlugin") { id = "org.ajoberstar.grgit-service" displayName = "The Groovy way to use Git (BuildService edition)" - tags = listOf("git", "groovy") + description = "The Groovy way to use Git (BuildService edition)" + implementationClass = "org.ajoberstar.grgit.gradle.GrgitServicePlugin" } } - mavenCoordinates { - groupId = project.group as String - artifactId = project.name as String - version = project.version.toString() - } -} - -// remove duplicate publication -gradlePlugin { - setAutomatedPublishing(false) } diff --git a/grgit-gradle/src/main/resources/META-INF/gradle-plugins/org.ajoberstar.grgit-service.properties b/grgit-gradle/src/main/resources/META-INF/gradle-plugins/org.ajoberstar.grgit-service.properties deleted file mode 100644 index 2497a0ee..00000000 --- a/grgit-gradle/src/main/resources/META-INF/gradle-plugins/org.ajoberstar.grgit-service.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-class=org.ajoberstar.grgit.gradle.GrgitServicePlugin diff --git a/grgit-gradle/src/main/resources/META-INF/gradle-plugins/org.ajoberstar.grgit.properties b/grgit-gradle/src/main/resources/META-INF/gradle-plugins/org.ajoberstar.grgit.properties deleted file mode 100644 index dc0d5063..00000000 --- a/grgit-gradle/src/main/resources/META-INF/gradle-plugins/org.ajoberstar.grgit.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-class=org.ajoberstar.grgit.gradle.GrgitPlugin diff --git a/settings.gradle.kts b/settings.gradle.kts index a0649acf..7afea1ec 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,13 +1,14 @@ pluginManagement { plugins { - id("org.gradle.test-retry") version "1.3.1" - id("com.gradle.plugin-publish") version "0.20.0" + id("org.ajoberstar.defaults.java-library") version "0.17.1" + id("org.ajoberstar.defaults.gradle-plugin") version "0.17.1" id("org.ajoberstar.grgit") version "4.1.1" - id("org.ajoberstar.reckon") version "0.13.1" - id("org.ajoberstar.git-publish") version "3.0.0" + id("org.ajoberstar.reckon") version "0.13.2" + id("org.ajoberstar.git-publish") version "3.0.1" id("org.ajoberstar.stutter") version "0.7.0" + id("org.gradle.test-retry") version "1.3.1" id("com.diffplug.spotless") version "6.2.1" id("org.jbake.site") version "5.5.0" }