Enable desugar libary tests in new gradle setup

Bug: b/270105162
Bug: b/291198792
Change-Id: Ia3e3e1fb4d26e21f6e2fcd20f944522fef5e304f
diff --git a/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt b/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt
index f04b5c3..e396985 100644
--- a/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt
+++ b/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt
@@ -367,6 +367,10 @@
     "coreLambdaStubs",
     Paths.get("third_party", "core-lambda-stubs").toFile(),
     Paths.get("third_party", "core-lambda-stubs.tar.gz.sha1").toFile())
+  val customConversion = ThirdPartyDependency(
+    "customConversion",
+    Paths.get("third_party", "openjdk", "custom_conversion").toFile(),
+    Paths.get("third_party", "openjdk", "custom_conversion.tar.gz.sha1").toFile())
   val dagger = ThirdPartyDependency(
     "dagger",
     Paths.get("third_party", "dagger", "2.41").toFile(),
@@ -624,3 +628,48 @@
       Paths.get("third_party", "gmscore", "${it}.tar.gz.sha1").toFile(),
       DependencyType.X20)}
 }
+
+val testRuntimeDependencies = (listOf(
+  ThirdPartyDeps.aapt2,
+  ThirdPartyDeps.artTests,
+  ThirdPartyDeps.artTestsLegacy,
+  ThirdPartyDeps.compilerApi,
+  ThirdPartyDeps.coreLambdaStubs,
+  ThirdPartyDeps.customConversion,
+  ThirdPartyDeps.dagger,
+  ThirdPartyDeps.desugarJdkLibs,
+  ThirdPartyDeps.desugarJdkLibsLegacy,
+  ThirdPartyDeps.desugarJdkLibs11,
+  ThirdPartyDeps.examplesAndroidOLegacy,
+  ThirdPartyDeps.gson,
+  ThirdPartyDeps.jacoco,
+  ThirdPartyDeps.java8Runtime,
+  ThirdPartyDeps.jdk11Test,
+  ThirdPartyDeps.jsr223,
+  ThirdPartyDeps.multidex,
+  ThirdPartyDeps.r8,
+  ThirdPartyDeps.r8Mappings,
+  ThirdPartyDeps.r8v2_0_74,
+  ThirdPartyDeps.r8v3_2_54,
+  ThirdPartyDeps.retraceBenchmark,
+  ThirdPartyDeps.retraceBinaryCompatibility,
+  ThirdPartyDeps.rhino,
+  ThirdPartyDeps.rhinoAndroid,
+  ThirdPartyDeps.smali,
+  ThirdPartyDeps.tivi)
+    + ThirdPartyDeps.androidJars
+    + ThirdPartyDeps.androidVMs
+    + ThirdPartyDeps.desugarLibraryReleases
+    + ThirdPartyDeps.jdks
+    + ThirdPartyDeps.kotlinCompilers
+    + ThirdPartyDeps.proguards)
+
+val testRuntimeInternalDependencies = (listOf(
+  ThirdPartyDeps.clank,
+  ThirdPartyDeps.framework,
+  ThirdPartyDeps.nest,
+  ThirdPartyDeps.proto,
+  ThirdPartyDeps.protobufLite,
+  ThirdPartyDeps.retraceInternal)
+  + ThirdPartyDeps.internalIssues
+  + ThirdPartyDeps.gmscoreVersions)
\ No newline at end of file
diff --git a/d8_r8/test/build.gradle.kts b/d8_r8/test/build.gradle.kts
index ceafdfa..6cc61e5 100644
--- a/d8_r8/test/build.gradle.kts
+++ b/d8_r8/test/build.gradle.kts
@@ -28,6 +28,14 @@
 val java8TestsDepsJarTask = projectTask("tests_java_8", "depsJar")
 val bootstrapTestsDepsJarTask = projectTask("tests_bootstrap", "depsJar")
 
+val thirdPartyRuntimeDependenciesTask = ensureThirdPartyDependencies(
+  "runtimeDeps",
+  testRuntimeDependencies)
+
+val thirdPartyRuntimeInternalDependenciesTask = ensureThirdPartyDependencies(
+  "runtimeInternalDeps",
+  testRuntimeInternalDependencies)
+
 tasks {
   withType<Exec> {
     doFirst {
@@ -185,6 +193,7 @@
     dependsOn(allTestsJarRelocated)
     dependsOn(r8WithRelocatedDepsTask)
     dependsOn(allTestWithApplyMappingProguardConfiguration)
+    dependsOn(thirdPartyRuntimeDependenciesTask)
     val r8 = r8WithRelocatedDepsTask.outputs.files.singleFile
     val allTests = allTestsJarRelocated.get().outputs.files.singleFile
     val pgConf = allTestWithApplyMappingProguardConfiguration.get().outputs.files.singleFile
@@ -258,6 +267,10 @@
     dependsOn(r8LibWithRelocatedDeps)
     dependsOn(unzipTests)
     dependsOn(unzipRewrittenTests)
+    dependsOn(thirdPartyRuntimeDependenciesTask)
+    if (!project.hasProperty("no_internal")) {
+      dependsOn(thirdPartyRuntimeInternalDependenciesTask)
+    }
     val r8LibJar = r8LibWithRelocatedDeps.get().outputs.files.singleFile
     this.configure(isR8Lib = true, r8Jar = r8LibJar)
 
@@ -277,22 +290,5 @@
     // TODO(b/270105162): This should change if running with retrace lib/r8lib.
     systemProperty("RETRACE_RUNTIME_PATH", r8LibJar)
     systemProperty("R8_DEPS", mainDepsJarTask.outputs.files.singleFile)
-
-    // TODO(b/291198792): Remove this exclusion when desugared library runs correctly.
-    exclude("com/android/tools/r8/desugar/desugaredlibrary/**")
-    exclude("com/android/tools/r8/desugar/InvokeSuperToRewrittenDefaultMethodTest**")
-    exclude("com/android/tools/r8/desugar/InvokeSuperToEmulatedDefaultMethodTest**")
-    exclude("com/android/tools/r8/desugar/backports/ThreadLocalBackportWithDesugaredLibraryTest**")
-    exclude("com/android/tools/r8/L8CommandTest**")
-    exclude("com/android/tools/r8/MarkersTest**")
-    exclude("com/android/tools/r8/apimodel/ApiModelDesugaredLibraryReferenceTest**")
-    exclude("com/android/tools/r8/apimodel/ApiModelNoDesugaredLibraryReferenceTest**")
-    exclude("com/android/tools/r8/benchmarks/desugaredlib/**")
-    exclude("com/android/tools/r8/classmerging/vertical/ForceInlineConstructorWithRetargetedLibMemberTest**")
-    exclude("com/android/tools/r8/classmerging/vertical/ForceInlineConstructorWithRetargetedLibMemberTest**")
-    exclude("com/android/tools/r8/ir/optimize/inliner/InlineMethodWithRetargetedLibMemberTest**")
-    exclude("com/android/tools/r8/profile/art/DesugaredLibraryArtProfileRewritingTest**")
-    exclude("com/android/tools/r8/profile/art/dump/DumpArtProfileProvidersTest**")
-    exclude("com/android/tools/r8/shaking/serviceloader/ServiceLoaderDesugaredLibraryTest**")
  }
 }
\ No newline at end of file
diff --git a/d8_r8/test_modules/tests_java_8/build.gradle.kts b/d8_r8/test_modules/tests_java_8/build.gradle.kts
index dd1bfbd..f87553a 100644
--- a/d8_r8/test_modules/tests_java_8/build.gradle.kts
+++ b/d8_r8/test_modules/tests_java_8/build.gradle.kts
@@ -68,52 +68,11 @@
 
 val thirdPartyRuntimeDependenciesTask = ensureThirdPartyDependencies(
   "runtimeDeps",
-  listOf(
-    ThirdPartyDeps.aapt2,
-    ThirdPartyDeps.artTests,
-    ThirdPartyDeps.artTestsLegacy,
-    ThirdPartyDeps.compilerApi,
-    ThirdPartyDeps.coreLambdaStubs,
-    ThirdPartyDeps.dagger,
-    ThirdPartyDeps.desugarJdkLibs,
-    ThirdPartyDeps.desugarJdkLibsLegacy,
-    ThirdPartyDeps.desugarJdkLibs11,
-    ThirdPartyDeps.examplesAndroidOLegacy,
-    ThirdPartyDeps.gson,
-    ThirdPartyDeps.jacoco,
-    ThirdPartyDeps.java8Runtime,
-    ThirdPartyDeps.jdk11Test,
-    ThirdPartyDeps.jsr223,
-    ThirdPartyDeps.multidex,
-    ThirdPartyDeps.r8,
-    ThirdPartyDeps.r8Mappings,
-    ThirdPartyDeps.r8v2_0_74,
-    ThirdPartyDeps.r8v3_2_54,
-    ThirdPartyDeps.retraceBenchmark,
-    ThirdPartyDeps.retraceBinaryCompatibility,
-    ThirdPartyDeps.rhino,
-    ThirdPartyDeps.rhinoAndroid,
-    ThirdPartyDeps.smali,
-    ThirdPartyDeps.tivi)
-    + ThirdPartyDeps.androidJars
-    + ThirdPartyDeps.androidVMs
-    + ThirdPartyDeps.desugarLibraryReleases
-    + ThirdPartyDeps.jdks
-    + ThirdPartyDeps.kotlinCompilers
-    + ThirdPartyDeps.proguards)
+  testRuntimeDependencies)
 
 val thirdPartyRuntimeInternalDependenciesTask = ensureThirdPartyDependencies(
   "runtimeInternalDeps",
-  listOf(
-    ThirdPartyDeps.clank,
-    ThirdPartyDeps.framework,
-    ThirdPartyDeps.nest,
-    ThirdPartyDeps.proto,
-    ThirdPartyDeps.protobufLite,
-    ThirdPartyDeps.retraceInternal)
-    + ThirdPartyDeps.internalIssues
-    + ThirdPartyDeps.gmscoreVersions
-)
+  testRuntimeInternalDependencies)
 
 val sourceSetDependenciesTasks = arrayOf(
   projectTask("tests_java_examples", getExampleJarsTaskName("examples")),
@@ -179,22 +138,6 @@
       mainCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0] +
         File.pathSeparator + mainDepsJarTask.outputs.files.singleFile)
     systemProperty("R8_DEPS", mainDepsJarTask.outputs.files.singleFile)
-
-    // TODO(b/291198792): Remove this exclusion when desugared library runs correctly.
-    exclude("com/android/tools/r8/desugar/desugaredlibrary/**")
-    exclude("com/android/tools/r8/desugar/InvokeSuperToRewrittenDefaultMethodTest**")
-    exclude("com/android/tools/r8/desugar/InvokeSuperToEmulatedDefaultMethodTest**")
-    exclude("com/android/tools/r8/desugar/backports/ThreadLocalBackportWithDesugaredLibraryTest**")
-    exclude("com/android/tools/r8/L8CommandTest**")
-    exclude("com/android/tools/r8/MarkersTest**")
-    exclude("com/android/tools/r8/apimodel/ApiModelDesugaredLibraryReferenceTest**")
-    exclude("com/android/tools/r8/apimodel/ApiModelNoDesugaredLibraryReferenceTest**")
-    exclude("com/android/tools/r8/benchmarks/desugaredlib/**")
-    exclude("com/android/tools/r8/classmerging/vertical/ForceInlineConstructorWithRetargetedLibMemberTest**")
-    exclude("com/android/tools/r8/classmerging/vertical/ForceInlineConstructorWithRetargetedLibMemberTest**")
-    exclude("com/android/tools/r8/ir/optimize/inliner/InlineMethodWithRetargetedLibMemberTest**")
-    exclude("com/android/tools/r8/profile/art/DesugaredLibraryArtProfileRewritingTest**")
-    exclude("com/android/tools/r8/profile/art/dump/DumpArtProfileProvidersTest**")
   }
 
   val testJar by registering(Jar::class) {