diff --git a/build.gradle b/build.gradle index 2efe65c..6e8ad27 100644 --- a/build.gradle +++ b/build.gradle @@ -91,6 +91,13 @@ gradlePlugin { implementationClass= 'nebula.plugin.info.reporting.InfoJarManifestPlugin' tags.set(['nebula', 'info']) } + infoJARProperties { + id = 'com.netflix.nebula.info-jar-properties' + displayName = 'Gradle Info JAR properties plugin' + description = project.description + implementationClass= 'nebula.plugin.info.reporting.InfoJarPropertiesFilePlugin' + tags.set(['nebula', 'info']) + } infoJava { id = 'com.netflix.nebula.info-java' displayName = 'Gradle Info Java plugin' diff --git a/src/test/groovy/nebula/plugin/info/BaseIntegrationSpec.groovy b/src/test/groovy/nebula/plugin/info/BaseIntegrationSpec.groovy deleted file mode 100644 index d3c51bf..0000000 --- a/src/test/groovy/nebula/plugin/info/BaseIntegrationSpec.groovy +++ /dev/null @@ -1,10 +0,0 @@ -package nebula.plugin.info - -import nebula.test.IntegrationSpec - -abstract class BaseIntegrationSpec extends IntegrationSpec { - def setup() { - // Enable configuration cache :) - new File(projectDir, 'gradle.properties') << '''org.gradle.configuration-cache=true'''.stripIndent() - } -} diff --git a/src/test/groovy/nebula/plugin/info/InfoBrokerPluginIntegrationSpec.groovy b/src/test/groovy/nebula/plugin/info/InfoBrokerPluginIntegrationSpec.groovy index abf5adf..8eec03c 100644 --- a/src/test/groovy/nebula/plugin/info/InfoBrokerPluginIntegrationSpec.groovy +++ b/src/test/groovy/nebula/plugin/info/InfoBrokerPluginIntegrationSpec.groovy @@ -18,13 +18,15 @@ package nebula.plugin.info import nebula.test.functional.ExecutionResult -class InfoBrokerPluginIntegrationSpec extends BaseIntegrationSpec { +class InfoBrokerPluginIntegrationSpec extends BaseIntegrationTestKitSpec { def 'it returns build reports at the end of the build'() { given: def report = 'This string may only be retrieved after the build has finished' buildFile << """ - ${applyPlugin(InfoBrokerPlugin)} + plugins { + id 'com.netflix.nebula.info-broker' + } def broker = project.plugins.getPlugin(${InfoBrokerPlugin.name}) @@ -42,10 +44,10 @@ class InfoBrokerPluginIntegrationSpec extends BaseIntegrationSpec { new File(projectDir, 'gradle.properties').text = '''org.gradle.configuration-cache=false'''.stripIndent() when: - ExecutionResult result = runTasksSuccessfully('createReport') + def result = runTasks('createReport') then: - result.standardOutput.contains(report) + result.output.contains(report) } diff --git a/src/test/groovy/nebula/plugin/info/InfoPluginIntegrationSpec.groovy b/src/test/groovy/nebula/plugin/info/InfoPluginIntegrationSpec.groovy index 88e008e..8af2331 100644 --- a/src/test/groovy/nebula/plugin/info/InfoPluginIntegrationSpec.groovy +++ b/src/test/groovy/nebula/plugin/info/InfoPluginIntegrationSpec.groovy @@ -15,9 +15,8 @@ */ package nebula.plugin.info -import nebula.test.functional.ExecutionResult -class InfoPluginIntegrationSpec extends BaseIntegrationSpec { +class InfoPluginIntegrationSpec extends BaseIntegrationTestKitSpec { def 'it returns build reports at the end of the build'() { given: buildFile << """ @@ -30,8 +29,10 @@ class InfoPluginIntegrationSpec extends BaseIntegrationSpec { } } - ${applyPlugin(InfoPlugin)} - apply plugin: 'java' + plugins { + id 'com.netflix.nebula.info' + id 'java' + } repositories { mavenCentral() } dependencies { @@ -51,17 +52,20 @@ class InfoPluginIntegrationSpec extends BaseIntegrationSpec { new File(projectDir, 'gradle.properties').text = '''org.gradle.configuration-cache=false'''.stripIndent() when: - ExecutionResult result = runTasksSuccessfully('assemble') + def result = runTasks('assemble') then: - result.standardOutput.contains('{buildscript-singlemodule-test-dependencies={Resolved-Dependencies-CompileClasspath=com.google.guava:guava:18.0}}') + result.output.contains('{buildscript-singlemodule-test-dependencies={Resolved-Dependencies-CompileClasspath=com.google.guava:guava:18.0}}') } def 'it returns build reports at the end of multiproject build'() { given: buildFile << """ + plugins { + id 'com.netflix.nebula.info' + } allprojects { - ${applyPlugin(InfoPlugin)} + apply plugin: 'com.netflix.nebula.info' } subprojects { @@ -91,32 +95,23 @@ class InfoPluginIntegrationSpec extends BaseIntegrationSpec { new File(projectDir, 'gradle.properties').text = '''org.gradle.configuration-cache=false'''.stripIndent() when: - ExecutionResult result = runTasksSuccessfully('build') + def result = runTasks('build') then: - result.standardOutput.contains('common-dependencies={Resolved-Dependencies-CompileClasspath=com.google.guava:guava:18.0}') - result.standardOutput.contains('app-dependencies={Resolved-Dependencies-CompileClasspath=com.google.guava:guava:19.0}') + result.output.contains('common-dependencies={Resolved-Dependencies-CompileClasspath=com.google.guava:guava:18.0}') + result.output.contains('app-dependencies={Resolved-Dependencies-CompileClasspath=com.google.guava:guava:19.0}') } def 'works with jenkins jpi plugin'() { given: System.setProperty("ignoreDeprecations", 'true') buildFile << """ - buildscript { - repositories { - maven { - url "https://plugins.gradle.org/m2/" - } - } - dependencies { - classpath "org.jenkins-ci.tools:gradle-jpi-plugin:0.49.0" - } + plugins { + id 'com.netflix.nebula.info' + id 'java' + id "org.jenkins-ci.jpi" version "0.50.0-rc.3" } - - ${applyPlugin(InfoPlugin)} - apply plugin: 'java' - apply plugin: "org.jenkins-ci.jpi" - + jenkinsPlugin { jenkinsVersion.set('2.249.3') } @@ -134,10 +129,7 @@ class InfoPluginIntegrationSpec extends BaseIntegrationSpec { // JPI plugin might not be configuration cache compatible yet new File(projectDir, 'gradle.properties').text = '''org.gradle.configuration-cache=false'''.stripIndent() - when: - ExecutionResult result = runTasksSuccessfully('assemble') - - then: - result.success + expect: + runTasks('assemble') } } diff --git a/src/test/groovy/nebula/plugin/info/InfoPluginIntegrationTestKitSpec.groovy b/src/test/groovy/nebula/plugin/info/InfoPluginIntegrationTestKitSpec.groovy index f2e5721..a3b7b6e 100644 --- a/src/test/groovy/nebula/plugin/info/InfoPluginIntegrationTestKitSpec.groovy +++ b/src/test/groovy/nebula/plugin/info/InfoPluginIntegrationTestKitSpec.groovy @@ -61,7 +61,6 @@ class InfoPluginIntegrationTestKitSpec extends BaseIntegrationTestKitSpec { def 'reports proper jdk version when configuring toolchain in compile task'() { given: - debug = true buildFile << """ buildscript { repositories { @@ -112,7 +111,6 @@ class InfoPluginIntegrationTestKitSpec extends BaseIntegrationTestKitSpec { def 'reports proper jdk version when configuring target/source compatibility in compile task + toolchains'() { given: - debug = true buildFile << """ buildscript { repositories { @@ -165,7 +163,6 @@ class InfoPluginIntegrationTestKitSpec extends BaseIntegrationTestKitSpec { def 'reports proper jdk version when configuring target/source compatibility in compile task + toolchains (multi language)'() { given: - debug = true buildFile << """ buildscript { repositories { @@ -221,7 +218,6 @@ class InfoPluginIntegrationTestKitSpec extends BaseIntegrationTestKitSpec { def 'reports proper jdk version when configuring target/source compatibility in compile task + toolchains (scala support)'() { given: - debug = true buildFile << """ buildscript { repositories { diff --git a/src/test/groovy/nebula/plugin/info/ci/ContinuousIntegrationInfoPluginSpec.groovy b/src/test/groovy/nebula/plugin/info/ci/ContinuousIntegrationInfoPluginSpec.groovy index 754d1ea..3f4c33d 100644 --- a/src/test/groovy/nebula/plugin/info/ci/ContinuousIntegrationInfoPluginSpec.groovy +++ b/src/test/groovy/nebula/plugin/info/ci/ContinuousIntegrationInfoPluginSpec.groovy @@ -1,9 +1,6 @@ package nebula.plugin.info.ci -import nebula.plugin.info.BaseIntegrationSpec -import nebula.plugin.info.InfoBrokerPlugin -import nebula.plugin.info.reporting.InfoJarManifestPlugin -import nebula.test.IntegrationSpec +import nebula.plugin.info.BaseIntegrationTestKitSpec import org.junit.Rule import org.junit.contrib.java.lang.system.EnvironmentVariables import spock.lang.IgnoreIf @@ -14,7 +11,7 @@ import java.util.jar.JarFile import java.util.jar.Manifest @IgnoreIf({ System.getenv('TITUS_TASK_ID') || jvm.isJava21() || jvm.isJava17() }) -class ContinuousIntegrationInfoPluginSpec extends BaseIntegrationSpec { +class ContinuousIntegrationInfoPluginSpec extends BaseIntegrationTestKitSpec { @Rule public final EnvironmentVariables environmentVariables = new EnvironmentVariables() @@ -28,9 +25,11 @@ class ContinuousIntegrationInfoPluginSpec extends BaseIntegrationSpec { writeHelloWorld('nebula.test') buildFile << """ - ${applyPlugin(InfoBrokerPlugin)} - ${applyPlugin(ContinuousIntegrationInfoPlugin)} - ${applyPlugin(InfoJarManifestPlugin)} + plugins { + id 'com.netflix.nebula.info-broker' + id 'com.netflix.nebula.info-ci' + id 'com.netflix.nebula.info-jar' + } apply plugin: 'java' @@ -38,7 +37,7 @@ class ContinuousIntegrationInfoPluginSpec extends BaseIntegrationSpec { """.stripIndent() when: - runTasksSuccessfully('jar') + runTasks('jar') then: File jarFile = new File(projectDir, "build/libs/${moduleName}-1.0.jar") diff --git a/src/test/groovy/nebula/plugin/info/reporting/InfoJarManifestPluginLauncherSpec.groovy b/src/test/groovy/nebula/plugin/info/reporting/InfoJarManifestPluginLauncherSpec.groovy index 411f660..06a6853 100644 --- a/src/test/groovy/nebula/plugin/info/reporting/InfoJarManifestPluginLauncherSpec.groovy +++ b/src/test/groovy/nebula/plugin/info/reporting/InfoJarManifestPluginLauncherSpec.groovy @@ -16,25 +16,24 @@ package nebula.plugin.info.reporting -import nebula.plugin.info.BaseIntegrationSpec -import nebula.plugin.info.InfoBrokerPlugin -import nebula.plugin.info.basic.BasicInfoPlugin -import nebula.test.IntegrationSpec -import nebula.test.functional.ExecutionResult +import nebula.plugin.info.BaseIntegrationTestKitSpec +import org.gradle.testkit.runner.TaskOutcome import java.time.OffsetDateTime import java.util.jar.Attributes import java.util.jar.JarFile import java.util.jar.Manifest -class InfoJarManifestPluginLauncherSpec extends BaseIntegrationSpec { +class InfoJarManifestPluginLauncherSpec extends BaseIntegrationTestKitSpec { def 'jar task is marked UP-TO-DATE if ran before successfully and manifest changes are ignored'() { writeHelloWorld('nebula.test') buildFile << """ - ${applyPlugin(InfoBrokerPlugin)} - ${applyPlugin(BasicInfoPlugin)} - ${applyPlugin(InfoJarManifestPlugin)} + plugins { + id 'com.netflix.nebula.info-broker' + id 'com.netflix.nebula.info-basic' + id 'com.netflix.nebula.info-jar' + } apply plugin: 'java' status = 'release' @@ -42,42 +41,44 @@ class InfoJarManifestPluginLauncherSpec extends BaseIntegrationSpec { when: // Make sure we have some history already in place - runTasksSuccessfully('jar') - runTasksSuccessfully('clean') + runTasks('jar') + runTasks('clean') - def result = runTasksSuccessfully('jar') + def result = runTasks('jar') File jarFile = new File(projectDir, "build/libs/${moduleName}.jar") then: jarFile.exists() - !result.wasUpToDate(':jar') + result.task(':jar').outcome != TaskOutcome.UP_TO_DATE Manifest manifest = new JarFile(jarFile).manifest Attributes attributes = manifest.mainAttributes manifestKey(attributes, 'Built-Status') == 'release' when: 'Nothing has changed' - def secondResult = runTasksSuccessfully('jar') + def secondResult = runTasks('jar') then: - secondResult.wasUpToDate(':jar') + secondResult.task(':jar').outcome == TaskOutcome.UP_TO_DATE when: 'A manifest field was changed' buildFile << """ status = 'integration' """.stripIndent() - def thirdResult = runTasksSuccessfully('jar') + def thirdResult = runTasks('jar') then: - thirdResult.wasUpToDate(':jar') + secondResult.task(':jar').outcome == TaskOutcome.UP_TO_DATE } def "Creates JAR file with populated manifest attributes by basic info plugin"() { given: writeHelloWorld('nebula.test') buildFile << """ - ${applyPlugin(InfoBrokerPlugin)} - ${applyPlugin(BasicInfoPlugin)} - ${applyPlugin(InfoJarManifestPlugin)} + plugins { + id 'com.netflix.nebula.info-broker' + id 'com.netflix.nebula.info-basic' + id 'com.netflix.nebula.info-jar' + } apply plugin: 'java' @@ -85,7 +86,7 @@ class InfoJarManifestPluginLauncherSpec extends BaseIntegrationSpec { """.stripIndent() when: - runTasksSuccessfully('jar') + runTasks('jar') then: File jarFile = new File(projectDir, "build/libs/${moduleName}-1.0.jar") @@ -111,9 +112,11 @@ class InfoJarManifestPluginLauncherSpec extends BaseIntegrationSpec { given: writeHelloWorld('nebula.test') buildFile << """ - ${applyPlugin(InfoBrokerPlugin)} - ${applyPlugin(BasicInfoPlugin)} - ${applyPlugin(InfoJarManifestPlugin)} + plugins { + id 'com.netflix.nebula.info-broker' + id 'com.netflix.nebula.info-basic' + id 'com.netflix.nebula.info-jar' + } apply plugin: 'java' @@ -125,7 +128,7 @@ class InfoJarManifestPluginLauncherSpec extends BaseIntegrationSpec { """.stripIndent() when: - runTasksSuccessfully('jar') + runTasks('jar') then: File jarFile = new File(projectDir, "build/libs/${moduleName}-1.0.jar") @@ -146,9 +149,11 @@ class InfoJarManifestPluginLauncherSpec extends BaseIntegrationSpec { given: writeHelloWorld('nebula.test') buildFile << """ - ${applyPlugin(InfoBrokerPlugin)} - ${applyPlugin(BasicInfoPlugin)} - ${applyPlugin(InfoJarManifestPlugin)} + plugins { + id 'com.netflix.nebula.info-broker' + id 'com.netflix.nebula.info-basic' + id 'com.netflix.nebula.info-jar' + } apply plugin: 'java' @@ -160,7 +165,7 @@ class InfoJarManifestPluginLauncherSpec extends BaseIntegrationSpec { """.stripIndent() when: - runTasksSuccessfully('jar') + runTasks('jar') then: File jarFile = new File(projectDir, "build/libs/${moduleName}-1.0.jar") @@ -179,9 +184,11 @@ class InfoJarManifestPluginLauncherSpec extends BaseIntegrationSpec { given: writeHelloWorld('nebula.test') buildFile << """ - ${applyPlugin(InfoBrokerPlugin)} - ${applyPlugin(BasicInfoPlugin)} - ${applyPlugin(InfoJarManifestPlugin)} + plugins { + id 'com.netflix.nebula.info-broker' + id 'com.netflix.nebula.info-basic' + id 'com.netflix.nebula.info-jar' + } apply plugin: 'java' @@ -194,10 +201,10 @@ class InfoJarManifestPluginLauncherSpec extends BaseIntegrationSpec { """.stripIndent() when: - ExecutionResult executionResult = runTasksWithFailure('jar') + def executionResult = runTasksAndFail('jar') then: - executionResult.standardError.contains('includedManifestProperties and excludedManifestProperties are mutually exclusive. Only one should be provided') + executionResult.output.contains('includedManifestProperties and excludedManifestProperties are mutually exclusive. Only one should be provided') } @@ -205,9 +212,11 @@ class InfoJarManifestPluginLauncherSpec extends BaseIntegrationSpec { given: writeHelloWorld('nebula.test') buildFile << """ - ${applyPlugin(InfoBrokerPlugin)} - ${applyPlugin(BasicInfoPlugin)} - ${applyPlugin(InfoJarManifestPlugin)} + plugins { + id 'com.netflix.nebula.info-broker' + id 'com.netflix.nebula.info-basic' + id 'com.netflix.nebula.info-jar' + } apply plugin: 'java' @@ -216,7 +225,7 @@ class InfoJarManifestPluginLauncherSpec extends BaseIntegrationSpec { """.stripIndent() when: - runTasksSuccessfully('jar') + runTasks('jar') then: File jarFile = new File(projectDir, "build/libs/${moduleName}-1.0.jar") @@ -230,10 +239,12 @@ class InfoJarManifestPluginLauncherSpec extends BaseIntegrationSpec { given: writeHelloWorld('nebula.test') buildFile << """ - ${applyPlugin(InfoBrokerPlugin)} - ${applyPlugin(BasicInfoPlugin)} - ${applyPlugin(InfoJarPropertiesFilePlugin)} - ${applyPlugin(InfoJarManifestPlugin)} + plugins { + id 'com.netflix.nebula.info-broker' + id 'com.netflix.nebula.info-basic' + id 'com.netflix.nebula.info-jar' + } + apply plugin: 'java' @@ -244,7 +255,7 @@ class InfoJarManifestPluginLauncherSpec extends BaseIntegrationSpec { """.stripIndent() when: - runTasksSuccessfully('jar') + runTasks('jar') then: File jarFile = new File(projectDir, "build/libs/${moduleName}-1.0.jar") diff --git a/src/test/groovy/nebula/plugin/info/reporting/InfoPropertiesFilePluginLauncherSpec.groovy b/src/test/groovy/nebula/plugin/info/reporting/InfoPropertiesFilePluginLauncherSpec.groovy index f5df108..984ead2 100644 --- a/src/test/groovy/nebula/plugin/info/reporting/InfoPropertiesFilePluginLauncherSpec.groovy +++ b/src/test/groovy/nebula/plugin/info/reporting/InfoPropertiesFilePluginLauncherSpec.groovy @@ -1,20 +1,20 @@ package nebula.plugin.info.reporting -import nebula.plugin.info.BaseIntegrationSpec -import nebula.plugin.info.InfoBrokerPlugin -import nebula.plugin.info.basic.BasicInfoPlugin -import nebula.test.IntegrationSpec +import nebula.plugin.info.BaseIntegrationTestKitSpec +import org.gradle.testkit.runner.TaskOutcome import java.util.jar.JarFile -class InfoPropertiesFilePluginLauncherSpec extends BaseIntegrationSpec { +class InfoPropertiesFilePluginLauncherSpec extends BaseIntegrationTestKitSpec { def 'jar task is marked UP-TO-DATE if ran before successfully and metadata changes are ignored'() { writeHelloWorld('nebula.test') buildFile << """ - ${applyPlugin(InfoBrokerPlugin)} - ${applyPlugin(BasicInfoPlugin)} - ${applyPlugin(InfoJarPropertiesFilePlugin)} + plugins { + id 'com.netflix.nebula.info-broker' + id 'com.netflix.nebula.info-basic' + id 'com.netflix.nebula.info-jar-properties' + } apply plugin: 'java' status = 'release' @@ -22,8 +22,8 @@ class InfoPropertiesFilePluginLauncherSpec extends BaseIntegrationSpec { when: // Make sure we have some history already in place - def result = runTasksSuccessfully('jar') - runTasksSuccessfully('clean') + def result = runTasks('jar') + runTasks('clean') result = runTasks('jar') @@ -34,19 +34,19 @@ class InfoPropertiesFilePluginLauncherSpec extends BaseIntegrationSpec { jarFile.exists() Properties metadata = getPropertiesFromJar(jarFile) metadata['Built-Status'] == 'release' - !result.wasUpToDate(':jar') + result.task(':jar').outcome != TaskOutcome.UP_TO_DATE when: 'Nothing has changed' - def secondResult = runTasksSuccessfully('jar') + def secondResult = runTasks('jar') then: - secondResult.wasUpToDate(':jar') + secondResult.task(':jar').outcome == TaskOutcome.UP_TO_DATE when: 'A manifest field was changed' buildFile << """ status = 'integration' """.stripIndent() - def thirdResult = runTasksSuccessfully('jar') + def thirdResult = runTasks('jar') then: File reusedJar = new File(projectDir, "build/libs/${moduleName}.jar") @@ -54,7 +54,7 @@ class InfoPropertiesFilePluginLauncherSpec extends BaseIntegrationSpec { Properties staleMetadata = getPropertiesFromJar(reusedJar) //metadata change is ignored and cache is reused staleMetadata['Built-Status'] == 'release' - thirdResult.wasUpToDate(':jar') + thirdResult.task(':jar').outcome == TaskOutcome.UP_TO_DATE } Properties getPropertiesFromJar(File jar) { @@ -71,9 +71,11 @@ class InfoPropertiesFilePluginLauncherSpec extends BaseIntegrationSpec { def 'all jar tasks is marked UP-TO-DATE if ran before successfully and metadata changes are ignored'() { writeHelloWorld('nebula.test') buildFile << """ - ${applyPlugin(InfoBrokerPlugin)} - ${applyPlugin(BasicInfoPlugin)} - ${applyPlugin(InfoJarPropertiesFilePlugin)} + plugins { + id 'com.netflix.nebula.info-broker' + id 'com.netflix.nebula.info-basic' + id 'com.netflix.nebula.info-jar-properties' + } apply plugin: 'java' status = 'release' @@ -86,30 +88,30 @@ class InfoPropertiesFilePluginLauncherSpec extends BaseIntegrationSpec { when: // Make sure we have some history already in place - runTasksSuccessfully('jar', 'sourceJar') - runTasksSuccessfully('clean') + runTasks('jar', 'sourceJar') + runTasks('clean') def result = runTasks('jar', 'sourceJar') then: - !result.wasUpToDate(':jar') - !result.wasUpToDate(':sourceJar') + result.task(':jar').outcome != TaskOutcome.UP_TO_DATE + result.task(':sourceJar').outcome != TaskOutcome.UP_TO_DATE when: 'Nothing has changed' - def secondResult = runTasksSuccessfully('jar', 'sourceJar') + def secondResult = runTasks('jar', 'sourceJar') then: - secondResult.wasUpToDate(':jar') - secondResult.wasUpToDate(':sourceJar') + secondResult.task(':jar').outcome == TaskOutcome.UP_TO_DATE + secondResult.task(':sourceJar').outcome == TaskOutcome.UP_TO_DATE when: 'A manifest field was changed' buildFile << """ status = 'integration' """.stripIndent() - def thirdResult = runTasksSuccessfully('jar', 'sourceJar') + def thirdResult = runTasks('jar', 'sourceJar') then: - thirdResult.wasUpToDate(':jar') - thirdResult.wasUpToDate(':sourceJar') + thirdResult.task(':jar').outcome == TaskOutcome.UP_TO_DATE + thirdResult.task(':sourceJar').outcome == TaskOutcome.UP_TO_DATE } }