Reland "Clean-up top-level r8 entry-points to not use shadow-jar"

This reverts commit 9957518b7c781235baba52c229c77e5bd6c548ab.

Change-Id: Ib01490901c0cb0f0b9b04806df61f2d919d6881a
diff --git a/build.gradle b/build.gradle
index 7b0526b..39b8fc0 100644
--- a/build.gradle
+++ b/build.gradle
@@ -284,7 +284,6 @@
 def r8LibPath = "$buildDir/libs/r8lib.jar"
 def r8LibExludeDepsPath = "$buildDir/libs/r8lib-exclude-deps.jar"
 def r8LibGeneratedKeepRulesPath = "$buildDir/generated/keep.txt"
-def r8LibGeneratedKeepRulesExcludeDepsPath = "$buildDir/generated/keep-exclude-deps.txt"
 def r8LibTestPath = "$buildDir/classes/r8libtest"
 def java11ClassFiles = "build/classes/java/mainJava11"
 
@@ -696,33 +695,9 @@
     }
 }
 
-static configureRelocations(ShadowJar task) {
-    task.relocate('com.google.common', 'com.android.tools.r8.com.google.common')
-    task.relocate('com.google.gson', 'com.android.tools.r8.com.google.gson')
-    task.relocate('com.google.thirdparty', 'com.android.tools.r8.com.google.thirdparty')
-    task.relocate('joptsimple', 'com.android.tools.r8.joptsimple')
-    task.relocate('org.objectweb.asm', 'com.android.tools.r8.org.objectweb.asm')
-    task.relocate('it.unimi.dsi.fastutil', 'com.android.tools.r8.it.unimi.dsi.fastutil')
-    task.relocate('kotlin', 'com.android.tools.r8.jetbrains.kotlin')
-    task.relocate('kotlinx', 'com.android.tools.r8.jetbrains.kotlinx')
-    task.relocate('org.jetbrains', 'com.android.tools.r8.org.jetbrains')
-    task.relocate('org.intellij', 'com.android.tools.r8.org.intellij')
-}
-
-task repackageDepsNoRelocate(type: ShadowJar) {
-    configurations = [project.configurations.runtimeClasspath]
-    mergeServiceFiles(it)
-    exclude { it.getRelativePath().getPathString() == "module-info.class" }
-    exclude { it.getRelativePath().getPathString().startsWith("META-INF/maven/") }
-    baseName 'deps-not-relocated'
-}
-
 task repackageDeps(type: ShadowJar) {
     configurations = [project.configurations.runtimeClasspath]
     mergeServiceFiles(it)
-    if (!project.hasProperty('lib_no_relocate')) {
-        configureRelocations(it)
-    }
     exclude { it.getRelativePath().getPathString() == "module-info.class" }
     exclude { it.getRelativePath().getPathString().startsWith("META-INF/maven/") }
     baseName 'deps'
@@ -731,9 +706,6 @@
 task repackageSources(type: ShadowJar) {
     from sourceSets.main.output
     mergeServiceFiles(it)
-    if (!project.hasProperty('lib_no_relocate')) {
-        configureRelocations(it)
-    }
     baseName 'sources'
 }
 
@@ -741,100 +713,161 @@
     dependsOn compileMainWithJava11
     from file(java11ClassFiles)
     mergeServiceFiles(it)
-    if (!project.hasProperty('lib_no_relocate')) {
-        configureRelocations(it)
-    }
     baseName 'sources11'
 }
 
-task r8WithRelocatedDeps(type: ShadowJar) {
-    from consolidatedLicense.outputs.files
-    baseName 'r8_with_relocated_deps'
-    classifier = null
-    version = null
-    manifest {
-        attributes 'Main-Class': 'com.android.tools.r8.SwissArmyKnife'
+def r8CreateTask(name, baseNameName, sources, includeSwissArmyKnife) {
+    return tasks.create("r8Create${name}", ShadowJar) {
+        from consolidatedLicense.outputs.files
+        from sources
+        baseName baseNameName
+        classifier = null
+        version = null
+        if (includeSwissArmyKnife) {
+            manifest {
+                attributes 'Main-Class': 'com.android.tools.r8.SwissArmyKnife'
+            }
+        }
+        exclude "META-INF/*.kotlin_module"
+        exclude "**/*.kotlin_metadata"
     }
-    from repackageSources.outputs.files
-    from repackageDeps.outputs.files
-    configureRelocations(it)
-    exclude "META-INF/*.kotlin_module"
-    exclude "**/*.kotlin_metadata"
 }
 
-task r8WithRelocatedDeps11(type: ShadowJar) {
-    from consolidatedLicense.outputs.files
-    baseName 'r8_with_relocated_deps_11'
-    classifier = null
-    version = null
-    manifest {
-        attributes 'Main-Class': 'com.android.tools.r8.SwissArmyKnife'
+def r8RelocateTask(r8Task, output) {
+    return tasks.create("r8Relocate_${r8Task.name}", Exec) {
+        dependsOn r8WithDeps
+        dependsOn r8Task
+        outputs.file output
+        workingDir = projectDir
+        inputs.files r8Task.outputs.files + r8WithDeps.outputs.files
+        commandLine baseR8CommandLine([
+                "relocator",
+                "--input",
+                r8Task.outputs.files[0],
+                "--output",
+                output,
+                "--map",
+                "com.google.common->com.android.tools.r8.com.google.common",
+                "--map",
+                "com.google.gson->com.android.tools.r8.com.google.gson",
+                "--map",
+                "com.google.thirdparty->com.android.tools.r8.com.google.thirdparty",
+                "--map",
+                "joptsimple->com.android.tools.r8.joptsimple",
+                "--map",
+                "org.objectweb.asm->com.android.tools.r8.org.objectweb.asm",
+                "--map",
+                "it.unimi.dsi.fastutil->com.android.tools.r8.it.unimi.dsi.fastutil",
+                "--map",
+                "kotlin->com.android.tools.r8.jetbrains.kotlin",
+                "--map",
+                "kotlinx->com.android.tools.r8.jetbrains.kotlinx",
+                "--map",
+                "org.jetbrains->com.android.tools.r8.org.jetbrains",
+                "--map",
+                "org.intellij->com.android.tools.r8.org.intellij"
+        ])
     }
-    from repackageSources11.outputs.files
-    from repackageDeps.outputs.files
-    configureRelocations(it)
-    exclude "META-INF/*.kotlin_module"
-    exclude "**/*.kotlin_metadata"
 }
 
-task r8WithoutDeps(type: ShadowJar) {
-    from consolidatedLicense.outputs.files
-    baseName 'r8_without_deps'
-    classifier = null
-    version = null
-    manifest {
-        attributes 'Main-Class': 'com.android.tools.r8.SwissArmyKnife'
-    }
-    from sourceSets.main.output
+task r8WithDeps {
+    dependsOn repackageSources
+    dependsOn repackageDeps
+    def r8Task = r8CreateTask(
+            'WithDeps',
+            'r8_with_deps',
+            repackageSources.outputs.files + repackageDeps.outputs.files,
+            true)
+    dependsOn r8Task
+    outputs.files r8Task.outputs.files
 }
 
-task R8(type: ShadowJar) {
-    from consolidatedLicense.outputs.files
-    baseName 'r8'
-    classifier = null
-    version = null
-    manifest {
-        attributes 'Main-Class': 'com.android.tools.r8.SwissArmyKnife'
-    }
-    // In order to build without dependencies, pass the exclude_deps property using:
-    // gradle -Pexclude_deps R8
-    if (!project.hasProperty('exclude_deps')) {
-        from repackageSources.outputs.files
-        from repackageDeps.outputs.files
-    } else {
-        from sourceSets.main.output
-    }
-    exclude "META-INF/*.kotlin_module"
-    exclude "**/*.kotlin_metadata"
+task r8WithDeps11 {
+    dependsOn repackageSources11
+    dependsOn repackageDeps
+    def r8Task = r8CreateTask(
+            'WithDeps11',
+            'r8_with_deps_11',
+            repackageSources11.outputs.files + repackageDeps.outputs.files,
+            true)
+    dependsOn r8Task
+    outputs.files r8Task.outputs.files
 }
 
-task R8NoManifestNoDeps(type: ShadowJar) {
-    from consolidatedLicense.outputs.files
-    baseName 'r8nomanifest-exclude-deps'
-    classifier = null
-    version = null
-    from sourceSets.main.output
+task r8WithRelocatedDeps {
+    def output = "${buildDir}/libs/r8_with_relocated_deps.jar"
+    dependsOn r8RelocateTask(r8WithDeps, output)
+    outputs.file output
 }
 
-task R8NoManifest(type: ShadowJar) {
-    from consolidatedLicense.outputs.files
-    baseName 'r8nomanifest'
-    classifier = null
-    version = null
-    // In order to build without dependencies, pass the exclude_deps property using:
-    // gradle -Pexclude_deps R8
-    if (!project.hasProperty('exclude_deps')) {
-        from repackageSources.outputs.files
-        from repackageDeps.outputs.files
-    } else {
-        from sourceSets.main.output
-    }
-    exclude "META-INF/*.kotlin_module"
-    exclude "**/*.kotlin_metadata"
+task r8WithRelocatedDeps11 {
+    def output = "${buildDir}/libs/r8_with_relocated_deps_11.jar"
+    dependsOn r8RelocateTask(r8WithDeps11, output)
+    outputs.file output
+}
+
+task r8WithoutDeps {
+    dependsOn repackageSources
+    def r8Task = r8CreateTask(
+            'WithoutDeps',
+            'r8_without_deps',
+            repackageSources.outputs.files,
+            true)
+    dependsOn r8Task
+    outputs.files r8Task.outputs.files
+}
+
+task r8(type: Copy) {
+    def r8Task = project.hasProperty("exclude_deps")
+            ? r8WithoutDeps : r8WithRelocatedDeps
+    dependsOn r8Task
+    from r8Task.outputs.files[0]
+    into file("${buildDir}/libs")
+    rename { String fileName -> "r8.jar" }
+    outputs.file "${buildDir}/libs/r8.jar"
+}
+
+task r8NoManifestWithoutDeps {
+    dependsOn repackageSources
+    def r8Task = r8CreateTask(
+            'NoManifestWithoutDeps',
+            'r8_no_manifest_without_deps',
+            repackageSources.outputs.files,
+            false)
+    dependsOn r8Task
+    outputs.files r8Task.outputs.files
+}
+
+task r8NoManifestWithDeps {
+    dependsOn repackageSources
+    def r8Task = r8CreateTask(
+            'NoManifestWithDeps',
+            'r8_no_manifest_with_deps',
+            repackageSources.outputs.files + repackageDeps.outputs.files,
+            false)
+    dependsOn r8Task
+    outputs.files r8Task.outputs.files
+}
+
+task r8NoManifestWithRelocatedDeps {
+    def output = "${buildDir}/libs/r8_no_manifest_with_relocated_deps.jar"
+    dependsOn r8RelocateTask(r8NoManifestWithDeps, output)
+    outputs.file output
+}
+
+task r8NoManifest(type: Copy) {
+    def r8Task = project.hasProperty("exclude_deps")
+            ? r8NoManifestWithoutDeps : r8NoManifestWithRelocatedDeps
+    dependsOn r8Task
+    from r8Task.outputs.files[0]
+    into file("${buildDir}/libs")
+    rename { String fileName -> "r8_no_manifest.jar" }
+    outputs.file "${buildDir}/libs/r8_no_manifest.jar"
 }
 
 task D8(type: ShadowJar) {
-    from R8.outputs.files
+    dependsOn r8
+    from r8.outputs.files[0]
     baseName 'd8'
     manifest {
         attributes 'Main-Class': 'com.android.tools.r8.D8'
@@ -842,10 +875,10 @@
 }
 
 def baseR8CommandLine(args = []) {
-    // Execute r8 commands against a stable r8 with relocated dependencies.
+    // Execute r8 commands against a stable r8 with dependencies.
     // TODO(b/139725780): See if we can remove or lower the heap size (-Xmx6g).
     return [org.gradle.internal.jvm.Jvm.current().getJavaExecutable(),
-            "-Xmx8g", "-ea", "-jar", r8WithRelocatedDeps.outputs.files[0]] + args
+            "-Xmx8g", "-ea", "-jar", r8WithDeps.outputs.files[0]] + args
 }
 
 def r8CfCommandLine(input, output, pgConfs = [], args = ["--release"], libs = []) {
@@ -891,23 +924,23 @@
         // TODO(b/154785341): We should remove this.
         standardOutput new FileOutputStream(r8LibGeneratedKeepRulesPath)
     }
-    dependsOn R8NoManifest
+    dependsOn r8NoManifest
     dependsOn r8WithRelocatedDeps
     dependsOn testJar
     dependsOn downloadOpenJDKrt
-    inputs.files ([r8WithRelocatedDeps.outputs, R8NoManifest.outputs, testJar.outputs])
+    inputs.files ([r8WithRelocatedDeps.outputs, r8NoManifest.outputs, testJar.outputs])
     outputs.file r8LibGeneratedKeepRulesPath
     commandLine baseR8CommandLine([
             "printuses",
             "--keeprules-allowobfuscation",
             "third_party/openjdk/openjdk-rt-1.8/rt.jar",
-            R8NoManifest.outputs.files[0],
+            r8NoManifest.outputs.files[0],
             testJar.outputs.files[0]])
     workingDir = projectDir
 }
 
 task R8LibApiOnly {
-    dependsOn r8LibCreateTask("Api", ["src/main/keep.txt"], R8NoManifest, r8LibPath)
+    dependsOn r8LibCreateTask("Api", ["src/main/keep.txt"], r8NoManifest, r8LibPath)
     outputs.file r8LibPath
 }
 
@@ -917,7 +950,7 @@
             ["src/main/keep.txt",
              "src/main/keep-applymapping.txt",
              generateR8LibKeepRules.outputs.files[0]],
-            R8NoManifest,
+            r8NoManifestWithRelocatedDeps,
             r8LibPath,
     ).dependsOn(generateR8LibKeepRules)
     outputs.file r8LibPath
@@ -927,11 +960,11 @@
     dependsOn r8LibCreateTask(
             "NoDeps",
             ["src/main/keep.txt", "src/main/keep-applymapping.txt"],
-            R8NoManifestNoDeps,
+            r8NoManifestWithoutDeps,
             r8LibExludeDepsPath,
             "--release",
-            repackageDepsNoRelocate.outputs.files
-    ).dependsOn(repackageDepsNoRelocate)
+            repackageDeps.outputs.files
+    ).dependsOn(repackageDeps)
     outputs.file r8LibExludeDepsPath
 }
 
@@ -1740,7 +1773,7 @@
 task buildR8LibCfTestDeps(type: Exec) {
     def outputPath = "build/libs/r8libtestdeps-cf.jar"
     dependsOn downloadDeps
-    dependsOn R8NoManifest
+    dependsOn r8NoManifest
     dependsOn R8Lib
     dependsOn generateR8TestKeepRules
     dependsOn testJar
@@ -1755,8 +1788,8 @@
             testJar.outputs.files[0],
             outputPath,
             [generateR8TestKeepRules.outputs.files[0]],
-            ["--debug", "--classpath", R8NoManifest.outputs.files[0]],
-            R8NoManifest.outputs.files + addedLibraries)
+            ["--debug", "--classpath", r8NoManifest.outputs.files[0]],
+            r8NoManifest.outputs.files + addedLibraries)
     workingDir = projectDir
     outputs.file outputPath
 }
@@ -1824,7 +1857,7 @@
     dependsOn buildLibraryDesugarConversions
     dependsOn getJarsFromSupportLibs
     // R8.jar is required for running bootstrap tests.
-    dependsOn R8
+    dependsOn r8
     testLogging.exceptionFormat = 'full'
     if (project.hasProperty('print_test_stdout')) {
         testLogging.showStandardStreams = true
diff --git a/src/test/java/com/android/tools/r8/ExternalR8TestBuilder.java b/src/test/java/com/android/tools/r8/ExternalR8TestBuilder.java
index 11e6692..08ce5be 100644
--- a/src/test/java/com/android/tools/r8/ExternalR8TestBuilder.java
+++ b/src/test/java/com/android/tools/r8/ExternalR8TestBuilder.java
@@ -90,9 +90,7 @@
 
       String classPath =
           addR8ExternalDeps
-              ? r8jar.toAbsolutePath().toString()
-                  + CLASSPATH_SEPARATOR
-                  + ToolHelper.DEPS_NOT_RELOCATED
+              ? r8jar.toAbsolutePath().toString() + CLASSPATH_SEPARATOR + ToolHelper.DEPS
               : r8jar.toAbsolutePath().toString();
 
       List<String> command = new ArrayList<>();
diff --git a/src/test/java/com/android/tools/r8/ToolHelper.java b/src/test/java/com/android/tools/r8/ToolHelper.java
index 52d2619..5c50407 100644
--- a/src/test/java/com/android/tools/r8/ToolHelper.java
+++ b/src/test/java/com/android/tools/r8/ToolHelper.java
@@ -160,8 +160,10 @@
 
   public static final Path D8_JAR = Paths.get(LIBS_DIR, "d8.jar");
   public static final Path R8_JAR = Paths.get(LIBS_DIR, "r8.jar");
+  public static final Path R8_WITH_DEPS_JAR = Paths.get(LIBS_DIR, "r8_with_deps.jar");
   public static final Path R8_WITH_RELOCATED_DEPS_JAR =
       Paths.get(LIBS_DIR, "r8_with_relocated_deps.jar");
+  public static final Path R8_WITH_DEPS_11_JAR = Paths.get(LIBS_DIR, "r8_with_deps_11.jar");
   public static final Path R8_WITH_RELOCATED_DEPS_11_JAR =
       Paths.get(LIBS_DIR, "r8_with_relocated_deps_11.jar");
   public static final Path R8LIB_JAR = Paths.get(LIBS_DIR, "r8lib.jar");
@@ -169,7 +171,7 @@
   public static final Path R8LIB_EXCLUDE_DEPS_JAR = Paths.get(LIBS_DIR, "r8lib-exclude-deps.jar");
   public static final Path R8LIB_EXCLUDE_DEPS_MAP =
       Paths.get(LIBS_DIR, "r8lib-exclude-deps.jar.map");
-  public static final Path DEPS_NOT_RELOCATED = Paths.get(LIBS_DIR, "deps-not-relocated.jar");
+  public static final Path DEPS = Paths.get(LIBS_DIR, "deps.jar");
 
   public static final Path DESUGAR_LIB_CONVERSIONS =
       Paths.get(LIBS_DIR, "library_desugar_conversions.zip");
diff --git a/src/test/java/com/android/tools/r8/relocator/RelocatorTest.java b/src/test/java/com/android/tools/r8/relocator/RelocatorTest.java
index 7f64b67..3dd87ec 100644
--- a/src/test/java/com/android/tools/r8/relocator/RelocatorTest.java
+++ b/src/test/java/com/android/tools/r8/relocator/RelocatorTest.java
@@ -63,8 +63,8 @@
   public void testRelocatorIdentity()
       throws IOException, CompilationFailedException, ExecutionException {
     Path output = temp.newFile("output.jar").toPath();
-    runRelocator(ToolHelper.R8_JAR, new HashMap<>(), output);
-    inspectAllClassesRelocated(ToolHelper.R8_JAR, output, "", "");
+    runRelocator(ToolHelper.R8_WITH_DEPS_JAR, new HashMap<>(), output);
+    inspectAllClassesRelocated(ToolHelper.R8_WITH_DEPS_JAR, output, "", "");
   }
 
   @Test
@@ -74,8 +74,9 @@
     Path output = temp.newFile("output.jar").toPath();
     Map<String, String> mapping = new HashMap<>();
     mapping.put(originalPrefix, newPrefix);
-    runRelocator(ToolHelper.R8_JAR, mapping, output);
-    inspectAllClassesRelocated(ToolHelper.R8_JAR, output, originalPrefix, newPrefix + ".");
+    runRelocator(ToolHelper.R8_WITH_DEPS_JAR, mapping, output);
+    inspectAllClassesRelocated(
+        ToolHelper.R8_WITH_DEPS_JAR, output, originalPrefix, newPrefix + ".");
   }
 
   @Test
@@ -90,7 +91,7 @@
         assertThrows(
             CompilationFailedException.class,
             () -> {
-              runRelocator(ToolHelper.R8_JAR, mapping, output);
+              runRelocator(ToolHelper.R8_WITH_DEPS_JAR, mapping, output);
             });
   }
 
@@ -102,9 +103,9 @@
     Path output = temp.newFile("output.jar").toPath();
     Map<String, String> mapping = new HashMap<>();
     mapping.put(originalPrefix, newPrefix);
-    runRelocator(ToolHelper.R8_JAR, mapping, output);
+    runRelocator(ToolHelper.R8_WITH_DEPS_JAR, mapping, output);
     // Assert that all classes are the same, have the same methods and debug info:
-    CodeInspector originalInspector = new CodeInspector(ToolHelper.R8_JAR);
+    CodeInspector originalInspector = new CodeInspector(ToolHelper.R8_WITH_DEPS_JAR);
     CodeInspector relocatedInspector = new CodeInspector(output);
     for (FoundClassSubject clazz : originalInspector.allClasses()) {
       ClassSubject relocatedClass = relocatedInspector.clazz(clazz.getFinalName());
@@ -146,8 +147,8 @@
     mapping.put("some.package.that.does.not.exist", "foo");
     mapping.put(originalPrefix, newPrefix);
     Path output = temp.newFile("output.jar").toPath();
-    runRelocator(ToolHelper.R8_JAR, mapping, output);
-    inspectAllClassesRelocated(ToolHelper.R8_JAR, output, originalPrefix, newPrefix);
+    runRelocator(ToolHelper.R8_WITH_DEPS_JAR, mapping, output);
+    inspectAllClassesRelocated(ToolHelper.R8_WITH_DEPS_JAR, output, originalPrefix, newPrefix);
   }
 
   @Test
@@ -161,7 +162,7 @@
     CompilationFailedException exception =
         assertThrows(
             CompilationFailedException.class,
-            () -> runRelocator(ToolHelper.R8_JAR, mapping, output));
+            () -> runRelocator(ToolHelper.R8_WITH_DEPS_JAR, mapping, output));
     assertThat(
         exception.getCause().getMessage(),
         containsString("can be relocated by multiple mappings."));
@@ -176,8 +177,8 @@
     mapping.put(originalPrefix, newPrefix);
     mapping.put(newPrefix, "qux");
     Path output = temp.newFile("output.jar").toPath();
-    runRelocator(ToolHelper.R8_JAR, mapping, output);
-    inspectAllClassesRelocated(ToolHelper.R8_JAR, output, originalPrefix, newPrefix);
+    runRelocator(ToolHelper.R8_WITH_DEPS_JAR, mapping, output);
+    inspectAllClassesRelocated(ToolHelper.R8_WITH_DEPS_JAR, output, originalPrefix, newPrefix);
     // Assert that no mappings of com.android.tools.r8 -> qux exists.
     CodeInspector inspector = new CodeInspector(output);
     assertFalse(
@@ -190,7 +191,7 @@
     Set<String> seenPackages = new HashSet<>();
     List<Pair<String, String>> packageMappings = new ArrayList<>();
     Map<String, String> mapping = new LinkedHashMap<>();
-    CodeInspector inspector = new CodeInspector(ToolHelper.R8_JAR);
+    CodeInspector inspector = new CodeInspector(ToolHelper.R8_WITH_DEPS_JAR);
     int packageNameCounter = 0;
     // Generate a mapping for each package name directly below com.android.tools.r8.
     for (FoundClassSubject clazz : inspector.allClasses()) {
@@ -211,10 +212,13 @@
       }
     }
     Path output = temp.newFile("output.jar").toPath();
-    runRelocator(ToolHelper.R8_JAR, mapping, output);
+    runRelocator(ToolHelper.R8_WITH_DEPS_JAR, mapping, output);
     for (Pair<String, String> packageMapping : packageMappings) {
       inspectAllClassesRelocated(
-          ToolHelper.R8_JAR, output, packageMapping.getFirst(), packageMapping.getSecond());
+          ToolHelper.R8_WITH_DEPS_JAR,
+          output,
+          packageMapping.getFirst(),
+          packageMapping.getSecond());
     }
   }
 
@@ -226,8 +230,8 @@
     Map<String, String> mapping = new LinkedHashMap<>();
     mapping.put(originalPrefix, newPrefix);
     Path output = temp.newFile("output.jar").toPath();
-    runRelocator(ToolHelper.R8_JAR, mapping, output);
-    inspectAllClassesRelocated(ToolHelper.R8_JAR, output, originalPrefix, originalPrefix);
+    runRelocator(ToolHelper.R8_WITH_DEPS_JAR, mapping, output);
+    inspectAllClassesRelocated(ToolHelper.R8_WITH_DEPS_JAR, output, originalPrefix, originalPrefix);
   }
 
   @Test
@@ -237,9 +241,9 @@
     Map<String, String> mapping = new LinkedHashMap<>();
     mapping.put(originalPrefix, newPrefix);
     Path output = temp.newFile("output.jar").toPath();
-    runRelocator(ToolHelper.R8_JAR, mapping, output);
+    runRelocator(ToolHelper.R8_WITH_DEPS_JAR, mapping, output);
     // Check that all classes has been remapped.
-    inspectAllClassesRelocated(ToolHelper.R8_JAR, output, originalPrefix, newPrefix);
+    inspectAllClassesRelocated(ToolHelper.R8_WITH_DEPS_JAR, output, originalPrefix, newPrefix);
     inspectAllSignaturesNotContainingString(output, originalPrefix);
     // We should be able to call the relocated relocator.
     Path bootstrapOutput = temp.newFile("bootstrap.jar").toPath();
@@ -259,7 +263,7 @@
     inspectAllClassesRelocated(output, bootstrapOutput, newPrefix, originalPrefix);
     inspectAllSignaturesNotContainingString(bootstrapOutput, newPrefix);
     // Assert that this is infact an identity transformation.
-    inspectAllClassesRelocated(ToolHelper.R8_JAR, bootstrapOutput, "", "");
+    inspectAllClassesRelocated(ToolHelper.R8_WITH_DEPS_JAR, bootstrapOutput, "", "");
   }
 
   @Test
@@ -269,9 +273,9 @@
     Path output = temp.newFile("output.jar").toPath();
     Map<String, String> mapping = new HashMap<>();
     mapping.put(originalPrefix, newPrefix);
-    runRelocator(ToolHelper.R8_WITH_RELOCATED_DEPS_11_JAR, mapping, output);
+    runRelocator(ToolHelper.R8_WITH_DEPS_11_JAR, mapping, output);
     // Assert that all classes are the same, have the same methods and nest info.
-    CodeInspector originalInspector = new CodeInspector(ToolHelper.R8_WITH_RELOCATED_DEPS_11_JAR);
+    CodeInspector originalInspector = new CodeInspector(ToolHelper.R8_WITH_DEPS_11_JAR);
     CodeInspector relocatedInspector = new CodeInspector(output);
     for (FoundClassSubject originalSubject : originalInspector.allClasses()) {
       ClassSubject relocatedSubject = relocatedInspector.clazz(originalSubject.getFinalName());
@@ -315,6 +319,8 @@
   private void inspectAllClassesRelocated(
       Path original, Path relocated, String originalPrefix, String newPrefix)
       throws IOException, ExecutionException {
+    assert !originalPrefix.endsWith("" + DescriptorUtils.JAVA_PACKAGE_SEPARATOR)
+        && !newPrefix.endsWith("" + DescriptorUtils.JAVA_PACKAGE_SEPARATOR);
     CodeInspector originalInspector = new CodeInspector(original);
     CodeInspector relocatedInspector = new CodeInspector(relocated);
     for (FoundClassSubject clazz : originalInspector.allClasses()) {
diff --git a/tools/test.py b/tools/test.py
index a75beb4..d6e4983 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -240,6 +240,8 @@
     gradle_args.append('--no-daemon')
 
   # Build an R8 with dependencies for bootstrapping tests before adding test sources.
+  gradle_args.append('r8WithDeps')
+  gradle_args.append('r8WithDeps11')
   gradle_args.append('r8WithRelocatedDeps')
   gradle_args.append('r8WithRelocatedDeps11')