Change location of kotlin r8 test resources for relocating
When running r8lib with relocated dependencies, the string
"kotlinR8TestResources" is changed to
"com.android.tools.R8.jetbrains.kotlinR8testResources" because of the
relocation added in build.gradle. After this CL, the location
r8KotlinTestResources have a capital K thus the string will not be
relocated.
Change-Id: Ib39aacdaa98845ea9c48d7e493eb8238c1fee1b8
diff --git a/build.gradle b/build.gradle
index e469e03..2e70b1e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1199,10 +1199,10 @@
kotlin.Kotlinc.KotlinTargetVersion.values().each { kotlinTargetVersion ->
def name = dir.getName()
def taskName = "jar_kotlinR8TestResources_${name}_${kotlinTargetVersion}"
- def outputFile = "build/test/kotlinR8TestResources/${kotlinTargetVersion}/${name}.jar"
- def javaOutput = "build/test/kotlinR8TestResources/${kotlinTargetVersion}/${name}/java"
+ def outputFile = "build/test/r8KotlinTestResources/${kotlinTargetVersion}/${name}.jar"
+ def javaOutput = "build/test/r8KotlinTestResources/${kotlinTargetVersion}/${name}/java"
def javaOutputJarName = "${name}.java.jar"
- def javaOutputJarDir = "build/test/kotlinR8TestResources/${kotlinTargetVersion}"
+ def javaOutputJarDir = "build/test/r8KotlinTestResources/${kotlinTargetVersion}"
task "${taskName}Kotlin"(type: kotlin.Kotlinc) {
source = fileTree(dir: file("${examplesDir}/${name}"),
include: ['**/*.kt', '**/*.java'])
diff --git a/src/test/java/com/android/tools/r8/KotlinTestBase.java b/src/test/java/com/android/tools/r8/KotlinTestBase.java
index 9139583..63dd265 100644
--- a/src/test/java/com/android/tools/r8/KotlinTestBase.java
+++ b/src/test/java/com/android/tools/r8/KotlinTestBase.java
@@ -9,7 +9,9 @@
import java.nio.file.Paths;
public abstract class KotlinTestBase extends TestBase {
- private static final String RSRC = "kotlinR8TestResources";
+ // It is important that Kotlin is capitalized, otherwise the string will be relocated when
+ // building tests for r8lib with relocated dependencies.
+ private static final String RSRC = "r8KotlinTestResources";
protected final KotlinTargetVersion targetVersion;
@@ -17,18 +19,21 @@
this.targetVersion = targetVersion;
}
- protected Path getKotlinJarFile(String folder) {
+ protected static Path getKotlinJarFile(String folder, KotlinTargetVersion targetVersion) {
return Paths.get(ToolHelper.TESTS_BUILD_DIR, RSRC,
targetVersion.getFolderName(), folder + FileUtils.JAR_EXTENSION);
}
- protected Path getJavaJarFile(String folder) {
+ protected Path getKotlinJarFile(String folder) {
+ return getKotlinJarFile(folder, targetVersion);
+ }
+
+ protected static Path getJavaJarFile(String folder, KotlinTargetVersion targetVersion) {
return Paths.get(ToolHelper.TESTS_BUILD_DIR, RSRC,
targetVersion.getFolderName(), folder + ".java" + FileUtils.JAR_EXTENSION);
}
- protected Path getMappingfile(String folder, String mappingFileName) {
- return Paths.get(ToolHelper.TESTS_DIR, RSRC, folder, mappingFileName);
+ protected Path getJavaJarFile(String folder) {
+ return getJavaJarFile(folder, targetVersion);
}
-
}
diff --git a/src/test/java/com/android/tools/r8/kotlin/AbstractR8KotlinTestBase.java b/src/test/java/com/android/tools/r8/kotlin/AbstractR8KotlinTestBase.java
index 9380115..4229213 100644
--- a/src/test/java/com/android/tools/r8/kotlin/AbstractR8KotlinTestBase.java
+++ b/src/test/java/com/android/tools/r8/kotlin/AbstractR8KotlinTestBase.java
@@ -10,9 +10,9 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import com.android.tools.r8.KotlinTestBase;
import com.android.tools.r8.OutputMode;
import com.android.tools.r8.R8Command;
-import com.android.tools.r8.TestBase;
import com.android.tools.r8.ToolHelper;
import com.android.tools.r8.ToolHelper.KotlinTargetVersion;
import com.android.tools.r8.graph.Code;
@@ -24,7 +24,6 @@
import com.android.tools.r8.utils.AndroidApp;
import com.android.tools.r8.utils.BooleanUtils;
import com.android.tools.r8.utils.DescriptorUtils;
-import com.android.tools.r8.utils.FileUtils;
import com.android.tools.r8.utils.InternalOptions;
import com.android.tools.r8.utils.codeinspector.ClassSubject;
import com.android.tools.r8.utils.codeinspector.CodeInspector;
@@ -32,7 +31,6 @@
import com.android.tools.r8.utils.codeinspector.MethodSubject;
import com.google.common.collect.ImmutableList;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -46,7 +44,7 @@
import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
-public abstract class AbstractR8KotlinTestBase extends TestBase {
+public abstract class AbstractR8KotlinTestBase extends KotlinTestBase {
// This is the name of the Jasmin-generated class which contains the "main" method which will
// invoke the tested method.
@@ -63,6 +61,10 @@
return buildParameters(BooleanUtils.values(), KotlinTargetVersion.values());
}
+ public AbstractR8KotlinTestBase() {
+ super(KotlinTargetVersion.JAVA_6);
+ }
+
protected void addExtraClasspath(Path path) {
extraClasspath.add(path);
}
@@ -230,8 +232,8 @@
// Build classpath for compilation (and java execution)
classpath.clear();
- classpath.add(getKotlinJarFile(folder));
- classpath.add(getJavaJarFile(folder));
+ classpath.add(getKotlinJarFile(folder, targetVersion));
+ classpath.add(getJavaJarFile(folder, targetVersion));
classpath.addAll(extraClasspath);
// Build with R8
@@ -296,16 +298,6 @@
}
}
- private Path getKotlinJarFile(String folder) {
- return Paths.get(ToolHelper.TESTS_BUILD_DIR, "kotlinR8TestResources",
- targetVersion.getFolderName(), folder + FileUtils.JAR_EXTENSION);
- }
-
- private Path getJavaJarFile(String folder) {
- return Paths.get(ToolHelper.TESTS_BUILD_DIR, "kotlinR8TestResources",
- targetVersion.getFolderName(), folder + ".java" + FileUtils.JAR_EXTENSION);
- }
-
@FunctionalInterface
interface AndroidAppInspector {