Reapply "Move examples and examplesAndroidX out into third_party"

This reverts commit b474c0cc2c7f38849927d52754c725ba02d199dc.

Change-Id: I33612f99e92a2a4e54b9e467e85c0feae2f6a58c
diff --git a/.gitignore b/.gitignore
index 4496e10..4008f3e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -96,8 +96,20 @@
 third_party/dependencies_new.tar.gz
 third_party/desugar/desugar_*.tar.gz
 third_party/desugar/desugar_*/
+third_party/examples
+third_party/examples.tar.gz
+third_party/examplesAndroidN
+third_party/examplesAndroidN.tar.gz
+third_party/examplesAndroidO
+third_party/examplesAndroidO.tar.gz
+third_party/examplesAndroidOGenerated
+third_party/examplesAndroidOGenerated.tar.gz
 third_party/examplesAndroidOLegacy
 third_party/examplesAndroidOLegacy.tar.gz
+third_party/examplesAndroidP
+third_party/examplesAndroidP.tar.gz
+third_party/examplesAndroidPGenerated
+third_party/examplesAndroidPGenerated.tar.gz
 third_party/framework
 third_party/framework.tar.gz
 third_party/gmail/*
@@ -155,6 +167,8 @@
 third_party/kotlin/kotlin-compiler-dev
 third_party/kotlinx-coroutines-1.3.6.tar.gz
 third_party/kotlinx-coroutines-1.3.6
+third_party/kotlinR8TestResources
+third_party/kotlinR8TestResources.tar.gz
 third_party/multidex
 third_party/multidex.tar.gz
 third_party/nest/*
diff --git a/build.gradle b/build.gradle
index 8db5b0d..31651fa 100644
--- a/build.gradle
+++ b/build.gradle
@@ -105,12 +105,6 @@
         }
         output.resourcesDir = 'build/classes/debugTestResourcesJava8'
     }
-    examples {
-        java {
-            srcDirs = ['src/test/examples']
-        }
-        output.resourcesDir = 'build/classes/examples'
-    }
     examplesJava9 {
         java {
             srcDirs = ['src/test/examplesJava9']
@@ -136,30 +130,6 @@
             srcDirs = ['src/test/examplesJava20']
         }
     }
-    examplesAndroidN {
-        java {
-            srcDirs = ['src/test/examplesAndroidN']
-        }
-        output.resourcesDir = 'build/classes/examplesAndroidN'
-    }
-    examplesAndroidO {
-        java {
-            srcDirs = ['src/test/examplesAndroidO']
-        }
-        output.resourcesDir = 'build/classes/examplesAndroidO'
-    }
-    examplesAndroidP {
-        java {
-            srcDirs = ['src/test/examplesAndroidP']
-        }
-        output.resourcesDir = 'build/classes/examplesAndroidP'
-    }
-    kotlinR8TestResources {
-        java {
-            srcDirs = ['src/test/kotlinR8TestResources']
-        }
-        output.resourcesDir = 'build/classes/kotlinR8TestResources'
-    }
     keepanno {
         java {
             srcDirs = ['src/keepanno/java']
@@ -225,7 +195,6 @@
     main17Implementation group: 'org.ow2.asm', name: 'asm-analysis', version: asmVersion
     main17Implementation group: 'org.ow2.asm', name: 'asm-util', version: asmVersion
 
-    testCompile sourceSets.examples.output
     testCompile "junit:junit:$junitVersion"
     testCompile "com.google.guava:guava:$guavaVersion"
     testCompile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
@@ -242,18 +211,8 @@
     testCompile group: 'it.unimi.dsi', name: 'fastutil', version: fastutilVersion
     testCompile group: 'org.javassist', name: 'javassist', version: javassistVersion
 
-    examplesAndroidOCompile group: 'org.ow2.asm', name: 'asm', version: asmVersion
-    examplesAndroidOCompile files("third_party/android_jar/lib-v26/android.jar")
-    examplesAndroidOCompile files("third_party/examplesAndroidOLegacy")
-
-    examplesAndroidPCompile group: 'org.ow2.asm', name: 'asm', version: asmVersion
-    // Import Guava for @Nullable annotation
-    examplesCompile "com.google.guava:guava:$guavaVersion"
-    examplesCompile "junit:junit:$junitVersion"
-    examplesCompile "org.mockito:mockito-core:$mockitoVersion"
     apiUsageSampleCompile sourceSets.main.output
     apiUsageSampleCompile "com.google.guava:guava:$guavaVersion"
-    kotlinR8TestResourcesCompileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
     errorprone("com.google.errorprone:error_prone_core:$errorproneVersion")
 
     keepannoCompile group: 'org.ow2.asm', name: 'asm', version: asmVersion
@@ -307,7 +266,13 @@
                 "dagger/2.41",
                 "dart-sdk",
                 "ddmlib",
+                "examples",
+                "examplesAndroidN",
+                "examplesAndroidO",
                 "examplesAndroidOLegacy",
+                "examplesAndroidOGenerated",
+                "examplesAndroidP",
+                "examplesAndroidPGenerated",
                 "gradle/gradle",
                 "google/google-java-format/1.14.0",
                 "google-java-format",
@@ -329,6 +294,7 @@
                 "kotlin/kotlin-compiler-1.7.0",
                 "kotlin/kotlin-compiler-1.8.0",
                 "kotlinx-coroutines-1.3.6",
+                "kotlinR8TestResources",
                 "multidex",
                 "openjdk/custom_conversion",
                 "openjdk/openjdk-rt-1.8",
@@ -1133,211 +1099,6 @@
     dependsOn buildR8ApiUsageSample
 }
 
-// Proto lite generated code yields warnings when compiling with javac.
-// We change the options passed to javac to ignore it.
-compileExamplesJava.options.compilerArgs = ["-Xlint:none"]
-
-
-task buildExampleJars {
-    def examplesDir = file("src/test/examples")
-    task extractExamplesRuntime(type: Sync) {
-        dependsOn configurations.examplesRuntime
-        from { configurations.examplesRuntime.collect { zipTree(it) } }
-        include "**/*.class"
-        includeEmptyDirs false
-        into "$buildDir/runtime/examples/"
-    }
-
-    task "copy_examples_resources"(type: org.gradle.api.tasks.Copy) {
-        from examplesDir
-        exclude "**/*.java"
-        exclude "**/keep-rules*.txt"
-        into file("build/test/examples/classes")
-    }
-
-    task "compile_examples"(type: JavaCompile) {
-        dependsOn "copy_examples_resources"
-        source examplesDir
-        include "**/*.java"
-        destinationDir = file("build/test/examples/classes")
-        classpath = sourceSets.examples.compileClasspath
-        sourceCompatibility = JavaVersion.VERSION_1_7
-        targetCompatibility = JavaVersion.VERSION_1_7
-        options.compilerArgs = ["-g:source,lines", "-Xlint:none"]
-    }
-    task "compile_examples_debuginfo_all"(type: JavaCompile) {
-        source examplesDir
-        include "**/*.java"
-        destinationDir = file("build/test/examples/classes_debuginfo_all")
-        classpath = sourceSets.examples.compileClasspath
-        sourceCompatibility = JavaVersion.VERSION_1_7
-        targetCompatibility = JavaVersion.VERSION_1_7
-        options.compilerArgs = ["-g", "-Xlint:none"]
-    }
-    task "compile_examples_debuginfo_none"(type: JavaCompile) {
-        source examplesDir
-        include "**/*.java"
-        destinationDir = file("build/test/examples/classes_debuginfo_none")
-        classpath = sourceSets.examples.compileClasspath
-        sourceCompatibility = JavaVersion.VERSION_1_7
-        targetCompatibility = JavaVersion.VERSION_1_7
-        options.compilerArgs = ["-g:none", "-Xlint:none"]
-    }
-    examplesDir.eachDir { dir ->
-        def name = dir.getName();
-        def exampleOutputDir = file("build/test/examples");
-        def jarName = "${name}.jar"
-        dependsOn "jar_example_${name}"
-        dependsOn "jar_example_${name}_debuginfo_all"
-        dependsOn "jar_example_${name}_debuginfo_none"
-        dependsOn "extractExamplesRuntime"
-        def runtimeDependencies = copySpec { }
-        task "jar_example_${name}"(type: Jar, dependsOn: "compile_examples") {
-            archiveName = "${name}.jar"
-            destinationDir = exampleOutputDir
-            from "build/test/examples/classes"
-            include name + "/**/*"
-            with runtimeDependencies
-            includeEmptyDirs true
-        }
-        task "jar_example_${name}_debuginfo_all"(type: Jar, dependsOn: "compile_examples_debuginfo_all") {
-            archiveName = "${name}_debuginfo_all.jar"
-            destinationDir = exampleOutputDir
-            from "build/test/examples/classes_debuginfo_all"
-            include name + "/**/*.class"
-            with runtimeDependencies
-            includeEmptyDirs false
-        }
-        task "jar_example_${name}_debuginfo_none"(type: Jar, dependsOn: "compile_examples_debuginfo_none") {
-            archiveName = "${name}_debuginfo_none.jar"
-            destinationDir = exampleOutputDir
-            from "build/test/examples/classes_debuginfo_none"
-            include name + "/**/*.class"
-            with runtimeDependencies
-            includeEmptyDirs false
-        }
-    }
-}
-
-task buildExampleAndroidNJars {
-    dependsOn downloadDeps
-    def examplesDir = file("src/test/examplesAndroidN")
-    task "compile_examplesAndroidN"(type: JavaCompile) {
-        source = fileTree(dir: examplesDir, include: '**/*.java')
-        destinationDir = file("build/test/examplesAndroidN/classes")
-        classpath = sourceSets.main.compileClasspath
-        sourceCompatibility = JavaVersion.VERSION_1_8
-        targetCompatibility = JavaVersion.VERSION_1_8
-        options.compilerArgs += ["-Xlint:-options"]
-    }
-    examplesDir.eachDir { dir ->
-        def name = dir.getName();
-        def exampleOutputDir = file("build/test/examplesAndroidN");
-        def jarName = "${name}.jar"
-        dependsOn "jar_examplesAndroidN_${name}"
-        task "jar_examplesAndroidN_${name}"(type: Jar, dependsOn: "compile_examplesAndroidN") {
-            archiveName = jarName
-            destinationDir = exampleOutputDir
-            from "build/test/examplesAndroidN/classes"
-            include "**/" + name + "/**/*.class"
-        }
-    }
-}
-
-
-task buildExampleAndroidOJars {
-    dependsOn downloadDeps
-    def examplesDir = file("src/test/examplesAndroidO")
-    // Compiling the rest of the files as Java 1.8 code.
-    task "compile_examplesAndroidO"(type: JavaCompile) {
-        source = fileTree(dir: examplesDir, include: '**/*.java', exclude: '**/legacy/**/*.java')
-        destinationDir = file("build/test/examplesAndroidO/classes")
-        classpath = sourceSets.main.compileClasspath
-        classpath += files("build/test/examplesAndroidOLegacy/classes")
-        classpath += files("third_party/android_jar/lib-v26/android.jar")
-        classpath += files("third_party/examplesAndroidOLegacy")
-        sourceCompatibility = JavaVersion.VERSION_1_8
-        targetCompatibility = JavaVersion.VERSION_1_8
-        options.compilerArgs += ["-Xlint:-options", "-parameters"]
-    }
-    examplesDir.eachDir { dir ->
-        def name = dir.getName();
-        def destinationDir = file("build/test/examplesAndroidO/classes");
-        if (file("src/test/examplesAndroidO/" + name + "/TestGenerator.java").isFile()) {
-            task "generate_examplesAndroidO_${name}"(type: JavaExec,
-                    dependsOn: "compile_examplesAndroidO") {
-                main = name + ".TestGenerator"
-                classpath = files(destinationDir, sourceSets.main.compileClasspath)
-                args destinationDir, file("build/test/examplesAndroidO/classes/${name}").toString()
-            }
-        } else {
-            task "generate_examplesAndroidO_${name}" () {}
-        }
-    }
-    examplesDir.eachDir { dir ->
-        def name = dir.getName();
-        def exampleOutputDir = file("build/test/examplesAndroidO");
-        def jarName = "${name}.jar"
-        dependsOn "jar_examplesAndroidO_${name}"
-        task "jar_examplesAndroidO_${name}"(type: Jar, dependsOn: ["compile_examplesAndroidO",
-                "generate_examplesAndroidO_${name}"]) {
-            archiveName = jarName
-            destinationDir = exampleOutputDir
-            from "build/test/examplesAndroidO/classes"        // Java 1.8 classes
-            from "build/test/examplesAndroidOLegacy/classes"  // Java 1.6 classes
-            include "**/" + name + "/**/*.class"
-            // Do not include generator into the test runtime jar, it is not useful.
-            // Otherwise, shrinking will need ASM jars.
-            exclude "**/TestGenerator*"
-        }
-    }
-}
-
-task buildExampleAndroidPJars {
-    dependsOn downloadDeps
-    def examplesDir = file("src/test/examplesAndroidP")
-
-    task "compile_examplesAndroidP"(type: JavaCompile) {
-        source = fileTree(dir: examplesDir, include: '**/*.java')
-        destinationDir = file("build/test/examplesAndroidP/classes")
-        classpath = sourceSets.main.compileClasspath
-        sourceCompatibility = JavaVersion.VERSION_1_8
-        targetCompatibility = JavaVersion.VERSION_1_8
-        options.compilerArgs += ["-Xlint:-options"]
-    }
-    examplesDir.eachDir { dir ->
-        def name = dir.getName();
-        def destinationDir = file("build/test/examplesAndroidP/classes");
-        if (file("src/test/examplesAndroidP/" + name + "/TestGenerator.java").isFile()) {
-            task "generate_examplesAndroidP_${name}"(type: JavaExec,
-                    dependsOn: "compile_examplesAndroidP") {
-                main = name + ".TestGenerator"
-                classpath = files(destinationDir.toString(), sourceSets.main.compileClasspath)
-                args destinationDir, file("build/test/examplesAndroidP/classes/${name}").toString()
-            }
-        } else {
-            task "generate_examplesAndroidP_${name}" () {}
-        }
-    }
-    examplesDir.eachDir { dir ->
-        def name = dir.getName();
-        def exampleOutputDir = file("build/test/examplesAndroidP");
-        def jarName = "${name}.jar"
-        dependsOn "jar_examplesAndroidP_${name}"
-        task "jar_examplesAndroidP_${name}"(type: Jar,
-                dependsOn: ["compile_examplesAndroidP",
-                            "generate_examplesAndroidP_${name}"]) {
-            archiveName = jarName
-            destinationDir = exampleOutputDir
-            from "build/test/examplesAndroidP/classes"  // Java 1.8 classes
-            include "**/" + name + "/**/*.class"
-            // Do not include generator into the test runtime jar, it is not useful.
-            // Otherwise, shrinking will need ASM jars.
-            exclude "**/TestGenerator*"
-        }
-    }
-}
-
 def buildExampleJarsCreateTask(javaVersion, sourceSet) {
     return tasks.create("buildExample${javaVersion}Jars") {
         def examplesDir = file("src/test/examples${javaVersion}")
@@ -1376,32 +1137,6 @@
     })
 }
 
-task buildKotlinR8TestResources {
-    def examplesDir = file("src/test/kotlinR8TestResources")
-    examplesDir.eachDir { dir ->
-        def name = dir.getName()
-        def taskName = "jar_kotlinR8TestResources_${name}"
-        def javaOutput = "build/test/kotlinR8TestResources/${name}/java"
-        def javaOutputJarName = "${name}.jar"
-        def javaOutputJarDir = "build/test/kotlinR8TestResources"
-        task "${taskName}Java"(type: JavaCompile) {
-            source = fileTree(dir: file("${examplesDir}/${name}"), include: '**/*.java')
-            destinationDir = file(javaOutput)
-            classpath = sourceSets.main.compileClasspath
-            sourceCompatibility = JavaVersion.VERSION_1_8
-            targetCompatibility = JavaVersion.VERSION_1_8
-            options.compilerArgs += ["-g", "-Xlint:-options"]
-        }
-        task "${taskName}JavaJar"(type: Jar, dependsOn: "${taskName}Java") {
-            archiveName = javaOutputJarName
-            destinationDir = file(javaOutputJarDir)
-            from javaOutput
-            include "**/*.class"
-        }
-        dependsOn "${taskName}JavaJar"
-    }
-}
-
 task buildExamples {
     if (OperatingSystem.current().isMacOsX() || OperatingSystem.current().isWindows()) {
         logger.lifecycle("WARNING: Testing (including building examples) is only partially supported on your " +
@@ -1411,22 +1146,11 @@
           "It is fully supported on Linux and partially supported on Mac OS and Windows")
       return;
     }
-    dependsOn buildExampleJars
-    dependsOn buildExampleAndroidNJars
-    dependsOn buildExampleAndroidOJars
-    dependsOn buildExampleAndroidPJars
     dependsOn buildExampleJava9Jars
     dependsOn buildExampleJava10Jars
     dependsOn buildExampleJava11Jars
     dependsOn buildExampleJava17Jars
     dependsOn buildExampleJava20Jars
-    def examplesDir = file("src/test/examples")
-    examplesDir.eachDir { dir ->
-        def exampleOutputDir = file("build/test/examples/" + dir.getName());
-        if (!exampleOutputDir.exists()) {
-          exampleOutputDir.mkdirs()
-        }
-    }
 }
 
 tasks.withType(Test) {
@@ -1512,8 +1236,10 @@
     delete r8LibTestPath
     from zipTree(buildR8LibCfTestDeps.outputs.files[0])
     def examplesDir = file("build/test")
-    examplesDir.eachDir { dir ->
-        from ("${buildDir}/test/${dir.getName()}/classes")
+    if (examplesDir.exists()) {
+        examplesDir.eachDir { dir ->
+            from ("${buildDir}/test/${dir.getName()}/classes")
+        }
     }
     from ("${buildDir}/runtime/examples")
     into r8LibTestPath
@@ -2023,7 +1749,6 @@
         }
         dependsOn downloadDeps
         dependsOn buildExamples
-        dependsOn buildKotlinR8TestResources
         dependsOn buildPreNJdwpTestsJar
         dependsOn provideArtFrameworksDependencies
     } else {
diff --git a/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt b/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt
index 11dde81..b11a532 100644
--- a/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt
+++ b/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt
@@ -362,10 +362,34 @@
     "ddmlib",
     Paths.get("third_party", "ddmlib").toFile(),
     Paths.get("third_party", "ddmlib.tar.gz.sha1").toFile())
+  val examples = ThirdPartyDependency(
+    "examples",
+    Paths.get("third_party", "examples").toFile(),
+    Paths.get("third_party", "examples.tar.gz.sha1").toFile())
+  val examplesAndroidN = ThirdPartyDependency(
+    "examplesAndroidN",
+    Paths.get("third_party", "examplesAndroidN").toFile(),
+    Paths.get("third_party", "examplesAndroidN.tar.gz.sha1").toFile())
+  val examplesAndroidO = ThirdPartyDependency(
+    "examplesAndroidO",
+    Paths.get("third_party", "examplesAndroidO").toFile(),
+    Paths.get("third_party", "examplesAndroidO.tar.gz.sha1").toFile())
+  val examplesAndroidOGenerated = ThirdPartyDependency(
+    "examplesAndroidOGenerated",
+    Paths.get("third_party", "examplesAndroidOGenerated").toFile(),
+    Paths.get("third_party", "examplesAndroidOGenerated.tar.gz.sha1").toFile())
   val examplesAndroidOLegacy = ThirdPartyDependency(
     "examplesAndroidOLegacy",
     Paths.get("third_party", "examplesAndroidOLegacy").toFile(),
     Paths.get("third_party", "examplesAndroidOLegacy.tar.gz.sha1").toFile())
+  val examplesAndroidP = ThirdPartyDependency(
+    "examplesAndroidP",
+    Paths.get("third_party", "examplesAndroidP").toFile(),
+    Paths.get("third_party", "examplesAndroidP.tar.gz.sha1").toFile())
+  val examplesAndroidPGenerated = ThirdPartyDependency(
+    "examplesAndroidPGenerated",
+    Paths.get("third_party", "examplesAndroidPGenerated").toFile(),
+    Paths.get("third_party", "examplesAndroidPGenerated.tar.gz.sha1").toFile())
   val desugarJdkLibs = ThirdPartyDependency(
     "desugar-jdk-libs",
     Paths.get("third_party", "openjdk", "desugar_jdk_libs").toFile(),
@@ -421,6 +445,10 @@
     Paths.get("third_party", "jdwp-tests").toFile(),
     Paths.get("third_party", "jdwp-tests.tar.gz.sha1").toFile())
   val kotlinCompilers = getThirdPartyKotlinCompilers()
+  val kotlinR8TestResources = ThirdPartyDependency(
+    "kotlinR8TestResources",
+    Paths.get("third_party", "kotlinR8TestResources").toFile(),
+    Paths.get("third_party", "kotlinR8TestResources.tar.gz.sha1").toFile())
   val multidex = ThirdPartyDependency(
     "multidex",
     Paths.get("third_party", "multidex").toFile(),
diff --git a/d8_r8/commonBuildSrc/src/main/kotlin/DownloadAllDependenciesTask.kt b/d8_r8/commonBuildSrc/src/main/kotlin/DownloadAllDependenciesTask.kt
index 381c269..92c1af2 100644
--- a/d8_r8/commonBuildSrc/src/main/kotlin/DownloadAllDependenciesTask.kt
+++ b/d8_r8/commonBuildSrc/src/main/kotlin/DownloadAllDependenciesTask.kt
@@ -98,7 +98,7 @@
     }
 
     @Throws(IOException::class, InterruptedException::class)
-    private fun downloadFromGoogleStorage(parameters: RunDownload2Parameters, sha1File: File) {
+    private fun downloadFromGoogleStorage(parameters: RunDownloadParameters, sha1File: File) {
       val args = Arrays.asList("-n", "-b", "r8-deps", "-s", "-u", sha1File.toString())
       if (OperatingSystem.current().isWindows) {
         val command: MutableList<String> = ArrayList()
@@ -116,7 +116,7 @@
     }
 
     @Throws(IOException::class, InterruptedException::class)
-    private fun downloadFromX20(parameters: RunDownload2Parameters, sha1File: File) {
+    private fun downloadFromX20(parameters: RunDownloadParameters, sha1File: File) {
       if (OperatingSystem.current().isWindows) {
         throw RuntimeException("Downloading from x20 unsupported on windows")
       }
@@ -126,7 +126,7 @@
     }
 
     @Throws(IOException::class, InterruptedException::class)
-    private fun runProcess(parameters: RunDownload2Parameters, builder: ProcessBuilder) {
+    private fun runProcess(parameters: RunDownloadParameters, builder: ProcessBuilder) {
       builder.directory(parameters.root.asFile.get())
       val command = java.lang.String.join(" ", builder.command())
       val p = builder.start()
diff --git a/d8_r8/library_desugar/build.gradle.kts b/d8_r8/library_desugar/build.gradle.kts
index 2bba9c5..4094e64 100644
--- a/d8_r8/library_desugar/build.gradle.kts
+++ b/d8_r8/library_desugar/build.gradle.kts
@@ -10,7 +10,7 @@
 java {
   sourceSets.main.configure {
     java.srcDir(getRoot().resolveAll("src", "library_desugar", "java"))
-    output.resourcesDir = getRoot().resolveAll("build", "classes", "library_desugar_conversions")
+    output.setResourcesDir(getRoot().resolveAll("build", "classes", "library_desugar_conversions"))
   }
   sourceCompatibility = JavaVersion.VERSION_1_8
   targetCompatibility = JavaVersion.VERSION_1_8
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 d0ef602..881089b 100644
--- a/d8_r8/test_modules/tests_java_8/build.gradle.kts
+++ b/d8_r8/test_modules/tests_java_8/build.gradle.kts
@@ -59,16 +59,11 @@
 }
 
 val sourceSetDependenciesTasks = arrayOf(
-  projectTask("tests_java_examples", getExampleJarsTaskName("examples")),
   projectTask("tests_java_9", getExampleJarsTaskName("examplesJava9")),
   projectTask("tests_java_10", getExampleJarsTaskName("examplesJava10")),
   projectTask("tests_java_11", getExampleJarsTaskName("examplesJava11")),
   projectTask("tests_java_17", getExampleJarsTaskName("examplesJava17")),
   projectTask("tests_java_20", getExampleJarsTaskName("examplesJava20")),
-  projectTask("tests_java_examplesAndroidN", getExampleJarsTaskName("examplesAndroidN")),
-  projectTask("tests_java_examplesAndroidO", getExampleJarsTaskName("examplesAndroidO")),
-  projectTask("tests_java_examplesAndroidP", getExampleJarsTaskName("examplesAndroidP")),
-  projectTask("tests_java_kotlinR8TestResources", getExampleJarsTaskName("kotlinR8TestResources")),
 )
 
 fun testDependencies() : FileCollection {
diff --git a/d8_r8/test_modules/tests_java_8/settings.gradle.kts b/d8_r8/test_modules/tests_java_8/settings.gradle.kts
index f5ac288..a0cc31c 100644
--- a/d8_r8/test_modules/tests_java_8/settings.gradle.kts
+++ b/d8_r8/test_modules/tests_java_8/settings.gradle.kts
@@ -39,9 +39,3 @@
 includeBuild(root.resolve("test_modules").resolve("tests_java_11"))
 includeBuild(root.resolve("test_modules").resolve("tests_java_17"))
 includeBuild(root.resolve("test_modules").resolve("tests_java_20"))
-includeBuild(root.resolve("test_modules").resolve("tests_java_examples"))
-includeBuild(root.resolve("test_modules").resolve("tests_java_examplesAndroidN"))
-includeBuild(root.resolve("test_modules").resolve("tests_java_examplesAndroidO"))
-includeBuild(root.resolve("test_modules").resolve("tests_java_examplesAndroidP"))
-includeBuild(root.resolve("test_modules").resolve("tests_java_kotlinR8TestResources"))
-
diff --git a/d8_r8/test_modules/tests_java_examples/build.gradle.kts b/d8_r8/test_modules/tests_java_examples/build.gradle.kts
deleted file mode 100644
index 63584d2..0000000
--- a/d8_r8/test_modules/tests_java_examples/build.gradle.kts
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import org.gradle.api.JavaVersion
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-
-plugins {
-  `kotlin-dsl`
-  `java-library`
-  id("dependencies-plugin")
-}
-
-val root = getRoot()
-
-java {
-  sourceSets.test.configure {
-    java.srcDirs.clear()
-    java.srcDir(root.resolveAll("src", "test", "examples"))
-  }
-  sourceCompatibility = JavaVersion.VERSION_1_8
-  targetCompatibility = JavaVersion.VERSION_1_8
-}
-
-dependencies {
-  testCompileOnly(Deps.mockito)
-}
-
-tasks {
-  withType<JavaCompile> {
-    dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
-  }
-
-  compileTestJava {
-    options.compilerArgs = listOf("-g:source,lines")
-  }
-
-  register<JavaCompile>("debuginfo-all") {
-    source = sourceSets.test.get().allSource
-    include("**/*.java")
-    classpath = sourceSets.test.get().compileClasspath
-    destinationDirectory.set(getRoot().resolveAll("build","test","examples","classes_debuginfo_all"))
-    options.compilerArgs = listOf("-g")
-  }
-
-  register<JavaCompile>("debuginfo-none") {
-    source = sourceSets.test.get().allSource
-    include("**/*.java")
-    classpath = sourceSets.test.get().compileClasspath
-    destinationDirectory.set(getRoot().resolveAll("build","test","examples","classes_debuginfo_none"))
-    options.compilerArgs = listOf("-g:none")
-  }
-}
-
-// We just need to register the examples jars for it to be referenced by other modules. This should
-// be placed after all task registrations.
-val buildExampleJars = buildExampleJars("examples")
diff --git a/d8_r8/test_modules/tests_java_examples/gradle.properties b/d8_r8/test_modules/tests_java_examples/gradle.properties
deleted file mode 100644
index a82d85e..0000000
--- a/d8_r8/test_modules/tests_java_examples/gradle.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
-# for details. All rights reserved. Use of this source code is governed by a
-# BSD-style license that can be found in the LICENSE file.
-
-org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8
-kotlin.daemon.jvmargs=-Xmx3g -Dkotlin.js.compiler.legacy.force_enabled=true
-systemProp.file.encoding=UTF-8
-
-# Enable new incremental compilation
-kotlin.incremental.useClasspathSnapshot=true
-
-org.gradle.parallel=true
-org.gradle.caching=false
-org.gradle.configuration-cache=true
-
-# Do not download any jdks or detect them. We provide them.
-org.gradle.java.installations.auto-detect=false
-org.gradle.java.installations.auto-download=false
diff --git a/d8_r8/test_modules/tests_java_examples/settings.gradle.kts b/d8_r8/test_modules/tests_java_examples/settings.gradle.kts
deleted file mode 100644
index 8b0fe4e..0000000
--- a/d8_r8/test_modules/tests_java_examples/settings.gradle.kts
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-pluginManagement {
-  repositories {
-    maven {
-      url = uri("file:../../../third_party/dependencies")
-    }
-    maven {
-      url = uri("file:../../../third_party/dependencies_new")
-    }
-  }
-}
-
-dependencyResolutionManagement {
-  repositories {
-    maven {
-      url = uri("file:../../../third_party/dependencies")
-    }
-    maven {
-      url = uri("file:../../../third_party/dependencies_new")
-    }
-  }
-}
-
-rootProject.name = "tests_java_examples"
-val root = rootProject.projectDir.parentFile.parentFile
-includeBuild(root.resolve("shared"))
diff --git a/d8_r8/test_modules/tests_java_examplesAndroidN/build.gradle.kts b/d8_r8/test_modules/tests_java_examplesAndroidN/build.gradle.kts
deleted file mode 100644
index 38406dc..0000000
--- a/d8_r8/test_modules/tests_java_examplesAndroidN/build.gradle.kts
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import org.gradle.api.JavaVersion
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-
-plugins {
-  `kotlin-dsl`
-  `java-library`
-  id("dependencies-plugin")
-}
-
-val root = getRoot()
-
-java {
-  sourceSets.test.configure {
-    java.srcDirs.clear()
-    java.srcDir(root.resolveAll("src", "test", "examplesAndroidN"))
-  }
-  sourceCompatibility = JavaVersion.VERSION_1_8
-  targetCompatibility = JavaVersion.VERSION_1_8
-}
-
-dependencies {
-  testCompileOnly(Deps.asm)
-}
-
-// We just need to register the examples jars for it to be referenced by other modules.
-val buildExampleJars = buildExampleJars("examplesAndroidN")
-
-tasks {
-  withType<JavaCompile> {
-    dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
-  }
-}
diff --git a/d8_r8/test_modules/tests_java_examplesAndroidN/gradle.properties b/d8_r8/test_modules/tests_java_examplesAndroidN/gradle.properties
deleted file mode 100644
index a82d85e..0000000
--- a/d8_r8/test_modules/tests_java_examplesAndroidN/gradle.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
-# for details. All rights reserved. Use of this source code is governed by a
-# BSD-style license that can be found in the LICENSE file.
-
-org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8
-kotlin.daemon.jvmargs=-Xmx3g -Dkotlin.js.compiler.legacy.force_enabled=true
-systemProp.file.encoding=UTF-8
-
-# Enable new incremental compilation
-kotlin.incremental.useClasspathSnapshot=true
-
-org.gradle.parallel=true
-org.gradle.caching=false
-org.gradle.configuration-cache=true
-
-# Do not download any jdks or detect them. We provide them.
-org.gradle.java.installations.auto-detect=false
-org.gradle.java.installations.auto-download=false
diff --git a/d8_r8/test_modules/tests_java_examplesAndroidN/settings.gradle.kts b/d8_r8/test_modules/tests_java_examplesAndroidN/settings.gradle.kts
deleted file mode 100644
index 8a41fce..0000000
--- a/d8_r8/test_modules/tests_java_examplesAndroidN/settings.gradle.kts
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-pluginManagement {
-  repositories {
-    maven {
-      url = uri("file:../../../third_party/dependencies")
-    }
-    maven {
-      url = uri("file:../../../third_party/dependencies_new")
-    }
-  }
-}
-
-dependencyResolutionManagement {
-  repositories {
-    maven {
-      url = uri("file:../../../third_party/dependencies")
-    }
-    maven {
-      url = uri("file:../../../third_party/dependencies_new")
-    }
-  }
-}
-
-rootProject.name = "tests_java_examplesAndroidN"
-val root = rootProject.projectDir.parentFile.parentFile
-includeBuild(root.resolve("shared"))
diff --git a/d8_r8/test_modules/tests_java_examplesAndroidO/build.gradle.kts b/d8_r8/test_modules/tests_java_examplesAndroidO/build.gradle.kts
deleted file mode 100644
index 2f8a9a0..0000000
--- a/d8_r8/test_modules/tests_java_examplesAndroidO/build.gradle.kts
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import org.gradle.api.JavaVersion
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-
-plugins {
-  `kotlin-dsl`
-  `java-library`
-  id("dependencies-plugin")
-}
-
-val root = getRoot()
-
-java {
-  sourceSets.test.configure {
-    java.srcDirs.clear()
-    java.srcDir(root.resolveAll("src", "test", "examplesAndroidO"))
-  }
-  sourceCompatibility = JavaVersion.VERSION_1_8
-  targetCompatibility = JavaVersion.VERSION_1_8
-}
-
-// NOTE: we want to enable a scenario when test needs to reference some classes generated by legacy
-// (1.6) Java compiler to test some specific behaviour. To do so we compile all the java files
-// located in a sub-directory called 'legacy' with Java 1.6, then compile the rest of the files with
-// Java 1.8 and a reference to previously generated 1.6 classes.
-
-dependencies {
-  testCompileOnly(Deps.asm)
-  testCompileOnly(resolve(ThirdPartyDeps.examplesAndroidOLegacy))
-  testCompileOnly(resolve(getThirdPartyAndroidJar("lib-v26"),"android.jar"))
-}
-
-// We just need to register the examples jars for it to be referenced by other modules.
-val buildExampleJars = buildExampleJars("examplesAndroidO")
-
-tasks {
-  withType<JavaCompile> {
-    dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
-    options.compilerArgs.add("-Xlint:-options")
-    options.compilerArgs.add("-parameters")
-  }
-}
diff --git a/d8_r8/test_modules/tests_java_examplesAndroidO/gradle.properties b/d8_r8/test_modules/tests_java_examplesAndroidO/gradle.properties
deleted file mode 100644
index a82d85e..0000000
--- a/d8_r8/test_modules/tests_java_examplesAndroidO/gradle.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
-# for details. All rights reserved. Use of this source code is governed by a
-# BSD-style license that can be found in the LICENSE file.
-
-org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8
-kotlin.daemon.jvmargs=-Xmx3g -Dkotlin.js.compiler.legacy.force_enabled=true
-systemProp.file.encoding=UTF-8
-
-# Enable new incremental compilation
-kotlin.incremental.useClasspathSnapshot=true
-
-org.gradle.parallel=true
-org.gradle.caching=false
-org.gradle.configuration-cache=true
-
-# Do not download any jdks or detect them. We provide them.
-org.gradle.java.installations.auto-detect=false
-org.gradle.java.installations.auto-download=false
diff --git a/d8_r8/test_modules/tests_java_examplesAndroidO/settings.gradle.kts b/d8_r8/test_modules/tests_java_examplesAndroidO/settings.gradle.kts
deleted file mode 100644
index 0c63913..0000000
--- a/d8_r8/test_modules/tests_java_examplesAndroidO/settings.gradle.kts
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-pluginManagement {
-  repositories {
-    maven {
-      url = uri("file:../../../third_party/dependencies")
-    }
-    maven {
-      url = uri("file:../../../third_party/dependencies_new")
-    }
-  }
-}
-
-dependencyResolutionManagement {
-  repositories {
-    maven {
-      url = uri("file:../../../third_party/dependencies")
-    }
-    maven {
-      url = uri("file:../../../third_party/dependencies_new")
-    }
-  }
-}
-
-rootProject.name = "tests_java_examplesAndroidO"
-val root = rootProject.projectDir.parentFile.parentFile
-includeBuild(root.resolve("shared"))
diff --git a/d8_r8/test_modules/tests_java_examplesAndroidP/build.gradle.kts b/d8_r8/test_modules/tests_java_examplesAndroidP/build.gradle.kts
deleted file mode 100644
index 7b418461..0000000
--- a/d8_r8/test_modules/tests_java_examplesAndroidP/build.gradle.kts
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import org.gradle.api.JavaVersion
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-
-plugins {
-  `kotlin-dsl`
-  `java-library`
-  id("dependencies-plugin")
-}
-
-val root = getRoot()
-
-java {
-  sourceSets.test.configure {
-    java.srcDirs.clear()
-    java.srcDir(root.resolveAll("src", "test", "examplesAndroidP"))
-  }
-  sourceCompatibility = JavaVersion.VERSION_1_8
-  targetCompatibility = JavaVersion.VERSION_1_8
-}
-
-dependencies {
-  testCompileOnly(Deps.asm)
-}
-
-// We just need to register the examples jars for it to be referenced by other modules.
-val buildExampleJars = buildExampleJars("examplesAndroidP")
-
-
-tasks {
-  withType<JavaCompile> {
-    dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
-  }
-}
diff --git a/d8_r8/test_modules/tests_java_examplesAndroidP/gradle.properties b/d8_r8/test_modules/tests_java_examplesAndroidP/gradle.properties
deleted file mode 100644
index a82d85e..0000000
--- a/d8_r8/test_modules/tests_java_examplesAndroidP/gradle.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
-# for details. All rights reserved. Use of this source code is governed by a
-# BSD-style license that can be found in the LICENSE file.
-
-org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8
-kotlin.daemon.jvmargs=-Xmx3g -Dkotlin.js.compiler.legacy.force_enabled=true
-systemProp.file.encoding=UTF-8
-
-# Enable new incremental compilation
-kotlin.incremental.useClasspathSnapshot=true
-
-org.gradle.parallel=true
-org.gradle.caching=false
-org.gradle.configuration-cache=true
-
-# Do not download any jdks or detect them. We provide them.
-org.gradle.java.installations.auto-detect=false
-org.gradle.java.installations.auto-download=false
diff --git a/d8_r8/test_modules/tests_java_examplesAndroidP/settings.gradle.kts b/d8_r8/test_modules/tests_java_examplesAndroidP/settings.gradle.kts
deleted file mode 100644
index bf31cb9..0000000
--- a/d8_r8/test_modules/tests_java_examplesAndroidP/settings.gradle.kts
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-pluginManagement {
-  repositories {
-    maven {
-      url = uri("file:../../../third_party/dependencies")
-    }
-    maven {
-      url = uri("file:../../../third_party/dependencies_new")
-    }
-  }
-}
-
-dependencyResolutionManagement {
-  repositories {
-    maven {
-      url = uri("file:../../../third_party/dependencies")
-    }
-    maven {
-      url = uri("file:../../../third_party/dependencies_new")
-    }
-  }
-}
-
-rootProject.name = "tests_java_examplesAndroidP"
-val root = rootProject.projectDir.parentFile.parentFile
-includeBuild(root.resolve("shared"))
diff --git a/d8_r8/test_modules/tests_java_kotlinR8TestResources/build.gradle.kts b/d8_r8/test_modules/tests_java_kotlinR8TestResources/build.gradle.kts
deleted file mode 100644
index 2ca6560..0000000
--- a/d8_r8/test_modules/tests_java_kotlinR8TestResources/build.gradle.kts
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import org.gradle.api.JavaVersion
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-
-plugins {
-  `kotlin-dsl`
-  `java-library`
-  id("dependencies-plugin")
-}
-
-val root = getRoot()
-
-java {
-  sourceSets.test.configure {
-    java.srcDirs.clear()
-    java.srcDir(root.resolveAll("src", "test", "kotlinR8TestResources"))
-  }
-  sourceCompatibility = JavaVersion.VERSION_1_8
-  targetCompatibility = JavaVersion.VERSION_1_8
-}
-
-dependencies {
-  testCompileOnly(Deps.asm)
-}
-
-// We just need to register the examples jars for it to be referenced by other modules.
-val buildExampleJars = buildExampleJars("kotlinR8TestResources")
-
-tasks {
-  withType<JavaCompile> {
-    dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
-  }
-
-  withType<KotlinCompile> {
-    dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
-    kotlinOptions {
-      jvmTarget = "1.8"
-    }
-  }
-}
diff --git a/d8_r8/test_modules/tests_java_kotlinR8TestResources/gradle.properties b/d8_r8/test_modules/tests_java_kotlinR8TestResources/gradle.properties
deleted file mode 100644
index a82d85e..0000000
--- a/d8_r8/test_modules/tests_java_kotlinR8TestResources/gradle.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
-# for details. All rights reserved. Use of this source code is governed by a
-# BSD-style license that can be found in the LICENSE file.
-
-org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8
-kotlin.daemon.jvmargs=-Xmx3g -Dkotlin.js.compiler.legacy.force_enabled=true
-systemProp.file.encoding=UTF-8
-
-# Enable new incremental compilation
-kotlin.incremental.useClasspathSnapshot=true
-
-org.gradle.parallel=true
-org.gradle.caching=false
-org.gradle.configuration-cache=true
-
-# Do not download any jdks or detect them. We provide them.
-org.gradle.java.installations.auto-detect=false
-org.gradle.java.installations.auto-download=false
diff --git a/d8_r8/test_modules/tests_java_kotlinR8TestResources/settings.gradle.kts b/d8_r8/test_modules/tests_java_kotlinR8TestResources/settings.gradle.kts
deleted file mode 100644
index f5d5e59..0000000
--- a/d8_r8/test_modules/tests_java_kotlinR8TestResources/settings.gradle.kts
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-pluginManagement {
-  repositories {
-    maven {
-      url = uri("file:../../../third_party/dependencies")
-    }
-    maven {
-      url = uri("file:../../../third_party/dependencies_new")
-    }
-  }
-}
-
-dependencyResolutionManagement {
-  repositories {
-    maven {
-      url = uri("file:../../../third_party/dependencies")
-    }
-    maven {
-      url = uri("file:../../../third_party/dependencies_new")
-    }
-  }
-}
-
-rootProject.name = "tests_java_kotlinR8TestResources"
-val root = rootProject.projectDir.parentFile.parentFile
-includeBuild(root.resolve("shared"))
diff --git a/src/test/java/com/android/tools/r8/D8IncrementalRunExamplesAndroidOTest.java b/src/test/java/com/android/tools/r8/D8IncrementalRunExamplesAndroidOTest.java
index d3a155f..1d09697 100644
--- a/src/test/java/com/android/tools/r8/D8IncrementalRunExamplesAndroidOTest.java
+++ b/src/test/java/com/android/tools/r8/D8IncrementalRunExamplesAndroidOTest.java
@@ -156,8 +156,7 @@
 
     Path getGeneratedRoot(Path testJarFile) {
       String sourceSet = testJarFile.getParent().toFile().getName();
-      Path parent = testJarFile.getParent().getParent().getParent();
-      return parent.resolve(Paths.get("generated", sourceSet, packageName));
+      return Paths.get(ToolHelper.THIRD_PARTY_DIR, sourceSet + "Generated", packageName);
     }
 
     AndroidApp compileClassFilesInIntermediate(
diff --git a/src/test/java/com/android/tools/r8/D8NonLazyRunExamplesAndroidOTest.java b/src/test/java/com/android/tools/r8/D8NonLazyRunExamplesAndroidOTest.java
index c87ad97..7fc01c3 100644
--- a/src/test/java/com/android/tools/r8/D8NonLazyRunExamplesAndroidOTest.java
+++ b/src/test/java/com/android/tools/r8/D8NonLazyRunExamplesAndroidOTest.java
@@ -6,8 +6,7 @@
 
 import java.nio.file.Path;
 
-public class D8NonLazyRunExamplesAndroidOTest
-    extends D8IncrementalRunExamplesAndroidOTest {
+public class D8NonLazyRunExamplesAndroidOTest extends D8IncrementalRunExamplesAndroidOTest {
   class D8LazyTestRunner extends D8IncrementalTestRunner {
 
     D8LazyTestRunner(String testName, String packageName, String mainClass) {
diff --git a/src/test/java/com/android/tools/r8/KotlinTestBase.java b/src/test/java/com/android/tools/r8/KotlinTestBase.java
index f314547..a98d7f0 100644
--- a/src/test/java/com/android/tools/r8/KotlinTestBase.java
+++ b/src/test/java/com/android/tools/r8/KotlinTestBase.java
@@ -24,7 +24,6 @@
 import java.util.Map;
 import java.util.function.Consumer;
 import java.util.stream.Collectors;
-import org.hamcrest.Matcher;
 import org.junit.rules.TemporaryFolder;
 
 public abstract class KotlinTestBase extends TestBase {
@@ -91,15 +90,7 @@
   }
 
   protected Path getJavaJarFile(String folder) {
-    return Paths.get(ToolHelper.TESTS_BUILD_DIR, RSRC, folder + FileUtils.JAR_EXTENSION);
-  }
-
-  protected Path getMappingfile(String folder, String mappingFileName) {
-    return Paths.get(ToolHelper.TESTS_DIR, RSRC, folder, mappingFileName);
-  }
-
-  protected static Matcher<String> expectedInfoMessagesFromKotlinStdLib() {
-    return containsString("No VersionRequirement");
+    return Paths.get(ToolHelper.THIRD_PARTY_DIR, RSRC, folder + FileUtils.JAR_EXTENSION);
   }
 
   protected KotlinCompilerTool kotlinCompilerTool() {
diff --git a/src/test/java/com/android/tools/r8/ToolHelper.java b/src/test/java/com/android/tools/r8/ToolHelper.java
index 11e546d..b223f76 100644
--- a/src/test/java/com/android/tools/r8/ToolHelper.java
+++ b/src/test/java/com/android/tools/r8/ToolHelper.java
@@ -153,7 +153,6 @@
   public static final String MAIN_SOURCE_DIR = getProjectRoot() + "src/main/java/";
   public static final String LIBRARY_DESUGAR_SOURCE_DIR = getProjectRoot() + "src/library_desugar/";
   public static final String BUILD_DIR = getProjectRoot() + "build/";
-  public static final String GENERATED_TEST_BUILD_DIR = BUILD_DIR + "generated/test/";
   public static final String LIBS_DIR = BUILD_DIR + "libs/";
   public static final String THIRD_PARTY_DIR = getProjectRoot() + "third_party/";
   public static final String DEPENDENCIES = THIRD_PARTY_DIR + "dependencies/";
@@ -164,17 +163,15 @@
   public static final String EXAMPLES_DIR = TESTS_DIR + "examples/";
   public static final String EXAMPLES_ANDROID_O_DIR = TESTS_DIR + "examplesAndroidO/";
   public static final String EXAMPLES_ANDROID_P_DIR = TESTS_DIR + "examplesAndroidP/";
-  public static final String TESTS_BUILD_DIR = BUILD_DIR + "test/";
-  public static final String EXAMPLES_BUILD_DIR = TESTS_BUILD_DIR + "examples/";
+  public static final String EXAMPLES_BUILD_DIR = THIRD_PARTY_DIR + "examples/";
   public static final String EXAMPLES_CF_DIR = EXAMPLES_BUILD_DIR + "classes/";
-  public static final String EXAMPLES_ANDROID_N_BUILD_DIR = TESTS_BUILD_DIR + "examplesAndroidN/";
-  public static final String EXAMPLES_ANDROID_O_BUILD_DIR = TESTS_BUILD_DIR + "examplesAndroidO/";
-  public static final String EXAMPLES_ANDROID_P_BUILD_DIR = TESTS_BUILD_DIR + "examplesAndroidP/";
+  public static final String EXAMPLES_ANDROID_N_BUILD_DIR = THIRD_PARTY_DIR + "examplesAndroidN/";
+  public static final String EXAMPLES_ANDROID_O_BUILD_DIR = THIRD_PARTY_DIR + "examplesAndroidO/";
+  public static final String EXAMPLES_ANDROID_P_BUILD_DIR = THIRD_PARTY_DIR + "examplesAndroidP/";
+  public static final String TESTS_BUILD_DIR = BUILD_DIR + "test/";
   public static final String EXAMPLES_JAVA9_BUILD_DIR = TESTS_BUILD_DIR + "examplesJava9/";
   public static final String EXAMPLES_JAVA10_BUILD_DIR = TESTS_BUILD_DIR + "examplesJava10/";
   public static final String EXAMPLES_JAVA11_JAR_DIR = TESTS_BUILD_DIR + "examplesJava11/";
-  public static final String EXAMPLES_PROTO_BUILD_DIR = TESTS_BUILD_DIR + "examplesProto/";
-  public static final String GENERATED_PROTO_BUILD_DIR = GENERATED_TEST_BUILD_DIR + "proto/";
   public static final String SMALI_BUILD_DIR = THIRD_PARTY_DIR + "smali/";
 
   public static String getExamplesJava11BuildDir() {
diff --git a/src/test/java/com/android/tools/r8/classmerging/vertical/VerticalClassMergerTest.java b/src/test/java/com/android/tools/r8/classmerging/vertical/VerticalClassMergerTest.java
index 162f678..7ec72c7 100644
--- a/src/test/java/com/android/tools/r8/classmerging/vertical/VerticalClassMergerTest.java
+++ b/src/test/java/com/android/tools/r8/classmerging/vertical/VerticalClassMergerTest.java
@@ -65,9 +65,9 @@
 public class VerticalClassMergerTest extends TestBase {
 
   private static final Path CF_DIR =
-      Paths.get(ToolHelper.BUILD_DIR).resolve("test/examples/classes/classmerging");
+      Paths.get(ToolHelper.EXAMPLES_BUILD_DIR).resolve("classes/classmerging");
   private static final Path JAVA8_CF_DIR =
-      Paths.get(ToolHelper.BUILD_DIR).resolve("test/examplesAndroidO/classes/classmerging");
+      Paths.get(ToolHelper.THIRD_PARTY_DIR).resolve("examplesAndroidO/classes/classmerging");
   private static final Path EXAMPLE_JAR = Paths.get(ToolHelper.EXAMPLES_BUILD_DIR)
       .resolve("classmerging.jar");
   private static final Path EXAMPLE_KEEP = Paths.get(ToolHelper.EXAMPLES_DIR)
diff --git a/src/test/java/com/android/tools/r8/desugar/b72538146/B72538146.java b/src/test/java/com/android/tools/r8/desugar/b72538146/B72538146.java
index 85362c4..b385299 100644
--- a/src/test/java/com/android/tools/r8/desugar/b72538146/B72538146.java
+++ b/src/test/java/com/android/tools/r8/desugar/b72538146/B72538146.java
@@ -59,7 +59,7 @@
     // Run the classloader test loading the two dex applications.
     testForD8()
         .addProgramFiles(
-            Paths.get(ToolHelper.TESTS_BUILD_DIR)
+            Paths.get(ToolHelper.THIRD_PARTY_DIR)
                 .resolve("examplesAndroidO")
                 .resolve("classes")
                 .resolve("classloader")
diff --git a/src/test/java/com/android/tools/r8/maindexlist/b72312389/B72312389.java b/src/test/java/com/android/tools/r8/maindexlist/b72312389/B72312389.java
index e303689..8c717a0 100644
--- a/src/test/java/com/android/tools/r8/maindexlist/b72312389/B72312389.java
+++ b/src/test/java/com/android/tools/r8/maindexlist/b72312389/B72312389.java
@@ -43,7 +43,7 @@
         .addLibraryFiles(ToolHelper.getAndroidJar(AndroidApiLevel.O))
         .addProgramFiles(
             Paths.get(
-                ToolHelper.TESTS_BUILD_DIR,
+                ToolHelper.THIRD_PARTY_DIR,
                 "examplesAndroidO",
                 "classes",
                 "instrumentationtest",
diff --git a/src/test/java/com/android/tools/r8/shaking/TreeShakingSpecificTest.java b/src/test/java/com/android/tools/r8/shaking/TreeShakingSpecificTest.java
index 1dba3c9..1afb1c3 100644
--- a/src/test/java/com/android/tools/r8/shaking/TreeShakingSpecificTest.java
+++ b/src/test/java/com/android/tools/r8/shaking/TreeShakingSpecificTest.java
@@ -52,10 +52,6 @@
     return Paths.get(EXAMPLES_BUILD_DIR, test + ".jar");
   }
 
-  private byte[] getProgramDexFileData(String test) throws IOException {
-    return Files.readAllBytes(Paths.get(EXAMPLES_BUILD_DIR, test, "classes.dex"));
-  }
-
   @Test
   public void testIgnoreWarnings() throws Exception {
     // Generate R8 processed version without library option.
diff --git a/src/test/java/com/android/tools/r8/shaking/TreeShakingTest.java b/src/test/java/com/android/tools/r8/shaking/TreeShakingTest.java
index fb55a41..b573cd5 100644
--- a/src/test/java/com/android/tools/r8/shaking/TreeShakingTest.java
+++ b/src/test/java/com/android/tools/r8/shaking/TreeShakingTest.java
@@ -156,7 +156,7 @@
       DiagnosticsConsumer diagnosticsConsumer)
       throws Exception {
 
-    String programFile = ToolHelper.TESTS_BUILD_DIR + getName() + ".jar";
+    String programFile = ToolHelper.THIRD_PARTY_DIR + getName() + ".jar";
 
     R8FullTestBuilder testBuilder =
         testForR8(parameters.getBackend())
diff --git a/third_party/examples.tar.gz.sha1 b/third_party/examples.tar.gz.sha1
new file mode 100644
index 0000000..7cc4607
--- /dev/null
+++ b/third_party/examples.tar.gz.sha1
@@ -0,0 +1 @@
+a64a830bad847a8bcb1b1d441b16876882951960
\ No newline at end of file
diff --git a/third_party/examplesAndroidN.tar.gz.sha1 b/third_party/examplesAndroidN.tar.gz.sha1
new file mode 100644
index 0000000..c7c48ab
--- /dev/null
+++ b/third_party/examplesAndroidN.tar.gz.sha1
@@ -0,0 +1 @@
+3b4abfc288b97b2f592de1528162ffdfa4db76c2
\ No newline at end of file
diff --git a/third_party/examplesAndroidO.tar.gz.sha1 b/third_party/examplesAndroidO.tar.gz.sha1
new file mode 100644
index 0000000..7d28b20
--- /dev/null
+++ b/third_party/examplesAndroidO.tar.gz.sha1
@@ -0,0 +1 @@
+05367865efe55fcbf75c782deddab15ae7c40dad
\ No newline at end of file
diff --git a/third_party/examplesAndroidOGenerated.tar.gz.sha1 b/third_party/examplesAndroidOGenerated.tar.gz.sha1
new file mode 100644
index 0000000..832286b
--- /dev/null
+++ b/third_party/examplesAndroidOGenerated.tar.gz.sha1
@@ -0,0 +1 @@
+ea9220ee4f864517540f693ab0fd371a24607bf2
\ No newline at end of file
diff --git a/third_party/examplesAndroidP.tar.gz.sha1 b/third_party/examplesAndroidP.tar.gz.sha1
new file mode 100644
index 0000000..8b2db07
--- /dev/null
+++ b/third_party/examplesAndroidP.tar.gz.sha1
@@ -0,0 +1 @@
+591f8ee9f40e7a433e951908a22367d2001ff80e
\ No newline at end of file
diff --git a/third_party/examplesAndroidPGenerated.tar.gz.sha1 b/third_party/examplesAndroidPGenerated.tar.gz.sha1
new file mode 100644
index 0000000..28762a8
--- /dev/null
+++ b/third_party/examplesAndroidPGenerated.tar.gz.sha1
@@ -0,0 +1 @@
+8c0a039c70b4b335a017a818d286a9ace420a7ef
\ No newline at end of file
diff --git a/third_party/kotlinR8TestResources.tar.gz.sha1 b/third_party/kotlinR8TestResources.tar.gz.sha1
new file mode 100644
index 0000000..44d30c5
--- /dev/null
+++ b/third_party/kotlinR8TestResources.tar.gz.sha1
@@ -0,0 +1 @@
+4d5ea5f132e98018c5e3ef73ce478e0745d7f998
\ No newline at end of file