@@ -444,6 +444,57 @@ class LicenserPluginFunctionalTest extends Specification {
444
444
445
445
where:
446
446
[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
447
473
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
448
499
}
449
500
}
0 commit comments