Skip to content

Commit 7c4583d

Browse files
committed
Add failing test for #33
1 parent 6e73b6b commit 7c4583d

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

src/functionalTest/groovy/org/cadixdev/gradle/licenser/LicenserPluginFunctionalTest.groovy

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,57 @@ class LicenserPluginFunctionalTest extends Specification {
444444
445445
where:
446446
[gradleVersion, _, extraArgs] << testMatrix
447+
}
448+
449+
@Unroll
450+
def "Plugin tasks should work twice with configuration cache enabled (Gradle #gradleVersion)"() {
451+
given:
452+
def projectDir = temporaryFolder.newFolder()
453+
def sourceDir = projectDir.toPath().resolve(Paths.get("src", "main", "java", "com", "example")).toFile()
454+
sourceDir.mkdirs()
455+
new File(projectDir, "LICENSE") << "Copyright header"
456+
new File(projectDir, "settings.gradle") << ""
457+
new File(projectDir, "build.gradle") << """
458+
plugins {
459+
id('java')
460+
id('org.cadixdev.licenser')
461+
}
462+
""".stripIndent().trim()
463+
def sourceFileContent = """\
464+
/*
465+
* My header
466+
*/
467+
468+
package com.example;
469+
470+
class MyClass {}
471+
""".stripIndent()
472+
def sourceFile = new File(sourceDir, "MyClass.java") << sourceFileContent
447473
474+
when:
475+
def runner = runner(projectDir, gradleVersion, extraArgs + "checkLicenses")
476+
runner.debug = true
477+
def result = runner.build()
478+
479+
then:
480+
result.task(":checkLicenses").outcome == TaskOutcome.SUCCESS
481+
sourceFile.text == """\
482+
/*
483+
* Copyright header
484+
*/
485+
486+
package com.example;
487+
488+
class MyClass {}
489+
""".stripIndent()
490+
491+
when:
492+
def secondResult = runner.build()
493+
494+
then:
495+
secondResult.task(":checkLicenses").outcome == TaskOutcome.UP_TO_DATE
496+
497+
where:
498+
[gradleVersion, _, extraArgs] << configurationCacheTestMatrix
448499
}
449500
}

0 commit comments

Comments
 (0)