diff --git a/build.gradle b/build.gradle index 6abaffa..99310cf 100644 --- a/build.gradle +++ b/build.gradle @@ -64,22 +64,3 @@ gradlePlugin { } } -/** - * This is temporary until config cache serialization is fixed when writing tests - * More in https://github.com/gradle/gradle/issues/25898 - */ -tasks.withType(Test).configureEach { - Provider jdkVersionForTestsEnvVariable = providers.environmentVariable("JDK_VERSION_FOR_TESTS") - Integer jdkVersionForTests = jdkVersionForTestsEnvVariable.isPresent() ? jdkVersionForTestsEnvVariable.get().toInteger() : 8 - if(jdkVersionForTests >= 17) { - jvmArgs = [ - '--add-opens=java.base/java.lang=ALL-UNNAMED', - '--add-opens=java.base/java.util=ALL-UNNAMED', - '--add-opens=java.base/java.lang.invoke=ALL-UNNAMED', - '--add-opens=java.base/java.net=ALL-UNNAMED', - '--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED' - - ] - } -} - diff --git a/src/integTest/groovy/nebula/plugin/release/GitVersioningIntegrationSpecSpec.groovy b/src/integTest/groovy/nebula/plugin/release/GitVersioningIntegrationSpecSpec.groovy index 5d4a74d..4bddb49 100644 --- a/src/integTest/groovy/nebula/plugin/release/GitVersioningIntegrationSpecSpec.groovy +++ b/src/integTest/groovy/nebula/plugin/release/GitVersioningIntegrationSpecSpec.groovy @@ -16,9 +16,9 @@ package nebula.plugin.release /** - * Tests for {@link GitVersioningIntegrationSpec}. + * Tests for {@link GitVersioningIntegrationTestKitSpec}. */ -class GitVersioningIntegrationSpecSpec extends GitVersioningIntegrationSpec { +class GitVersioningIntegrationSpecSpec extends GitVersioningIntegrationTestKitSpec { @Override def setupBuild() {} def 'inferred version is parsed'() { diff --git a/src/integTest/groovy/nebula/plugin/release/GitVersioningIntegrationSpec.groovy b/src/integTest/groovy/nebula/plugin/release/GitVersioningIntegrationTestKitSpec.groovy similarity index 83% rename from src/integTest/groovy/nebula/plugin/release/GitVersioningIntegrationSpec.groovy rename to src/integTest/groovy/nebula/plugin/release/GitVersioningIntegrationTestKitSpec.groovy index b717419..ecd0ed5 100644 --- a/src/integTest/groovy/nebula/plugin/release/GitVersioningIntegrationSpec.groovy +++ b/src/integTest/groovy/nebula/plugin/release/GitVersioningIntegrationTestKitSpec.groovy @@ -17,11 +17,12 @@ package nebula.plugin.release import com.github.zafarkhaja.semver.Version import nebula.test.IntegrationSpec +import nebula.test.IntegrationTestKitSpec import org.ajoberstar.grgit.Grgit import java.nio.file.Files -abstract class GitVersioningIntegrationSpec extends IntegrationSpec { +abstract class GitVersioningIntegrationTestKitSpec extends IntegrationTestKitSpec { protected Grgit git protected Grgit originGit @@ -33,18 +34,21 @@ abstract class GitVersioningIntegrationSpec extends IntegrationSpec { origin.mkdirs() ['build.gradle', 'settings.gradle'].each { - Files.move(new File(projectDir, it).toPath(), new File(origin, it).toPath()) + def file = new File(projectDir, it) + if(!file.exists()) { + file.createNewFile() + } + Files.move(file.toPath(), new File(origin, it).toPath()) } originGit = Grgit.init(dir: origin) - - originGit.add(patterns: ['build.gradle', 'settings.gradle', '.gitignore', 'gradle.properties'] as Set) + originGit.add(patterns: ['build.gradle', 'settings.gradle', '.gitignore'] as Set) originGit.commit(message: 'Initial checkout') git = Grgit.clone(dir: projectDir, uri: origin.absolutePath) as Grgit - new File(projectDir, '.gitignore') << '''.gradle-test-kit/ -.gradle/ + new File(projectDir, '.gitignore') << '''.gradle-test-kit +.gradle build/ gradle.properties'''.stripIndent() @@ -53,6 +57,8 @@ gradle.properties'''.stripIndent() setupBuild() + + git.add(patterns: ['build.gradle', 'settings.gradle', '.gitignore']) git.commit(message: 'Setup') git.push() } @@ -73,8 +79,8 @@ gradle.properties'''.stripIndent() } def Version inferredVersionForTask(String... args) { - def result = runTasksSuccessfully(args) - inferredVersion(result.standardOutput) + def result = runTasks(args) + inferredVersion(result.output) } def Version inferredVersion(String standardOutput) { diff --git a/src/integTest/groovy/nebula/plugin/release/Issue187IntegrationSpec.groovy b/src/integTest/groovy/nebula/plugin/release/Issue187IntegrationSpec.groovy index 8bc75b0..a382f9b 100644 --- a/src/integTest/groovy/nebula/plugin/release/Issue187IntegrationSpec.groovy +++ b/src/integTest/groovy/nebula/plugin/release/Issue187IntegrationSpec.groovy @@ -22,15 +22,17 @@ import spock.lang.Unroll @Ignore("We need to visit the configuration/evaluation of extension") @Issue("Inconsistent versioning for SNAPSHOT stage https://github.com/nebula-plugins/nebula-release-plugin/issues/187") -class Issue187IntegrationSpec extends GitVersioningIntegrationSpec { +class Issue187IntegrationSpec extends GitVersioningIntegrationTestKitSpec { @Override def setupBuild() { - fork = false buildFile << """ + plugins { + id 'com.netflix.nebula.release' + id 'java' + } ext.dryRun = true group = 'test' - ${applyPlugin(ReleasePlugin)} - ${applyPlugin(JavaPlugin)} + """.stripIndent() git.add(patterns: ['build.gradle', '.gitignore'] as Set) @@ -45,16 +47,16 @@ release { """ when: - def resultBuild = runTasksSuccessfully('build') + def resultBuild = runTasks('build') then: - resultBuild.standardOutput.contains('version: 0.3.0-SNAPSHOT') + resultBuild.output.contains('version: 0.3.0-SNAPSHOT') when: - def resultSnapshot = runTasksSuccessfully('snapshot') + def resultSnapshot = runTasks('snapshot') then: - resultSnapshot.standardOutput.contains('version: 0.3.0-SNAPSHOT') + resultSnapshot.output.contains('version: 0.3.0-SNAPSHOT') } @Unroll @@ -66,16 +68,16 @@ release { """ when: - def resultBuild = runTasksSuccessfully('build', "-Prelease.scope=${scope}") + def resultBuild = runTasks('build', "-Prelease.scope=${scope}") then: - resultBuild.standardOutput.contains("version: ${expectedVersion}") + resultBuild.output.contains("version: ${expectedVersion}") when: - def resultSnapshot = runTasksSuccessfully('snapshot', "-Prelease.scope=${scope}") + def resultSnapshot = runTasks('snapshot', "-Prelease.scope=${scope}") then: - resultSnapshot.standardOutput.contains("version: ${expectedVersion}") + resultSnapshot.output.contains("version: ${expectedVersion}") where: scope | expectedVersion @@ -87,16 +89,16 @@ release { @Unroll def 'infer #expectedVersion for #task task when not using snapshot strategy'() { when: - def resultBuild = runTasksSuccessfully('build') + def resultBuild = runTasks('build') then: - resultBuild.standardOutput.contains('version: 0.3.0-dev') + resultBuild.output.contains('version: 0.3.0-dev') when: - def resultSnapshot = runTasksSuccessfully(task) + def resultSnapshot = runTasks(task) then: - resultSnapshot.standardOutput.contains("version: $expectedVersion") + resultSnapshot.output.contains("version: $expectedVersion") where: task | expectedVersion @@ -108,16 +110,16 @@ release { @Unroll def 'infer release version #expectedReleaseVersion and build version #expectedBuildVersion for #task task when not using snapshot strategy with scope #scope'() { when: - def resultBuild = runTasksSuccessfully('build', "-Prelease.scope=${scope}") + def resultBuild = runTasks('build', "-Prelease.scope=${scope}") then: - resultBuild.standardOutput.contains("version: $expectedBuildVersion") + resultBuild.output.contains("version: $expectedBuildVersion") when: - def resultSnapshot = runTasksSuccessfully(task, "-Prelease.scope=${scope}") + def resultSnapshot = runTasks(task, "-Prelease.scope=${scope}") then: - resultSnapshot.standardOutput.contains("version: $expectedReleaseVersion") + resultSnapshot.output.contains("version: $expectedReleaseVersion") where: task | scope | expectedReleaseVersion | expectedBuildVersion diff --git a/src/integTest/groovy/nebula/plugin/release/ReleasePluginConfiguredVersionIntegrationSpec.groovy b/src/integTest/groovy/nebula/plugin/release/ReleasePluginConfiguredVersionIntegrationSpec.groovy index f2acecb..6bc48d3 100644 --- a/src/integTest/groovy/nebula/plugin/release/ReleasePluginConfiguredVersionIntegrationSpec.groovy +++ b/src/integTest/groovy/nebula/plugin/release/ReleasePluginConfiguredVersionIntegrationSpec.groovy @@ -1,20 +1,21 @@ package nebula.plugin.release -import org.gradle.api.plugins.JavaPlugin - -class ReleasePluginConfiguredVersionIntegrationSpec extends GitVersioningIntegrationSpec { +class ReleasePluginConfiguredVersionIntegrationSpec extends GitVersioningIntegrationTestKitSpec { @Override def setupBuild() { buildFile << """ + plugins { + id 'com.netflix.nebula.release' + } allprojects { - ${applyPlugin(ReleasePlugin)} + apply plugin: 'com.netflix.nebula.release' } subprojects { ext.dryRun = true group = 'test' - ${applyPlugin(JavaPlugin)} + apply plugin: 'java' } version = '1.0.0' @@ -35,10 +36,10 @@ class ReleasePluginConfiguredVersionIntegrationSpec extends GitVersioningIntegra def 'should fail build if version is set in build file'() { when: - def results = runTasksWithFailure('final') + def results = runTasksAndFail('final') then: - results.standardError.contains('version should not be set in build file when using nebula-release plugin. Instead use `-Prelease.version` parameter') + results.output.contains('version should not be set in build file when using nebula-release plugin. Instead use `-Prelease.version` parameter') } } \ No newline at end of file diff --git a/src/integTest/groovy/nebula/plugin/release/ReleasePluginGitStateIntegrationSpec.groovy b/src/integTest/groovy/nebula/plugin/release/ReleasePluginGitStateIntegrationSpec.groovy index 4ba64e1..d88e88c 100644 --- a/src/integTest/groovy/nebula/plugin/release/ReleasePluginGitStateIntegrationSpec.groovy +++ b/src/integTest/groovy/nebula/plugin/release/ReleasePluginGitStateIntegrationSpec.groovy @@ -1,16 +1,15 @@ package nebula.plugin.release -import org.gradle.api.plugins.JavaPlugin -import static org.codehaus.groovy.runtime.StackTraceUtils.extractRootCause - -class ReleasePluginGitStateIntegrationSpec extends GitVersioningIntegrationSpec { +class ReleasePluginGitStateIntegrationSpec extends GitVersioningIntegrationTestKitSpec { @Override def setupBuild() { buildFile << """ - ${applyPlugin(ReleasePlugin)} - ${applyPlugin(JavaPlugin)} + plugins { + id 'com.netflix.nebula.release' + id 'java' + } """ } @@ -19,16 +18,16 @@ class ReleasePluginGitStateIntegrationSpec extends GitVersioningIntegrationSpec buildFile << "// force an uncommitted change to file" when: - def finalFail = runTasksWithFailure("final") + def finalFail = runTasksAndFail("final") then: - extractRootCause(finalFail.failure).message.contains('require all changes to be committed into Git') + finalFail.output.contains('require all changes to be committed into Git') when: - def candidateFail = runTasksWithFailure("candidate") + def candidateFail = runTasksAndFail("candidate") then: - extractRootCause(candidateFail.failure).message.contains('require all changes to be committed into Git') + candidateFail.output.contains('require all changes to be committed into Git') } def 'ensure plugin does NOT throw an error when a good init tag is present'() { @@ -36,7 +35,7 @@ class ReleasePluginGitStateIntegrationSpec extends GitVersioningIntegrationSpec ['my-feature-branch', 'super-duper', 'v1.0', 'v0.1.0'].each { git.tag.add(name: it) } expect: - runTasksSuccessfully("devSnapshot") + runTasks("devSnapshot") } } diff --git a/src/integTest/groovy/nebula/plugin/release/ReleasePluginIntegrationSpec.groovy b/src/integTest/groovy/nebula/plugin/release/ReleasePluginIntegrationSpec.groovy index 4f2219e..fa5e257 100644 --- a/src/integTest/groovy/nebula/plugin/release/ReleasePluginIntegrationSpec.groovy +++ b/src/integTest/groovy/nebula/plugin/release/ReleasePluginIntegrationSpec.groovy @@ -21,17 +21,23 @@ import nebula.test.functional.ExecutionResult import org.ajoberstar.grgit.Tag import org.gradle.api.plugins.JavaPlugin import org.gradle.internal.impldep.com.amazonaws.util.Throwables +import org.gradle.testkit.runner.BuildResult +import org.gradle.testkit.runner.TaskOutcome import spock.lang.Ignore import spock.lang.Unroll -class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { +class ReleasePluginIntegrationSpec extends GitVersioningIntegrationTestKitSpec { @Override def setupBuild() { buildFile << """ + plugins { + id 'com.netflix.nebula.release' + id 'java' + } + ext.dryRun = true group = 'test' - ${applyPlugin(ReleasePlugin)} - ${applyPlugin(JavaPlugin)} + task showVersion { doLast { @@ -184,7 +190,7 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { def 'multiple candidate releases will increment rc number'() { - runTasksSuccessfully('candidate') + runTasks('candidate') when: def version = inferredVersionForTask('candidate') @@ -249,7 +255,7 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { } def 'multiple final releases with defaults will increment minor number'() { - runTasksSuccessfully('final') + runTasks('final') when: def version = inferredVersionForTask('final') @@ -280,11 +286,11 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.commit(message: 'Add breaking test') when: - def results = runTasksWithFailure('final') + def results = runTasksAndFail('final') then: - results.wasExecuted('test') - !results.wasExecuted('release') + results.task(':test').outcome == TaskOutcome.FAILED + !results.task(':release')?.outcome } def 'final release log'() { @@ -330,13 +336,13 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.add(patterns: ['.'] as Set) git.commit(message: "Add file") git.push(all: true) - runTasksSuccessfully('candidate') + runTasks('candidate') git.branch.add(name: "0.1.x") file.text = "Updated dummy" git.add(patterns: ['.'] as Set) git.commit(message: "Update file") git.push(all: true) - runTasksSuccessfully('candidate') + runTasks('candidate') when: git.checkout(branch: '0.1.x') @@ -484,7 +490,7 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.checkout(branch: oneThree) when: - def results = runTasksWithFailure('build') + def results = runTasksAndFail('build') then: outputContains(results, 'Branches with pattern release/ are used to calculate versions. The version must be of form: .x, ..x, or ..') @@ -503,20 +509,19 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.push() when: - def results = runTasksSuccessfully('final') + def results = runTasks('final') then: - results.wasExecuted('placeholderTask') + results.task(':placeholderTask').outcome == TaskOutcome.SUCCESS || results.task(':placeholderTask').outcome == TaskOutcome.UP_TO_DATE } def 'fail final release on non release branch'() { git.checkout(branch: 'testexample', createBranch: true) when: - def result = runTasksWithFailure('final') + def result = runTasksAndFail('final') then: - result.failure != null outputContains(result, 'testexample does not match one of the included patterns: [master, HEAD, main, (release(-|/))?\\d+(\\.\\d+)?\\.x, v?\\d+\\.\\d+\\.\\d+]') } @@ -614,10 +619,9 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.push() when: - def result = runTasksWithFailure('final') + def result = runTasksAndFail('final') then: - result.failure != null outputContains(result, 'master matched an excluded pattern: [^master\$]') } @@ -625,7 +629,7 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.tag.add(name: 'v42.5.3') when: - runTasksSuccessfully('final', '-Prelease.useLastTag=true') + runTasks('final', '-Prelease.useLastTag=true') then: new File(projectDir, "build/libs/${moduleName}-42.5.3.jar").exists() @@ -638,10 +642,10 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.commit(message: 'Something got committed') when: - def result = runTasksWithFailure('final', '-Prelease.useLastTag=true') + def result = runTasksAndFail('final', '-Prelease.useLastTag=true') then: - result.standardError.contains 'Current commit does not have a tag' + result.output.contains 'Current commit does not have a tag' !new File(projectDir, "build/libs/${moduleName}-42.5.3.jar").exists() } @@ -653,17 +657,17 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.tag.add(name: 'v42.5.4-rc.01') when: - def result = runTasksWithFailure('candidate', '-Prelease.useLastTag=true') + def result = runTasksAndFail('candidate', '-Prelease.useLastTag=true') then: - result.standardError.contains 'Current commit has following tags: [v42.5.4-rc.01] but they were not recognized as valid versions' + result.output.contains 'Current commit has following tags: [v42.5.4-rc.01] but they were not recognized as valid versions' } def 'use last tag for rc'() { git.tag.add(name: 'v3.1.2-rc.1') when: - runTasksSuccessfully('candidate', '-Prelease.useLastTag=true') + runTasks('candidate', '-Prelease.useLastTag=true') then: new File(projectDir, "build/libs/${moduleName}-3.1.2-rc.1.jar").exists() @@ -673,10 +677,10 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.tag.add(name: "v3.1.2-rc.1") when: - def result = runTasksWithFailure('final', '-Prelease.useLastTag=true') + def result = runTasksAndFail('final', '-Prelease.useLastTag=true') then: - result.standardError.contains "Current tag (3.1.2-rc.1) does not appear to be a final version" + result.output.contains "Current tag (3.1.2-rc.1) does not appear to be a final version" !new File(projectDir, "build/libs/${moduleName}-3.1.2-rc.1.jar").exists() } @@ -685,7 +689,7 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.tag.add(name: "v3.1.2") when: - def result = runTasksSuccessfully('final', '-Prelease.useLastTag=true') + def result = runTasks('final', '-Prelease.useLastTag=true') then: !new File(projectDir, "build/libs/${moduleName}-3.1.2-rc.1.jar").exists() @@ -697,47 +701,47 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.tag.add(name: "v3.1.2") when: - def result = runTasksWithFailure('candidate', '-Prelease.useLastTag=true') + def result = runTasksAndFail('candidate', '-Prelease.useLastTag=true') then: - result.standardError.contains "Current tag (3.1.2) does not appear to be a pre-release version. A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers immediately following the patch version. For more information, please refer to https://semver.org/" + result.output.contains "Current tag (3.1.2) does not appear to be a pre-release version. A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers immediately following the patch version. For more information, please refer to https://semver.org/" !new File(projectDir, "build/libs/${moduleName}-3.1.2-rc.1.jar").exists() !new File(projectDir, "build/libs/${moduleName}-3.1.2.jar").exists() } def 'fails when running devSnapshot With useLastTag'() { when: - def result = runTasksWithFailure('devSnapshot', '-Prelease.useLastTag=true') + def result = runTasksAndFail('devSnapshot', '-Prelease.useLastTag=true') then: - result.standardError.contains "Cannot use useLastTag with snapshot, immutableSnapshot and devSnapshot tasks" + result.output.contains "Cannot use useLastTag with snapshot, immutableSnapshot and devSnapshot tasks" !new File(projectDir, "build/libs/${moduleName}-3.1.2-rc.1.jar").exists() } def 'succeeds when running devSnapshot With useLastTag false'() { expect: - runTasksSuccessfully('devSnapshot', '-Prelease.useLastTag=false') + runTasks('devSnapshot', '-Prelease.useLastTag=false') } def 'fails when running immutableSnapshot With useLastTag'() { when: - def result = runTasksWithFailure('immutableSnapshot', '-Prelease.useLastTag=true') + def result = runTasksAndFail('immutableSnapshot', '-Prelease.useLastTag=true') then: - result.standardError.contains "Cannot use useLastTag with snapshot, immutableSnapshot and devSnapshot tasks" + result.output.contains "Cannot use useLastTag with snapshot, immutableSnapshot and devSnapshot tasks" !new File(projectDir, "build/libs/${moduleName}-3.1.2-rc.1.jar").exists() } def 'succeeds when running immutableSnapshot With useLastTag false'() { expect: - runTasksSuccessfully('immutableSnapshot', '-Prelease.useLastTag=false') + runTasks('immutableSnapshot', '-Prelease.useLastTag=false') } def 'useLastTag succeeds when release stage is not supplied for final tag'() { git.tag.add(name: 'v42.5.3') when: - def result = runTasksSuccessfully('assemble', '-Prelease.useLastTag=true') + def result = runTasks('assemble', '-Prelease.useLastTag=true') then: new File(projectDir, "build/libs/${moduleName}-42.5.3.jar").exists() @@ -747,7 +751,7 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.tag.add(name: 'v3.1.2-rc.1') when: - def result = runTasksSuccessfully('assemble', '-Prelease.useLastTag=true') + def result = runTasks('assemble', '-Prelease.useLastTag=true') then: new File(projectDir, "build/libs/${moduleName}-3.1.2-rc.1.jar").exists() @@ -758,7 +762,7 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.tag.add(name: "${dev('0.1.0-dev.3+').toString()}") when: - def result = runTasksSuccessfully('assemble', '-Prelease.useLastTag=true') + def result = runTasks('assemble', '-Prelease.useLastTag=true') then: new File(projectDir, "build/libs/${moduleName}-3.1.2-rc.1.jar").exists() @@ -768,10 +772,10 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.tag.add(name: "${dev('0.1.0-dev.3+').toString()}") when: - def result = runTasksWithFailure('assemble', '-Prelease.useLastTag=true') + def result = runTasksAndFail('assemble', '-Prelease.useLastTag=true') then: - result.standardError.contains "Current commit has a snapshot, immutableSnapshot or devSnapshot tag. 'useLastTag' requires a prerelease or final tag." + result.output.contains "Current commit has a snapshot, immutableSnapshot or devSnapshot tag. 'useLastTag' requires a prerelease or final tag." !new File(projectDir, "build/libs/${moduleName}-${dev('0.1.0-dev.3+').toString()}.jar").exists() } @@ -780,10 +784,10 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.tag.add(name: "${dev('0.1.0-snapshot.220190705103502+').toString()}") when: - def result = runTasksWithFailure('assemble', '-Prelease.useLastTag=true') + def result = runTasksAndFail('assemble', '-Prelease.useLastTag=true') then: - result.standardError.contains "Current commit has a snapshot, immutableSnapshot or devSnapshot tag. 'useLastTag' requires a prerelease or final tag." + result.output.contains "Current commit has a snapshot, immutableSnapshot or devSnapshot tag. 'useLastTag' requires a prerelease or final tag." !new File(projectDir, "build/libs/${moduleName}-${dev('0.1.0-snapshot.220190705103502+').toString()}.jar").exists() } @@ -791,10 +795,10 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.tag.add(name: "1.2.3-SNAPSHOT") when: - def result = runTasksWithFailure('assemble', '-Prelease.useLastTag=true') + def result = runTasksAndFail('assemble', '-Prelease.useLastTag=true') then: - result.standardError.contains "Current commit has a snapshot, immutableSnapshot or devSnapshot tag. 'useLastTag' requires a prerelease or final tag." + result.output.contains "Current commit has a snapshot, immutableSnapshot or devSnapshot tag. 'useLastTag' requires a prerelease or final tag." !new File(projectDir, "build/libs/${moduleName}-1.2.3-SNAPSHOT.jar").exists() } @@ -804,7 +808,7 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.tag.add(name: 'v3.1.2') when: - def result = runTasksSuccessfully('assemble', '-Prelease.useLastTag=true') + def result = runTasks('assemble', '-Prelease.useLastTag=true') then: new File(projectDir, "build/libs/${moduleName}-3.1.2.jar").exists() @@ -815,7 +819,7 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.tag.add(name: 'v3.1.2-rc.2') when: - def result = runTasksSuccessfully('assemble', '-Prelease.useLastTag=true') + def result = runTasks('assemble', '-Prelease.useLastTag=true') then: new File(projectDir, "build/libs/${moduleName}-3.1.2-rc.2.jar").exists() @@ -825,36 +829,36 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.tag.add(name: 'v42.5.3') when: - def result = runTasksSuccessfully('final', '-Prelease.useLastTag=true', '--debug') + def result = runTasks('final', '-Prelease.useLastTag=true', '--debug') then: new File(projectDir, "build/libs/${moduleName}-42.5.3.jar").exists() - result.standardOutput.contains('Using version 42.5.3 with final release strategy') + result.output.contains('Using version 42.5.3 with final release strategy') } def 'useLastTag shows version selection with debug enabled - no release strategy selected'() { git.tag.add(name: 'v42.5.3') when: - def result = runTasksSuccessfully('assemble', '-Prelease.useLastTag=true', '--debug') + def result = runTasks('assemble', '-Prelease.useLastTag=true', '--debug') then: new File(projectDir, "build/libs/${moduleName}-42.5.3.jar").exists() - result.standardOutput.contains("Note: It is recommended to supply a release strategy of to make 'useLastTag' most explicit. Please add one to your list of tasks.") - result.standardOutput.contains('Using version 42.5.3 with a non-supplied release strategy') + result.output.contains("Note: It is recommended to supply a release strategy of to make 'useLastTag' most explicit. Please add one to your list of tasks.") + result.output.contains('Using version 42.5.3 with a non-supplied release strategy') } def 'succeeds when running snapshot With useLastTag false'() { expect: - runTasksSuccessfully('snapshot', '-Prelease.useLastTag=false') + runTasks('snapshot', '-Prelease.useLastTag=false') } def 'fails when running snapshot With useLastTag'() { when: - def result = runTasksWithFailure('snapshot', '-Prelease.useLastTag=true') + def result = runTasksAndFail('snapshot', '-Prelease.useLastTag=true') then: - result.standardError.contains "Cannot use useLastTag with snapshot, immutableSnapshot and devSnapshot tasks" + result.output.contains "Cannot use useLastTag with snapshot, immutableSnapshot and devSnapshot tasks" !new File(projectDir, "build/libs/${moduleName}-3.1.2-rc.1.jar").exists() } @@ -862,16 +866,16 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.tag.add(name: "v3.1.2") when: - def result = runTasksWithFailure('candidate', '-Prelease.useLastTag=true') + def result = runTasksAndFail('candidate', '-Prelease.useLastTag=true') then: - result.standardError.contains "Current tag (3.1.2) does not appear to be a pre-release version. A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers immediately following the patch version. For more information, please refer to https://semver.org/" + result.output.contains "Current tag (3.1.2) does not appear to be a pre-release version. A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers immediately following the patch version. For more information, please refer to https://semver.org/" !new File(projectDir, "build/libs/${moduleName}-3.1.2.jar").exists() } def 'skip useLastTag if false'() { when: - runTasksSuccessfully('final', '-Prelease.useLastTag=345') + runTasks('final', '-Prelease.useLastTag=345') then: new File(projectDir, "build/libs/${moduleName}-0.1.0.jar").exists() @@ -903,7 +907,7 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { def 'able to release with the override of version calculation'() { when: - runTasksSuccessfully('final', '-Prelease.version=42.5.0') + runTasks('final', '-Prelease.version=42.5.0') then: new File(projectDir, "build/libs/${moduleName}-42.5.0.jar").exists() @@ -912,10 +916,10 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { def 'error if release.version is set to an empty string'() { when: - def result = runTasksWithFailure('build', '-Prelease.version=') + def result = runTasksAndFail('build', '-Prelease.version=') then: - Throwables.getRootCause(result.failure).message == 'Supplied release.version is empty' + result.output.contains('Supplied release.version is empty') } def 'devSnapshot works if default is changed'() { @@ -1013,7 +1017,7 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.tag.add(name: "v3.1.2+release2") when: - def result = runTasksSuccessfully('final', '-Prelease.useLastTag=true') + def result = runTasks('final', '-Prelease.useLastTag=true') then: !new File(projectDir, "build/libs/${moduleName}-3.1.2.jar").exists() @@ -1036,10 +1040,10 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.tag.add(name: "v3.1.2-release2") when: - def result = runTasksWithFailure('final', '-Prelease.useLastTag=true') + def result = runTasksAndFail('final', '-Prelease.useLastTag=true') then: - result.standardError.contains 'Current tag (3.1.2-release2) does not appear to be a final version' + result.output.contains 'Current tag (3.1.2-release2) does not appear to be a final version' } @@ -1053,7 +1057,7 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.commit(message: 'commenting build.gradle') when: - def results = runTasksSuccessfully(task) + def results = runTasks(task) then: originalRemoteHeadCommit == originGit.head().abbreviatedId @@ -1108,7 +1112,7 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.add(patterns: ['.'] as Set) git.commit(message: "Add file") git.push(all: true) - runTasksSuccessfully('candidate') + runTasks('candidate') git.branch.add(name: "0.1.x") file.text = "Updated dummy" git.add(patterns: ['.'] as Set) @@ -1116,10 +1120,10 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.push(all: true) when: - def result = runTasksSuccessfully('candidate') + def result = runTasks('candidate') then: - result.wasSkipped(':prepare') + result.task(':prepare').outcome == TaskOutcome.SKIPPED } def 'executes prepare if checkRemoteBranchOnRelease when releasing'() { @@ -1127,8 +1131,6 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { buildFile << """ ext.dryRun = true group = 'test' - ${applyPlugin(ReleasePlugin)} - ${applyPlugin(JavaPlugin)} nebulaRelease { checkRemoteBranchOnRelease = true @@ -1139,7 +1141,7 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.add(patterns: ['.'] as Set) git.commit(message: "Add file") git.push(all: true) - runTasksSuccessfully('candidate') + runTasks('candidate') git.branch.add(name: "0.1.x") file.text = "Updated dummy" git.add(patterns: ['.'] as Set) @@ -1147,11 +1149,11 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.push(all: true) when: - def result = runTasksSuccessfully('candidate', '-Drelease.configurePrepareTaskEnabled=true') + def result = runTasks('candidate', '-Drelease.configurePrepareTaskEnabled=true') then: - result.wasExecuted(':prepare') - !result.wasSkipped(':prepare') + result.task(':prepare').outcome in [TaskOutcome.SUCCESS, TaskOutcome.UP_TO_DATE] + result.task(':prepare').outcome != TaskOutcome.SKIPPED } @@ -1160,8 +1162,6 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { buildFile << """ ext.dryRun = true group = 'test' - ${applyPlugin(ReleasePlugin)} - ${applyPlugin(JavaPlugin)} nebulaRelease { checkRemoteBranchOnRelease = true @@ -1175,10 +1175,10 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.checkout(branch: 'my-branch-with-dash-', createBranch: true) when: - def result = runTasksWithFailure('candidate', '-Drelease.configurePrepareTaskEnabled=true') + def result = runTasksAndFail('candidate', '-Drelease.configurePrepareTaskEnabled=true') then: - result.standardError.contains('Nebula Release plugin does not support branches that end with dash (-)') + result.output.contains('Nebula Release plugin does not support branches that end with dash (-)') } @Unroll @@ -1186,10 +1186,10 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.tag.add(name: "v$version") when: - def result = runTasksWithFailure('final', '-Prelease.useLastTag=true') + def result = runTasksAndFail('final', '-Prelease.useLastTag=true') then: - result.standardError.contains "Current commit has following tags: [v${version}] but they were not recognized as valid versions" + result.output.contains "Current commit has following tags: [v${version}] but they were not recognized as valid versions" !new File(projectDir, "build/libs/${moduleName}-${version}.jar").exists() where: @@ -1204,10 +1204,10 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { @Unroll def 'release with the override of version calculation errors out if version has invalid number of digits - #version'() { when: - def result = runTasksWithFailure('final', "-Prelease.version=${version}") + def result = runTasksAndFail('final', "-Prelease.version=${version}") then: - result.standardError.contains "Supplied release.version ($version) is not valid per semver spec. For more information, please refer to https://semver.org/" + result.output.contains "Supplied release.version ($version) is not valid per semver spec. For more information, please refer to https://semver.org/" !new File(projectDir, "build/libs/${moduleName}-${version}.jar").exists() !originGit.tag.list()*.name.contains("v${version}") @@ -1223,10 +1223,10 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { @Unroll def 'release with the override of version calculation does not errors out if version has invalid number of digits but verification is off - #version'() { when: - def result = runTasksSuccessfully('final', "-Prelease.version=${version}", "-Prelease.ignoreSuppliedVersionVerification=true") + def result = runTasks('final', "-Prelease.version=${version}", "-Prelease.ignoreSuppliedVersionVerification=true") then: - !result.standardError.contains("Supplied release.version ($version) is not valid per semver spec. For more information, please refer to https://semver.org/") + !result.output.contains("Supplied release.version ($version) is not valid per semver spec. For more information, please refer to https://semver.org/") new File(projectDir, "build/libs/${moduleName}-${version}.jar").exists() where: @@ -1242,12 +1242,12 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { git.checkout(branch: 'main', createBranch: true) when: - def result = runTasksSuccessfully('final') + def result = runTasks('final') then: - result.wasExecuted('final') - result.standardOutput.contains('Tagging repository as v0.1.0') - result.standardOutput.contains('Pushing changes in v0.1.0 to origin') + result.task(':final').outcome == TaskOutcome.SUCCESS + result.output.contains('Tagging repository as v0.1.0') + result.output.contains('Pushing changes in v0.1.0 to origin') } def 'Can create devSnapshot with scope patch if candidate for next minor is present'() { @@ -1281,8 +1281,8 @@ nebula.release.features.replaceDevWithImmutableSnapshot=true """ } - static outputContains(ExecutionResult result, String substring) { - return result.standardError.contains(substring) || result.standardOutput.contains(substring) + static outputContains(BuildResult result, String substring) { + return result.output.contains(substring) } private String getUtcDateForComparison() { diff --git a/src/integTest/groovy/nebula/plugin/release/ReleasePluginIvyStatusIntegrationSpec.groovy b/src/integTest/groovy/nebula/plugin/release/ReleasePluginIvyStatusIntegrationSpec.groovy index a2f372e..8dc8797 100644 --- a/src/integTest/groovy/nebula/plugin/release/ReleasePluginIvyStatusIntegrationSpec.groovy +++ b/src/integTest/groovy/nebula/plugin/release/ReleasePluginIvyStatusIntegrationSpec.groovy @@ -14,23 +14,24 @@ * limitations under the License. */ package nebula.plugin.release -import nebula.test.functional.ExecutionResult -import org.gradle.api.plugins.JavaPlugin -import org.gradle.api.publish.ivy.plugins.IvyPublishPlugin -import spock.lang.IgnoreIf -class ReleasePluginIvyStatusIntegrationSpec extends GitVersioningIntegrationSpec { +import org.gradle.testkit.runner.BuildResult + +class ReleasePluginIvyStatusIntegrationSpec extends GitVersioningIntegrationTestKitSpec { public static final String REPO_LOCATION = 'build/ivytest' @Override def setupBuild() { buildFile << """ + plugins { + id 'com.netflix.nebula.release' + id 'java' + id 'ivy-publish' + } ext.dryRun = true group = 'test' - ${applyPlugin(ReleasePlugin)} - ${applyPlugin(JavaPlugin)} - ${applyPlugin(IvyPublishPlugin)} + publishing { repositories { @@ -75,8 +76,8 @@ class ReleasePluginIvyStatusIntegrationSpec extends GitVersioningIntegrationSpec git.add(patterns: ['build.gradle', '.gitignore', 'settings.gradle'] as Set) } - def loadIvyFileViaVersionLookup(ExecutionResult result) { - loadIvyFile(inferredVersion(result.standardOutput, 'statuscheck').toString()) + def loadIvyFileViaVersionLookup(BuildResult result) { + loadIvyFile(inferredVersion(result.output, 'statuscheck').toString()) } def loadIvyFile(String version) { @@ -85,7 +86,7 @@ class ReleasePluginIvyStatusIntegrationSpec extends GitVersioningIntegrationSpec def 'snapshot leaves integration status'() { when: - def result = runTasksSuccessfully('snapshot') + def result = runTasks('snapshot') then: def xml = loadIvyFileViaVersionLookup(result) @@ -94,15 +95,15 @@ class ReleasePluginIvyStatusIntegrationSpec extends GitVersioningIntegrationSpec def 'snapshot leaves project.status as integration'() { when: - def result = runTasksSuccessfully('snapshot', 'printStatus') + def result = runTasks('snapshot', 'printStatus') then: - result.standardOutput.contains 'Project Status: integration' + result.output.contains 'Project Status: integration' } def 'devSnapshot leaves integration status'() { when: - def result = runTasksSuccessfully('devSnapshot') + def result = runTasks('devSnapshot') then: def xml = loadIvyFileViaVersionLookup(result) @@ -111,7 +112,7 @@ class ReleasePluginIvyStatusIntegrationSpec extends GitVersioningIntegrationSpec def 'immutableSnapshot leaves integration status'() { when: - def result = runTasksSuccessfully('immutableSnapshot') + def result = runTasks('immutableSnapshot') then: def xml = loadIvyFileViaVersionLookup(result) @@ -120,7 +121,7 @@ class ReleasePluginIvyStatusIntegrationSpec extends GitVersioningIntegrationSpec def 'candidate sets candidate status'() { when: - def result = runTasksSuccessfully('candidate') + def result = runTasks('candidate') then: def xml = loadIvyFileViaVersionLookup(result) @@ -130,7 +131,7 @@ class ReleasePluginIvyStatusIntegrationSpec extends GitVersioningIntegrationSpec def 'final sets release status'() { when: - def result = runTasksSuccessfully('final') + def result = runTasks('final') then: def xml = loadIvyFileViaVersionLookup(result) diff --git a/src/integTest/groovy/nebula/plugin/release/ReleasePluginMultiprojectIntegrationSpec.groovy b/src/integTest/groovy/nebula/plugin/release/ReleasePluginMultiprojectIntegrationSpec.groovy index 9a129f1..94caba5 100644 --- a/src/integTest/groovy/nebula/plugin/release/ReleasePluginMultiprojectIntegrationSpec.groovy +++ b/src/integTest/groovy/nebula/plugin/release/ReleasePluginMultiprojectIntegrationSpec.groovy @@ -15,23 +15,24 @@ */ package nebula.plugin.release -import org.gradle.api.plugins.JavaPlugin -import org.gradle.api.publish.plugins.PublishingPlugin import spock.lang.Ignore import spock.lang.Unroll -class ReleasePluginMultiprojectIntegrationSpec extends GitVersioningIntegrationSpec { +class ReleasePluginMultiprojectIntegrationSpec extends GitVersioningIntegrationTestKitSpec { @Override def setupBuild() { buildFile << """\ + plugins { + id 'com.netflix.nebula.release' + } allprojects { - ${applyPlugin(ReleasePlugin)} + apply plugin: 'com.netflix.nebula.release' } subprojects { ext.dryRun = true group = 'test' - ${applyPlugin(JavaPlugin)} + apply plugin: 'java' } """.stripIndent() @@ -50,30 +51,30 @@ class ReleasePluginMultiprojectIntegrationSpec extends GitVersioningIntegrationS def 'choose release version'() { when: - def results = runTasksSuccessfully('final') + def results = runTasks('final') then: - inferredVersion(results.standardOutput) == normal('0.1.0') + inferredVersion(results.output) == normal('0.1.0') new File(projectDir, 'test-release-common/build/libs/test-release-common-0.1.0.jar').exists() new File(projectDir, 'test-release-client/build/libs/test-release-client-0.1.0.jar').exists() } def 'choose candidate version'() { when: - def results = runTasksSuccessfully('candidate') + def results = runTasks('candidate') then: - inferredVersion(results.standardOutput) == normal('0.1.0-rc.1') + inferredVersion(results.output) == normal('0.1.0-rc.1') new File(projectDir, 'test-release-common/build/libs/test-release-common-0.1.0-rc.1.jar').exists() new File(projectDir, 'test-release-client/build/libs/test-release-client-0.1.0-rc.1.jar').exists() } def 'build defaults to dev version'() { when: - def results = runTasksSuccessfully('build') + def results = runTasks('build') then: - inferredVersion(results.standardOutput) == dev('0.1.0-dev.2+') + inferredVersion(results.output) == dev('0.1.0-dev.2+') new File(projectDir, 'test-release-common/build/libs').list().find { it =~ /test-release-common-0\.1\.0-dev\.2\+/ } != null @@ -86,10 +87,10 @@ class ReleasePluginMultiprojectIntegrationSpec extends GitVersioningIntegrationS git.checkout(branch: 'testexample', createBranch: true) when: - def results = runTasksSuccessfully('build') + def results = runTasks('build') then: - inferredVersion(results.standardOutput) == dev('0.1.0-dev.2+') + inferredVersion(results.output) == dev('0.1.0-dev.2+') new File(projectDir, 'test-release-common/build/libs').list().find { it =~ /test-release-common-0\.1\.0-dev\.2\+testexample\./ } != null @@ -102,12 +103,12 @@ class ReleasePluginMultiprojectIntegrationSpec extends GitVersioningIntegrationS given: buildFile << """\ allprojects { - ${applyPlugin(PublishingPlugin)} - ${applyPlugin(JavaPlugin)} + apply plugin: 'org.gradle.publishing' + apply plugin: 'java' } """.stripIndent() when: - runTasksSuccessfully('tasks', '--all') + runTasks('tasks', '--all') then: noExceptionThrown() @@ -124,8 +125,8 @@ class ReleasePluginMultiprojectIntegrationSpec extends GitVersioningIntegrationS } allprojects { - ${applyPlugin(PublishingPlugin)} - ${applyPlugin(JavaPlugin)} + apply plugin: 'org.gradle.publishing' + apply plugin: 'java' } subprojects { sub -> @@ -146,13 +147,13 @@ class ReleasePluginMultiprojectIntegrationSpec extends GitVersioningIntegrationS """.stripIndent() when: - runTasksSuccessfully('tasks', '--all', '--warning-mode', 'all') + runTasks('tasks', '--all', '--warning-mode', 'all') then: noExceptionThrown() when: - def r = runTasksSuccessfully('snapshot', '-m') + def r = runTasks('snapshot', '-m') then: noExceptionThrown() @@ -171,7 +172,7 @@ class ReleasePluginMultiprojectIntegrationSpec extends GitVersioningIntegrationS git.commit(message: 'commenting build.gradle') when: - def results = runTasksSuccessfully(task) + def results = runTasks(task) then: originalRemoteHeadCommit == originGit.head().abbreviatedId diff --git a/src/integTest/groovy/nebula/plugin/release/ReleasePluginNewProjectIntegrationSpec.groovy b/src/integTest/groovy/nebula/plugin/release/ReleasePluginNewProjectIntegrationSpec.groovy index 61c53be..8f070cd 100644 --- a/src/integTest/groovy/nebula/plugin/release/ReleasePluginNewProjectIntegrationSpec.groovy +++ b/src/integTest/groovy/nebula/plugin/release/ReleasePluginNewProjectIntegrationSpec.groovy @@ -1,12 +1,12 @@ package nebula.plugin.release -import nebula.test.IntegrationSpec +import nebula.test.IntegrationTestKitSpec import org.ajoberstar.grgit.Grgit -import org.gradle.api.plugins.JavaPlugin + /** * Verify the behavior of nebula-release under various states for a new project (e.g. no git repo yet initialized, no * initial commit) */ -class ReleasePluginNewProjectIntegrationSpec extends IntegrationSpec { +class ReleasePluginNewProjectIntegrationSpec extends IntegrationTestKitSpec { def 'release tasks unavailable when git repository has no commits'() { setup: // equivalent of having completed `git init` but no initial commit def origin = new File(projectDir.parent, "${projectDir.name}.git") @@ -15,12 +15,14 @@ class ReleasePluginNewProjectIntegrationSpec extends IntegrationSpec { when: buildFile << """ - ${applyPlugin(ReleasePlugin)} - ${applyPlugin(JavaPlugin)} + plugins { + id 'com.netflix.nebula.release' + id 'java' + } """ then: - runTasksSuccessfully('build') - runTasksWithFailure('snapshot') + runTasks('build') + runTasksAndFail('snapshot') } } diff --git a/src/integTest/groovy/nebula/plugin/release/ReleasePluginNoCommitIntegrationSpec.groovy b/src/integTest/groovy/nebula/plugin/release/ReleasePluginNoCommitIntegrationSpec.groovy index c913614..057512d 100644 --- a/src/integTest/groovy/nebula/plugin/release/ReleasePluginNoCommitIntegrationSpec.groovy +++ b/src/integTest/groovy/nebula/plugin/release/ReleasePluginNoCommitIntegrationSpec.groovy @@ -15,21 +15,24 @@ */ package nebula.plugin.release -import nebula.test.IntegrationSpec +import nebula.test.IntegrationTestKitSpec import org.ajoberstar.grgit.Grgit -import org.gradle.api.plugins.JavaPlugin -class ReleasePluginNoCommitIntegrationSpec extends IntegrationSpec { +class ReleasePluginNoCommitIntegrationSpec extends IntegrationTestKitSpec { Grgit repo def 'repo with no commits does not throw errors'() { given: repo = Grgit.init(dir: projectDir) buildFile << """\ + plugins { + id 'com.netflix.nebula.release' + id 'java' + } + ext.dryRun = true group = 'test' - ${applyPlugin(ReleasePlugin)} - ${applyPlugin(JavaPlugin)} + task showVersion { doLast { @@ -42,7 +45,7 @@ class ReleasePluginNoCommitIntegrationSpec extends IntegrationSpec { def results = runTasks('showVersion') then: - results.standardOutput.contains 'Version in task: 0.1.0-dev.0.uncommitted' + results.output.contains 'Version in task: 0.1.0-dev.0.uncommitted' } def 'repo with no commits does not throw errors - replace dev with immutable snapshot'() { @@ -52,10 +55,13 @@ class ReleasePluginNoCommitIntegrationSpec extends IntegrationSpec { nebula.release.features.replaceDevWithImmutableSnapshot=true """ buildFile << """\ + plugins { + id 'com.netflix.nebula.release' + id 'java' + } + ext.dryRun = true group = 'test' - ${applyPlugin(ReleasePlugin)} - ${applyPlugin(JavaPlugin)} task showVersion { doLast { @@ -68,7 +74,7 @@ nebula.release.features.replaceDevWithImmutableSnapshot=true def results = runTasks('showVersion') then: - results.standardOutput.contains 'Version in task: 0.1.0-snapshot.' - results.standardOutput.contains '.uncommitted' + results.output.contains 'Version in task: 0.1.0-snapshot.' + results.output.contains '.uncommitted' } } diff --git a/src/integTest/groovy/nebula/plugin/release/ReleasePluginNoRepoIntegrationSpec.groovy b/src/integTest/groovy/nebula/plugin/release/ReleasePluginNoRepoIntegrationSpec.groovy index 44599ef..f696605 100644 --- a/src/integTest/groovy/nebula/plugin/release/ReleasePluginNoRepoIntegrationSpec.groovy +++ b/src/integTest/groovy/nebula/plugin/release/ReleasePluginNoRepoIntegrationSpec.groovy @@ -15,17 +15,19 @@ */ package nebula.plugin.release -import nebula.test.IntegrationSpec +import nebula.test.IntegrationTestKitSpec import org.gradle.api.plugins.JavaPlugin -class ReleasePluginNoRepoIntegrationSpec extends IntegrationSpec { +class ReleasePluginNoRepoIntegrationSpec extends IntegrationTestKitSpec { def 'calculate version with no commits'() { given: buildFile << """\ + plugins { + id 'com.netflix.nebula.release' + id 'java' + } ext.dryRun = true group = 'test' - ${applyPlugin(ReleasePlugin)} - ${applyPlugin(JavaPlugin)} task showVersion { doLast { @@ -35,9 +37,9 @@ class ReleasePluginNoRepoIntegrationSpec extends IntegrationSpec { """.stripIndent() when: - def results = runTasksSuccessfully('showVersion') + def results = runTasks('showVersion') then: - results.standardOutput.contains 'Version in task: 0.1.0-dev.0.uncommitted' + results.output.contains 'Version in task: 0.1.0-dev.0.uncommitted' } }