Enable configuration cache for more integration tests

Many of AGP integration tests were not using configuration
cache because of http://b/162074215. This CL enables configuration
cache, and disables the incompatble task for some tests.

Bug: n/a
Test: existing
Change-Id: I21e1a640a1ba160cff07c79b05f82dc47ff510bc
diff --git a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/CompileLibraryResourcesTest.kt b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/CompileLibraryResourcesTest.kt
index b869432..14e58b2 100644
--- a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/CompileLibraryResourcesTest.kt
+++ b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/CompileLibraryResourcesTest.kt
@@ -16,7 +16,6 @@
 
 package com.android.build.gradle.integration.application
 
-import com.android.build.gradle.integration.common.fixture.BaseGradleExecutor
 import com.android.build.gradle.integration.common.fixture.GradleTestProject
 import com.android.build.gradle.integration.common.fixture.app.MinimalSubProject
 import com.android.build.gradle.integration.common.fixture.app.MultiModuleTestProject
@@ -270,8 +269,8 @@
     @Test
     fun testIntegrationWithResourceShrinker() {
         project.executor().with(BooleanOption.PRECOMPILE_DEPENDENCIES_RESOURCES, true)
-            // http://b/149978740 and http://b/146208910
-            .withConfigurationCaching(BaseGradleExecutor.ConfigurationCaching.OFF)
+            // http://b/149978740
+            .with(BooleanOption.INCLUDE_DEPENDENCY_INFO_IN_APKS, false)
             .with(OptionalBooleanOption.INTERNAL_ONLY_ENABLE_R8, true)
             .run(":app:assembleRelease")
 
diff --git a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/CoreLibraryDesugarCachingTest.kt b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/CoreLibraryDesugarCachingTest.kt
index 4eb6d11..7ad97c0 100644
--- a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/CoreLibraryDesugarCachingTest.kt
+++ b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/CoreLibraryDesugarCachingTest.kt
@@ -16,12 +16,12 @@
 
 package com.android.build.gradle.integration.application
 
-import com.android.build.gradle.integration.common.fixture.BaseGradleExecutor
 import com.android.build.gradle.integration.common.fixture.DESUGAR_DEPENDENCY_VERSION
 import com.android.build.gradle.integration.common.fixture.GradleTestProject
 import com.android.build.gradle.integration.common.fixture.app.EmptyActivityProjectBuilder
 import com.android.build.gradle.integration.common.truth.TruthHelper.assertThat
 import com.android.build.gradle.integration.common.utils.TestFileUtils
+import com.android.build.gradle.options.BooleanOption
 import com.android.testutils.truth.PathSubject.assertThat
 import com.android.utils.FileUtils
 import org.junit.Before
@@ -60,8 +60,8 @@
         val buildCacheDir = File(project.projectDir.parent, GRADLE_BUILD_CACHE)
         FileUtils.deleteRecursivelyIfExists(buildCacheDir)
 
-        // http://b/149978740 and http://b/146208910
-        val executor = project.executor().withConfigurationCaching(BaseGradleExecutor.ConfigurationCaching.OFF)
+        // http://b/149978740
+        val executor = project.executor().with(BooleanOption.INCLUDE_DEPENDENCY_INFO_IN_APKS, false)
         executor
             .withArgument("--build-cache")
             .run("clean", ASSEMBLE_RELEASE)
diff --git a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/Java11WithKotlinCompileTest.kt b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/Java11WithKotlinCompileTest.kt
index 6d35a4c..47188df 100644
--- a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/Java11WithKotlinCompileTest.kt
+++ b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/Java11WithKotlinCompileTest.kt
@@ -16,7 +16,6 @@
 
 package com.android.build.gradle.integration.application
 
-import com.android.build.gradle.integration.common.fixture.BaseGradleExecutor
 import com.android.build.gradle.integration.common.fixture.GradleTestProject
 import com.android.build.gradle.integration.common.utils.TestFileUtils
 import com.android.testutils.TestUtils
@@ -35,9 +34,6 @@
     val project =
         GradleTestProject.builder()
             .fromTestProject("kotlinApp")
-            // b/158092419, b/146208910
-            .withConfigurationCaching(BaseGradleExecutor.ConfigurationCaching.WARN)
-            .addGradleProperties("org.gradle.unsafe.configuration-cache.max-problems=45")
             .create()
 
     @Before
diff --git a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/MinifyLibAndAppWithJavaResTest.java b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/MinifyLibAndAppWithJavaResTest.java
index eb05b49..24ce3fb 100644
--- a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/MinifyLibAndAppWithJavaResTest.java
+++ b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/MinifyLibAndAppWithJavaResTest.java
@@ -19,9 +19,9 @@
 import static com.android.build.gradle.integration.common.truth.TruthHelper.assertThat;
 import static org.junit.Assert.assertNotNull;
 
-import com.android.build.gradle.integration.common.fixture.BaseGradleExecutor;
 import com.android.build.gradle.integration.common.fixture.GradleTestProject;
 import com.android.build.gradle.integration.common.runner.FilterableParameterized;
+import com.android.build.gradle.options.BooleanOption;
 import com.android.build.gradle.options.OptionalBooleanOption;
 import com.android.builder.model.CodeShrinker;
 import com.android.testutils.apk.Apk;
@@ -73,8 +73,8 @@
                 .with(
                         OptionalBooleanOption.INTERNAL_ONLY_ENABLE_R8,
                         codeShrinker == CodeShrinker.R8)
-                // http://b/149978740 and http://b/146208910
-                .withConfigurationCaching(BaseGradleExecutor.ConfigurationCaching.OFF)
+                // http://b/149978740
+                .with(BooleanOption.INCLUDE_DEPENDENCY_INFO_IN_APKS, false)
                 .run(":app:assembleRelease");
         Apk releaseApk =
                 project.getSubproject("app").getApk(GradleTestProject.ApkType.RELEASE_SIGNED);
diff --git a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/ParentLibsTest.java b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/ParentLibsTest.java
index e19edaa..bf08902 100644
--- a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/ParentLibsTest.java
+++ b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/ParentLibsTest.java
@@ -17,7 +17,6 @@
 package com.android.build.gradle.integration.application;
 
 import com.android.SdkConstants;
-import com.android.build.gradle.integration.common.fixture.BaseGradleExecutor;
 import com.android.build.gradle.integration.common.fixture.GradleTestProject;
 import com.google.common.collect.ImmutableList;
 import com.google.common.io.Files;
@@ -34,8 +33,6 @@
     public GradleTestProject project =
             GradleTestProject.builder()
                     .fromTestProject("parentLibsTest")
-                    // http://b/146208910
-                    .withConfigurationCaching(BaseGradleExecutor.ConfigurationCaching.OFF)
                     .create();
 
     @Before
diff --git a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/PrivateResourceTest.java b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/PrivateResourceTest.java
index ad9dc3d..50cbbfe 100644
--- a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/PrivateResourceTest.java
+++ b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/PrivateResourceTest.java
@@ -16,8 +16,8 @@
 
 package com.android.build.gradle.integration.application;
 
-import com.android.build.gradle.integration.common.fixture.BaseGradleExecutor;
 import com.android.build.gradle.integration.common.fixture.GradleTestProject;
+import com.android.build.gradle.options.BooleanOption;
 import java.io.IOException;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -42,8 +42,8 @@
     @BeforeClass
     public static void setup() throws IOException, InterruptedException {
         project.executor()
-                // http://b/149978740 and http://b/146208910
-                .withConfigurationCaching(BaseGradleExecutor.ConfigurationCaching.OFF)
+                // http://b/149978740
+                .with(BooleanOption.INCLUDE_DEPENDENCY_INFO_IN_APKS, false)
                 .run("clean", "assemble");
     }
 
diff --git a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/ProjectNoJavaSourcesTest.kt b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/ProjectNoJavaSourcesTest.kt
index 2510044..1961681 100644
--- a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/ProjectNoJavaSourcesTest.kt
+++ b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/ProjectNoJavaSourcesTest.kt
@@ -16,10 +16,11 @@
 
 package com.android.build.gradle.integration.application
 
-import com.android.build.gradle.integration.common.fixture.BaseGradleExecutor
+import com.android.build.gradle.integration.common.fixture.GradleTaskExecutor
 import com.android.build.gradle.integration.common.fixture.GradleTestProject
 import com.android.build.gradle.integration.common.fixture.app.MinimalSubProject
 import com.android.build.gradle.integration.common.runner.FilterableParameterized
+import com.android.build.gradle.options.BooleanOption
 import com.google.common.truth.Truth
 import org.junit.Rule
 import org.junit.Test
@@ -27,7 +28,7 @@
 import org.junit.runners.Parameterized
 
 @RunWith(FilterableParameterized::class)
-class ProjectNoJavaSourcesTest(testProject: MinimalSubProject) {
+class ProjectNoJavaSourcesTest(val testProject: MinimalSubProject) {
 
     companion object {
         @Parameterized.Parameters
@@ -43,16 +44,11 @@
             android.buildFeatures.buildConfig = false
         """.trimIndent()
         )
-    ).also {
-        if (testProject.plugin == "com.android.application") {
-            // http://b/149978740 and http://b/146208910
-            it.withConfigurationCaching(BaseGradleExecutor.ConfigurationCaching.OFF)
-        }
-    }.create()
+    ).create()
 
     @Test
     fun testBuild() {
-        project.executor().run("assemble", "assembleDebugAndroidTest")
+        executor().run("assemble", "assembleDebugAndroidTest")
         Truth.assertThat(project.projectDir.walk().filter { it.extension == "java" }
             .toList()).named("list of Java sources").isEmpty()
     }
@@ -70,7 +66,7 @@
             }
         """.trimIndent()
         )
-        project.executor().run("assemble", "assembleDebugAndroidTest")
+        executor().run("assemble", "assembleDebugAndroidTest")
         Truth.assertThat(project.projectDir.walk().filter { it.extension == "java" }
             .toList()).named("list of Java sources").isEmpty()
     }
@@ -87,8 +83,17 @@
             }
         """.trimIndent()
         )
-        project.executor().run("assemble", "assembleDebugAndroidTest")
+        executor().run("assemble", "assembleDebugAndroidTest")
         Truth.assertThat(project.projectDir.walk().filter { it.extension == "java" }
             .toList()).named("list of Java sources").isEmpty()
     }
+
+    private fun executor() : GradleTaskExecutor {
+        return if (testProject.plugin == "com.android.application") {
+            // http://b/149978740
+             project.executor().with(BooleanOption.INCLUDE_DEPENDENCY_INFO_IN_APKS, false)
+        } else {
+             project.executor()
+        }
+    }
 }
diff --git a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/SigningTest.java b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/SigningTest.java
index ba0ffb2..1862c7b 100644
--- a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/SigningTest.java
+++ b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/application/SigningTest.java
@@ -250,8 +250,8 @@
                         .with(StringOption.IDE_SIGNING_KEY_PASSWORD, KEY_PASSWORD)
                         .with(OptionalBooleanOption.SIGNING_V1_ENABLED, true)
                         .with(OptionalBooleanOption.SIGNING_V2_ENABLED, true)
-                        // http://b/149978740 and http://b/146208910
-                        .withConfigurationCaching(BaseGradleExecutor.ConfigurationCaching.OFF)
+                        // http://b/149978740
+                        .with(BooleanOption.INCLUDE_DEPENDENCY_INFO_IN_APKS, false)
                         .run("assembleRelease");
         Apk apk = project.getApk(GradleTestProject.ApkType.RELEASE_SIGNED);
 
@@ -475,8 +475,8 @@
                 .with(StringOption.IDE_SIGNING_KEY_PASSWORD, KEY_PASSWORD)
                 .with(OptionalBooleanOption.SIGNING_V1_ENABLED, true)
                 .with(OptionalBooleanOption.SIGNING_V2_ENABLED, false)
-                // http://b/149978740 and http://b/146208910
-                .withConfigurationCaching(BaseGradleExecutor.ConfigurationCaching.OFF)
+                // http://b/149978740
+                .with(BooleanOption.INCLUDE_DEPENDENCY_INFO_IN_APKS, false)
                 .run("assembleRelease");
         Apk apk = project.getApk(GradleTestProject.ApkType.RELEASE_SIGNED);
 
@@ -498,8 +498,6 @@
                 .with(OptionalBooleanOption.SIGNING_V1_ENABLED, true)
                 .with(OptionalBooleanOption.SIGNING_V2_ENABLED, false)
                 .with(BooleanOption.INCLUDE_DEPENDENCY_INFO_IN_APKS, false)
-                // http://b/146208910
-                .withConfigurationCaching(BaseGradleExecutor.ConfigurationCaching.OFF)
                 .run("assembleRelease");
         Apk apk = project.getApk(GradleTestProject.ApkType.RELEASE_SIGNED);
 
@@ -520,8 +518,8 @@
                 .with(StringOption.IDE_SIGNING_KEY_ALIAS, ALIAS_NAME)
                 .with(StringOption.IDE_SIGNING_KEY_PASSWORD, KEY_PASSWORD)
                 .with(OptionalBooleanOption.SIGNING_V1_ENABLED, false)
-                // http://b/149978740 and http://b/146208910
-                .withConfigurationCaching(BaseGradleExecutor.ConfigurationCaching.OFF)
+                // http://b/149978740
+                .with(BooleanOption.INCLUDE_DEPENDENCY_INFO_IN_APKS, false)
                 .with(OptionalBooleanOption.SIGNING_V2_ENABLED, true)
                 .run("assembleRelease");
         Apk apk = project.getApk(GradleTestProject.ApkType.RELEASE_SIGNED);
@@ -659,8 +657,8 @@
                 .with(StringOption.IDE_SIGNING_STORE_PASSWORD, STORE_PASSWORD)
                 .with(StringOption.IDE_SIGNING_KEY_ALIAS, ALIAS_NAME)
                 .with(StringOption.IDE_SIGNING_KEY_PASSWORD, KEY_PASSWORD)
-                // http://b/149978740 and http://b/146208910
-                .withConfigurationCaching(BaseGradleExecutor.ConfigurationCaching.OFF)
+                // http://b/149978740
+                .with(BooleanOption.INCLUDE_DEPENDENCY_INFO_IN_APKS, false)
                 .run("assembleDebug");
         Apk apk = project.getApk(GradleTestProject.ApkType.DEBUG);
 
@@ -694,8 +692,8 @@
                 .with(StringOption.IDE_SIGNING_STORE_PASSWORD, STORE_PASSWORD)
                 .with(StringOption.IDE_SIGNING_KEY_ALIAS, ALIAS_NAME)
                 .with(StringOption.IDE_SIGNING_KEY_PASSWORD, KEY_PASSWORD)
-                // http://b/149978740 and http://b/146208910
-                .withConfigurationCaching(BaseGradleExecutor.ConfigurationCaching.OFF)
+                // http://b/149978740
+                .with(BooleanOption.INCLUDE_DEPENDENCY_INFO_IN_APKS, false)
                 .run("assembleDebug");
         Apk apk = project.getApk(GradleTestProject.ApkType.DEBUG);
 
@@ -733,8 +731,8 @@
                 .with(StringOption.IDE_SIGNING_KEY_PASSWORD, KEY_PASSWORD)
                 .with(OptionalBooleanOption.SIGNING_V1_ENABLED, true)
                 .with(OptionalBooleanOption.SIGNING_V2_ENABLED, true)
-                // http://b/149978740 and http://b/146208910
-                .withConfigurationCaching(BaseGradleExecutor.ConfigurationCaching.OFF)
+                // http://b/149978740
+                .with(BooleanOption.INCLUDE_DEPENDENCY_INFO_IN_APKS, false)
                 .run("assembleDebug");
         Apk apk = project.getApk(GradleTestProject.ApkType.DEBUG);
 
diff --git a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/bundle/DynamicAppSigningConfigTest.kt b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/bundle/DynamicAppSigningConfigTest.kt
index b88806b..336f38a 100644
--- a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/bundle/DynamicAppSigningConfigTest.kt
+++ b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/bundle/DynamicAppSigningConfigTest.kt
@@ -17,17 +17,14 @@
 package com.android.build.gradle.integration.bundle
 
 import com.android.build.gradle.integration.application.SigningTest
-import com.android.build.gradle.integration.common.fixture.BaseGradleExecutor
 import com.android.build.gradle.integration.common.fixture.GradleTestProject
 import com.android.build.gradle.integration.common.truth.ModelContainerSubject.assertThat
 import com.android.build.gradle.integration.common.truth.TruthHelper.assertThat
-import com.android.build.gradle.internal.scope.InternalArtifactType
-import com.android.build.gradle.internal.scope.getOutputDir
+import com.android.build.gradle.options.BooleanOption
 import com.android.build.gradle.options.OptionalBooleanOption
 import com.android.build.gradle.options.StringOption
 import com.android.builder.errors.IssueReporter
 import com.android.builder.model.SyncIssue
-import com.android.testutils.truth.PathSubject.assertThat
 import com.google.common.io.Resources
 import org.junit.Rule
 import org.junit.Test
@@ -86,8 +83,8 @@
 
         val result =
             project.executor()
-                // http://b/146208910
-                .withConfigurationCaching(BaseGradleExecutor.ConfigurationCaching.NONE)
+                // http://b/149978740
+                .with(BooleanOption.INCLUDE_DEPENDENCY_INFO_IN_APKS, false)
                 .with(StringOption.IDE_SIGNING_STORE_FILE, keystoreFile.path)
                 .with(StringOption.IDE_SIGNING_STORE_PASSWORD, STORE_PASSWORD)
                 .with(StringOption.IDE_SIGNING_KEY_ALIAS, ALIAS_NAME)
@@ -138,8 +135,6 @@
         )
 
         project.executor()
-            // http://b/146208910
-            .withConfigurationCaching(BaseGradleExecutor.ConfigurationCaching.NONE)
             .with(StringOption.IDE_SIGNING_STORE_FILE, keystoreFile.path)
             .with(StringOption.IDE_SIGNING_STORE_PASSWORD, STORE_PASSWORD)
             .with(StringOption.IDE_SIGNING_KEY_ALIAS, ALIAS_NAME)
diff --git a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/library/AttrOrderTest.java b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/library/AttrOrderTest.java
index e793f71..862d613 100644
--- a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/library/AttrOrderTest.java
+++ b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/library/AttrOrderTest.java
@@ -16,7 +16,6 @@
 
 package com.android.build.gradle.integration.library;
 
-import com.android.build.gradle.integration.common.fixture.BaseGradleExecutor;
 import com.android.build.gradle.integration.common.fixture.GradleTestProject;
 import java.io.IOException;
 import org.junit.AfterClass;
@@ -42,9 +41,6 @@
 
     @Test
     public void lint() throws IOException, InterruptedException {
-        // http://b/146208910
-        project.executor()
-                .withConfigurationCaching(BaseGradleExecutor.ConfigurationCaching.OFF)
-                .run("lint");
+        project.executor().run("lint");
     }
 }
diff --git a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/library/MultiprojectTest.java b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/library/MultiprojectTest.java
index 1372f07..f72f9ff 100644
--- a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/library/MultiprojectTest.java
+++ b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/library/MultiprojectTest.java
@@ -16,7 +16,6 @@
 
 package com.android.build.gradle.integration.library;
 
-import com.android.build.gradle.integration.common.fixture.BaseGradleExecutor;
 import com.android.build.gradle.integration.common.fixture.GradleTestProject;
 import java.io.IOException;
 import org.junit.After;
@@ -44,9 +43,6 @@
 
     @Test
     public void lint() throws IOException, InterruptedException {
-        // http://b/146208910
-        project.executor()
-                .withConfigurationCaching(BaseGradleExecutor.ConfigurationCaching.NONE)
-                .run("lint");
+        project.executor().run("lint");
     }
 }
diff --git a/build-system/integration-test/databinding/src/test/java/com/android/build/gradle/integration/databinding/DataBindingWithDynamicFeaturesAppTest.kt b/build-system/integration-test/databinding/src/test/java/com/android/build/gradle/integration/databinding/DataBindingWithDynamicFeaturesAppTest.kt
index 7df7950..69b8708 100644
--- a/build-system/integration-test/databinding/src/test/java/com/android/build/gradle/integration/databinding/DataBindingWithDynamicFeaturesAppTest.kt
+++ b/build-system/integration-test/databinding/src/test/java/com/android/build/gradle/integration/databinding/DataBindingWithDynamicFeaturesAppTest.kt
@@ -16,7 +16,6 @@
 
 package com.android.build.gradle.integration.databinding
 
-import com.android.build.gradle.integration.common.fixture.BaseGradleExecutor
 import com.android.build.gradle.integration.common.fixture.GradleTestProject
 import com.android.build.gradle.integration.common.runner.FilterableParameterized
 import com.android.build.gradle.options.BooleanOption
@@ -55,8 +54,8 @@
     @Test
     fun app() {
         project.executor()
-             // disable explicitly - http://b/146208910, http://b/149978740
-            .withConfigurationCaching(BaseGradleExecutor.ConfigurationCaching.NONE)
+            // http://b/149978740
+            .with(BooleanOption.INCLUDE_DEPENDENCY_INFO_IN_APKS, false)
             .run(":app:assemble")
     }