Add tests for Android V and desugared library

- R8 fixes some cases by rebinding, which should be fine
- JDK8 desugared library simply won't work with android.jar from V

Change-Id: I8d9803032e85f8858f7de315239b1df774fd7c4d
diff --git a/d8_r8/test_modules/tests_java_21/build.gradle.kts b/d8_r8/test_modules/tests_java_21/build.gradle.kts
index 9d71db8..ecbcef1 100644
--- a/d8_r8/test_modules/tests_java_21/build.gradle.kts
+++ b/d8_r8/test_modules/tests_java_21/build.gradle.kts
@@ -21,7 +21,15 @@
   targetCompatibility = JavaVersion.VERSION_21
 }
 
-dependencies { }
+val testbaseJavaCompileTask = projectTask("testbase", "compileJava")
+val testbaseDepsJarTask = projectTask("testbase", "depsJar")
+val mainCompileTask = projectTask("main", "compileJava")
+
+dependencies {
+  implementation(files(testbaseDepsJarTask.outputs.files.getSingleFile()))
+  implementation(testbaseJavaCompileTask.outputs.files)
+  implementation(mainCompileTask.outputs.files)
+}
 
 // We just need to register the examples jars for it to be referenced by other modules.
 val buildExampleJars = buildExampleJars("examplesJava21")
@@ -33,5 +41,17 @@
     options.forkOptions.memoryMaximumSize = "3g"
     options.forkOptions.executable = getCompilerPath(Jdk.JDK_21)
   }
+
+  withType<Test> {
+    TestingState.setUpTestingState(this)
+    javaLauncher = getJavaLauncher(Jdk.JDK_21)
+    systemProperty("TEST_DATA_LOCATION",
+      // This should be
+      //   layout.buildDirectory.dir("classes/java/test").get().toString()
+      // once the use of 'buildExampleJars' above is removed.
+                   getRoot().resolveAll("build", "test", "examplesJava21", "classes"))
+    systemProperty("TESTBASE_DATA_LOCATION",
+                   testbaseJavaCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0])
+  }
 }