From 41641474eac30e8b010e65f044bf37f5e01278e0 Mon Sep 17 00:00:00 2001
From: Roberto Perez Alcolea <rperezalcolea@netflix.com>
Date: Wed, 13 Dec 2023 15:02:50 -0800
Subject: [PATCH] Mark as not compatible with configuration cache

---
 .../gradle/plugins/daemon/DaemonTemplateTask.groovy    |  4 ++++
 .../groovy/com/netflix/gradle/plugins/deb/Deb.groovy   |  1 +
 .../packaging/OsPackageAbstractArchiveTask.groovy      |  5 +++++
 .../plugins/packaging/SystemPackagingTask.groovy       |  1 +
 .../groovy/com/netflix/gradle/plugins/rpm/Rpm.groovy   |  1 +
 .../gradle/plugins/BaseIntegrationTestKitSpec.groovy   | 10 ++++++++++
 ...ckageApplicationSpringBootPluginLauncherSpec.groovy |  4 ++++
 7 files changed, 26 insertions(+)

diff --git a/src/main/groovy/com/netflix/gradle/plugins/daemon/DaemonTemplateTask.groovy b/src/main/groovy/com/netflix/gradle/plugins/daemon/DaemonTemplateTask.groovy
index 16d69617..4cbe4851 100644
--- a/src/main/groovy/com/netflix/gradle/plugins/daemon/DaemonTemplateTask.groovy
+++ b/src/main/groovy/com/netflix/gradle/plugins/daemon/DaemonTemplateTask.groovy
@@ -31,6 +31,10 @@ import org.gradle.work.DisableCachingByDefault
 @DisableCachingByDefault
 class DaemonTemplateTask extends ConventionTask {
 
+    DaemonTemplateTask() {
+        notCompatibleWithConfigurationCache("nebula.ospackage does not support configuration cache")
+    }
+
     @Internal
     Map<String, String> context
 
diff --git a/src/main/groovy/com/netflix/gradle/plugins/deb/Deb.groovy b/src/main/groovy/com/netflix/gradle/plugins/deb/Deb.groovy
index 93e73081..b7ede4de 100755
--- a/src/main/groovy/com/netflix/gradle/plugins/deb/Deb.groovy
+++ b/src/main/groovy/com/netflix/gradle/plugins/deb/Deb.groovy
@@ -33,6 +33,7 @@ class Deb extends SystemPackagingTask {
     Deb() {
         super()
         archiveExtension.set 'deb'
+        notCompatibleWithConfigurationCache("nebula.ospackage does not support configuration cache")
     }
 
     @Override
diff --git a/src/main/groovy/com/netflix/gradle/plugins/packaging/OsPackageAbstractArchiveTask.groovy b/src/main/groovy/com/netflix/gradle/plugins/packaging/OsPackageAbstractArchiveTask.groovy
index e2eb5903..06cc436b 100644
--- a/src/main/groovy/com/netflix/gradle/plugins/packaging/OsPackageAbstractArchiveTask.groovy
+++ b/src/main/groovy/com/netflix/gradle/plugins/packaging/OsPackageAbstractArchiveTask.groovy
@@ -9,6 +9,11 @@ import javax.annotation.Nullable
 @DisableCachingByDefault
 abstract class OsPackageAbstractArchiveTask extends AbstractArchiveTask {
 
+    OsPackageAbstractArchiveTask() {
+        super()
+        notCompatibleWithConfigurationCache("nebula.ospackage does not support configuration cache")
+    }
+
     void setVersion(@Nullable String version) {
         archiveVersion.convention(version)
         archiveVersion.set(version)
diff --git a/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingTask.groovy b/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingTask.groovy
index cc99dc04..a9f2fc27 100755
--- a/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingTask.groovy
+++ b/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingTask.groovy
@@ -62,6 +62,7 @@ abstract class SystemPackagingTask extends OsPackageAbstractArchiveTask {
         }
 
         configureDuplicateStrategy()
+        notCompatibleWithConfigurationCache("nebula.ospackage does not support configuration cache")
     }
 
     private void configureDuplicateStrategy() {
diff --git a/src/main/groovy/com/netflix/gradle/plugins/rpm/Rpm.groovy b/src/main/groovy/com/netflix/gradle/plugins/rpm/Rpm.groovy
index 9981434f..35583fa3 100755
--- a/src/main/groovy/com/netflix/gradle/plugins/rpm/Rpm.groovy
+++ b/src/main/groovy/com/netflix/gradle/plugins/rpm/Rpm.groovy
@@ -40,6 +40,7 @@ class Rpm extends SystemPackagingTask {
     Rpm() {
         super()
         archiveExtension.set 'rpm'
+        notCompatibleWithConfigurationCache("nebula.ospackage does not support configuration cache")
     }
 
     @Override
diff --git a/src/test/groovy/com/netflix/gradle/plugins/BaseIntegrationTestKitSpec.groovy b/src/test/groovy/com/netflix/gradle/plugins/BaseIntegrationTestKitSpec.groovy
index ce2f063e..bfd83599 100644
--- a/src/test/groovy/com/netflix/gradle/plugins/BaseIntegrationTestKitSpec.groovy
+++ b/src/test/groovy/com/netflix/gradle/plugins/BaseIntegrationTestKitSpec.groovy
@@ -4,6 +4,16 @@ import nebula.test.IntegrationTestKitSpec
 
 abstract class BaseIntegrationTestKitSpec extends IntegrationTestKitSpec {
     def setup() {
+        // Enable configuration cache :)
+        new File(projectDir, 'gradle.properties') << '''org.gradle.configuration-cache=true'''.stripIndent()
+    }
 
+    void disableConfigurationCache() {
+        def propertiesFile = new File(projectDir, 'gradle.properties')
+        if(propertiesFile.exists()) {
+            propertiesFile.delete()
+        }
+        propertiesFile.createNewFile()
+        propertiesFile << '''org.gradle.configuration-cache=false'''.stripIndent()
     }
 }
diff --git a/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationSpringBootPluginLauncherSpec.groovy b/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationSpringBootPluginLauncherSpec.groovy
index 0111f416..a199ce04 100644
--- a/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationSpringBootPluginLauncherSpec.groovy
+++ b/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationSpringBootPluginLauncherSpec.groovy
@@ -29,6 +29,10 @@ class OspackageApplicationSpringBootPluginLauncherSpec extends BaseIntegrationTe
     @Rule
     public final ProvideSystemProperty ignoreDeprecations = new ProvideSystemProperty("ignoreDeprecations", "true")
 
+    def setup() {
+        disableConfigurationCache() // org.gradle.api.tasks.application.CreateStartScript does not support config cache and it is used in Spring Boot plugin in these tests
+    }
+
     def 'plugin throws exception if spring-boot plugin not applied'() {
         buildFile << """
             plugins {