From cdf338fe23e35fe40facdb1a09c4fc5e0f9acd15 Mon Sep 17 00:00:00 2001 From: Steve Hill Date: Fri, 15 Nov 2019 16:19:02 -0800 Subject: [PATCH] Switch Gradle configuration to Kotlin --- build.gradle | 139 ---------------------------------------- build.gradle.kts | 152 ++++++++++++++++++++++++++++++++++++++++++++ settings.gradle | 1 - settings.gradle.kts | 1 + 4 files changed, 153 insertions(+), 140 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/build.gradle b/build.gradle deleted file mode 100644 index d4010011..00000000 --- a/build.gradle +++ /dev/null @@ -1,139 +0,0 @@ -plugins { - id 'groovy' - id 'maven-publish' - id 'signing' - id 'codenarc' - id 'com.gradle.plugin-publish' version '0.10.1' - id 'java-gradle-plugin' -} - -repositories { - // using JCenter for dependency resolution is recommended, see https://plugins.gradle.org/docs/publish-plugin - jcenter() -} - -sourceCompatibility = '1.8' -targetCompatibility = '1.8' - -def sezpoz = 'net.java.sezpoz:sezpoz:1.13' - -dependencies { - annotationProcessor sezpoz - implementation gradleApi() - implementation 'org.jvnet.localizer:maven-localizer-plugin:1.24' - implementation 'org.jenkins-ci:version-number:1.1' - implementation sezpoz - implementation localGroovy() - testAnnotationProcessor sezpoz - testImplementation('org.spockframework:spock-core:1.3-groovy-2.5') { - exclude module: 'groovy-all' // use the version that is distributed with Gradle - } - testImplementation 'org.xmlunit:xmlunit-core:2.6.3' - testImplementation 'org.apache.commons:commons-text:1.8' -} - -publishing { - publications { - pluginMaven(MavenPublication) { - pom { - name = 'Gradle JPI Plugin' - description = 'The Gradle JPI plugin is a Gradle plugin for building Jenkins plugins' - url = 'http://github.com/jenkinsci/gradle-jpi-plugin' - scm { - url = 'https://github.com/jenkinsci/gradle-jpi-plugin' - } - licenses { - license { - name = 'Apache 2.0' - url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' - distribution = 'repo' - } - } - developers { - developer { - id = 'abayer' - name = 'Andrew Bayer' - } - developer { - id = 'kohsuke' - name = 'Kohsuke Kawaguchi' - } - developer { - id = 'daspilker' - name = 'Daniel Spilker' - } - } - } - } - } - repositories { - maven { - def path = version.toString().endsWith('SNAPSHOT') ? 'snapshots' : 'releases' - name = 'JenkinsCommunity' - url = "https://repo.jenkins-ci.org/${path}" - credentials { - username = project.findProperty('jenkins.username') - password = project.findProperty('jenkins.password') - } - } - } -} - -signing { - useGpgCmd() - required { project.hasProperty('jenkins.username') && project.hasProperty('jenkins.password') } - sign publishing.publications.pluginMaven -} - -tasks.addRule("Pattern: testGradle") { String taskName -> - if (!taskName.startsWith('testGradle')) return - tasks.register(taskName, Test) { Test t -> - def gradleVersion = taskName - 'testGradle' - t.systemProperty 'gradle.under.test', gradleVersion - t.useJUnit { JUnitOptions o -> - o.includeCategories('org.jenkinsci.gradle.plugins.jpi.UsesGradleTestKit') - } - t.onlyIf { - gradleVersion.startsWith('4') && System.getProperty('java.specification.version') == '1.8' || - gradleVersion.startsWith('5') - } - } -} - -check.dependsOn(['4.10.3', '5.6.4'].collect { tasks.named("testGradle$it") }) - -tasks.withType(Test).configureEach { - testLogging { - exceptionFormat = 'full' - } -} - -codenarc { - toolVersion = '1.1' - configFile = file('config/codenarc/rules.groovy') -} - -codenarcTest { - configFile = file('config/codenarc/rules-test.groovy') -} - -group = 'org.jenkins-ci.tools' -archivesBaseName = 'gradle-jpi-plugin' -description = 'Gradle plugin for building and packaging Jenkins plugins' - -gradlePlugin { - plugins { - pluginMaven { - id = 'org.jenkins-ci.jpi' - implementationClass = 'org.jenkinsci.gradle.plugins.jpi.JpiPlugin' - displayName = 'A plugin for building Jenkins plugins' - } - } -} - -pluginBundle { - website = 'https://wiki.jenkins-ci.org/display/JENKINS/Gradle+JPI+Plugin' - vcsUrl = 'https://github.com/jenkinsci/gradle-jpi-plugin' - description = 'A plugin for building Jenkins plugins' - tags = ['jenkins'] -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..8d127aa0 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,152 @@ +import org.gradle.api.JavaVersion.VERSION_1_8 +import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL + +plugins { + groovy + `maven-publish` + signing + codenarc + id("com.gradle.plugin-publish") version "0.10.1" + `java-gradle-plugin` +} + +repositories { + // using JCenter for dependency resolution is recommended, see https://plugins.gradle.org/docs/publish-plugin + jcenter() +} + +configure { + sourceCompatibility = VERSION_1_8 + targetCompatibility = VERSION_1_8 +} + +val sezpoz = "net.java.sezpoz:sezpoz:1.13" + +dependencies { + annotationProcessor(sezpoz) + implementation(gradleApi()) + implementation("org.jvnet.localizer:maven-localizer-plugin:1.24") + implementation("org.jenkins-ci:version-number:1.1") + implementation(sezpoz) + implementation(localGroovy()) + testAnnotationProcessor(sezpoz) + testImplementation("org.spockframework:spock-core:1.3-groovy-2.5") { + exclude(module = "groovy-all") // use the version that is distributed with Gradle + } + testImplementation("org.xmlunit:xmlunit-core:2.6.3") + testImplementation("org.apache.commons:commons-text:1.8") +} + +publishing { + publications { + create("pluginMaven") { + pom { + name.set("Gradle JPI Plugin") + description.set("The Gradle JPI plugin is a Gradle plugin for building Jenkins plugins") + url.set("http://github.com/jenkinsci/gradle-jpi-plugin") + scm { + url.set("https://github.com/jenkinsci/gradle-jpi-plugin") + } + licenses { + license { + name.set("Apache 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + distribution.set("repo") + } + } + developers { + developer { + id.set("abayer") + name.set("Andrew Bayer") + } + developer { + id.set("kohsuke") + name.set("Kohsuke Kawaguchi") + } + developer { + id.set("daspilker") + name.set("Daniel Spilker") + } + } + } + } + } + repositories { + maven { + val path = if (version.toString().endsWith("SNAPSHOT")) "snapshots" else "releases" + name = "JenkinsCommunity" + url = uri("https://repo.jenkins-ci.org/${path}") + credentials { + username = project.stringProp("jenkins.username") + password = project.stringProp("jenkins.password") + } + } + } +} + +signing { + useGpgCmd() + setRequired { setOf("jenkins.username", "jenkins.password").all { project.hasProperty(it) } } + sign(publishing.publications["pluginMaven"]) +} + +tasks.addRule("Pattern: testGradle") { + val taskName = this + if (!taskName.startsWith("testGradle")) return@addRule + tasks.register(taskName) { + val t = this + val gradleVersion = taskName.substringAfter("testGradle") + t.systemProperty("gradle.under.test", gradleVersion) + t.useJUnit { + includeCategories("org.jenkinsci.gradle.plugins.jpi.UsesGradleTestKit") + } + t.onlyIf { + gradleVersion.startsWith('4') && System.getProperty("java.specification.version") == "1.8" || + gradleVersion.startsWith('5') + } + } +} + +val check = tasks.getByPath("check") +setOf("4.10.3", "5.6.4") + .map { tasks.named("testGradle$it") } + .forEach { check.dependsOn(it) } + +tasks.withType().configureEach { + testLogging { + exceptionFormat = FULL + } +} + +codenarc { + toolVersion = "1.1" + configFile = file("config/codenarc/rules.groovy") +} + +project.withGroovyBuilder { + "codenarcTest" { + setProperty("configFile", file("config/codenarc/rules-test.groovy")) + } +} + +group = "org.jenkins-ci.tools" +description = "Gradle plugin for building and packaging Jenkins plugins" + +gradlePlugin { + plugins { + create("pluginMaven") { + id = "org.jenkins-ci.jpi" + implementationClass = "org.jenkinsci.gradle.plugins.jpi.JpiPlugin" + displayName = "A plugin for building Jenkins plugins" + } + } +} + +pluginBundle { + website = "https://wiki.jenkins-ci.org/display/JENKINS/Gradle+JPI+Plugin" + vcsUrl = "https://github.com/jenkinsci/gradle-jpi-plugin" + description = "A plugin for building Jenkins plugins" + tags = listOf("jenkins") +} + +fun Project.stringProp(named: String): String? = findProperty(named) as String? diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 0e3ebd41..00000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'gradle-jpi-plugin' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..d3c81f04 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "gradle-jpi-plugin"