Migrate Kotlin runtime test dependencies to TestDeps. Change-Id: I44d564f735df58eeb042d6c9e92b7518388a59d3
diff --git a/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt b/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt index 9750a11..c568954 100644 --- a/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt +++ b/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt
@@ -559,7 +559,19 @@ ) public val jdwpTests: ThirdPartyDependency = ThirdPartyDependency("jdwp-tests", Paths.get("third_party", "jdwp-tests").toFile()) - public val kotlinCompilers: List<ThirdPartyDependency> = getThirdPartyKotlinCompilers() + public val kotlinCompiler1_3_72: ThirdPartyDependency = getThirdPartyKotlinCompiler("1.3.72") + public val kotlinCompiler1_4_20: ThirdPartyDependency = getThirdPartyKotlinCompiler("1.4.20") + public val kotlinCompiler1_5_0: ThirdPartyDependency = getThirdPartyKotlinCompiler("1.5.0") + public val kotlinCompiler1_6_0: ThirdPartyDependency = getThirdPartyKotlinCompiler("1.6.0") + public val kotlinCompiler1_7_0: ThirdPartyDependency = getThirdPartyKotlinCompiler("1.7.0") + public val kotlinCompiler1_8_0: ThirdPartyDependency = getThirdPartyKotlinCompiler("1.8.0") + public val kotlinCompiler1_9_21: ThirdPartyDependency = getThirdPartyKotlinCompiler("1.9.21") + public val kotlinCompiler2_0_20: ThirdPartyDependency = getThirdPartyKotlinCompiler("2.0.20") + public val kotlinCompiler2_1_10: ThirdPartyDependency = getThirdPartyKotlinCompiler("2.1.10") + public val kotlinCompiler2_2_0: ThirdPartyDependency = getThirdPartyKotlinCompiler("2.2.0") + public val kotlinCompiler2_3_10: ThirdPartyDependency = getThirdPartyKotlinCompiler("2.3.10") + public val kotlinCompiler2_4_20: ThirdPartyDependency = getThirdPartyKotlinCompiler("2.4.20") + public val kotlinCompilerDev: ThirdPartyDependency = getThirdPartyKotlinCompiler("dev") public val kotlinR8TestResources: ThirdPartyDependency = ThirdPartyDependency( "kotlinR8TestResources", @@ -842,23 +854,11 @@ ) } -private fun getThirdPartyKotlinCompilers(): List<ThirdPartyDependency> { - return listOf( - "kotlin-compiler-1.3.72", - "kotlin-compiler-1.4.20", - "kotlin-compiler-1.5.0", - "kotlin-compiler-1.6.0", - "kotlin-compiler-1.7.0", - "kotlin-compiler-1.8.0", - "kotlin-compiler-1.9.21", - "kotlin-compiler-2.0.20", - "kotlin-compiler-2.1.10", - "kotlin-compiler-2.2.0", - "kotlin-compiler-2.3.10", - "kotlin-compiler-2.4.20", - "kotlin-compiler-dev", - ) - .map { ThirdPartyDependency(it, Paths.get("third_party", "kotlin", it).toFile()) } +private fun getThirdPartyKotlinCompiler(version: String): ThirdPartyDependency { + return ThirdPartyDependency( + "kotlin-compiler-$version", + Paths.get("third_party", "kotlin", "kotlin-compiler-$version").toFile(), + ) } private fun getThirdPartyDesugarLibraryRelease(version: String): ThirdPartyDependency {
diff --git a/d8_r8/test_modules/testbase/build.gradle.kts b/d8_r8/test_modules/testbase/build.gradle.kts index 22b57f9..f66a3c4 100644 --- a/d8_r8/test_modules/testbase/build.gradle.kts +++ b/d8_r8/test_modules/testbase/build.gradle.kts
@@ -63,6 +63,19 @@ runtimeOnlyData(project(":third_party", "jdk21")) runtimeOnlyData(project(":third_party", "jdk25")) runtimeOnlyData(project(":third_party", "jdwpTests")) + runtimeOnlyData(project(":third_party", "kotlinCompiler1_3_72")) + runtimeOnlyData(project(":third_party", "kotlinCompiler1_4_20")) + runtimeOnlyData(project(":third_party", "kotlinCompiler1_5_0")) + runtimeOnlyData(project(":third_party", "kotlinCompiler1_6_0")) + runtimeOnlyData(project(":third_party", "kotlinCompiler1_7_0")) + runtimeOnlyData(project(":third_party", "kotlinCompiler1_8_0")) + runtimeOnlyData(project(":third_party", "kotlinCompiler1_9_21")) + runtimeOnlyData(project(":third_party", "kotlinCompiler2_0_20")) + runtimeOnlyData(project(":third_party", "kotlinCompiler2_1_10")) + runtimeOnlyData(project(":third_party", "kotlinCompiler2_2_0")) + runtimeOnlyData(project(":third_party", "kotlinCompiler2_3_10")) + runtimeOnlyData(project(":third_party", "kotlinCompiler2_4_20")) + runtimeOnlyData(project(":third_party", "kotlinCompilerDev")) runtimeOnlyData(project(":third_party", "kotlinR8TestResources")) runtimeOnlyData(project(":third_party", "proguard7_0_0")) runtimeOnlyData(project(":third_party", "proguard7_7_0"))
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 f4cc220..26036ea 100644 --- a/d8_r8/test_modules/tests_java_8/build.gradle.kts +++ b/d8_r8/test_modules/tests_java_8/build.gradle.kts
@@ -120,6 +120,7 @@ runtimeOnlyData(project(":third_party", "jdwpTests")) runtimeOnlyData(project(":third_party", "jsr223")) runtimeOnlyData(project(":third_party", "keepassdx")) + runtimeOnlyData(project(":third_party", "kotlinCompiler1_3_72")) runtimeOnlyData(project(":third_party", "nest")) runtimeOnlyData(project(":third_party", "newpipe")) runtimeOnlyData(project(":third_party", "nowinandroid"))
diff --git a/d8_r8/test_modules/tests_java_8/debug/build.gradle.kts b/d8_r8/test_modules/tests_java_8/debug/build.gradle.kts index e7b3044..3ade1be 100644 --- a/d8_r8/test_modules/tests_java_8/debug/build.gradle.kts +++ b/d8_r8/test_modules/tests_java_8/debug/build.gradle.kts
@@ -11,4 +11,5 @@ runtimeOnlyData(project(":third_party", "examplesAndroidN")) runtimeOnlyData(project(":third_party", "java8Runtime")) runtimeOnlyData(project(":third_party", "jdk9")) + runtimeOnlyData(project(":third_party", "kotlinCompiler2_4_20")) }
diff --git a/d8_r8/test_modules/tests_java_8/kotlin/build.gradle.kts b/d8_r8/test_modules/tests_java_8/kotlin/build.gradle.kts index 1462102..11a1583 100644 --- a/d8_r8/test_modules/tests_java_8/kotlin/build.gradle.kts +++ b/d8_r8/test_modules/tests_java_8/kotlin/build.gradle.kts
@@ -27,5 +27,7 @@ runtimeOnlyData(project(":third_party", "coreLambdaStubs")) runtimeOnlyData(project(":third_party", "java8Runtime")) runtimeOnlyData(project(":third_party", "jdk9")) + runtimeOnlyData(project(":third_party", "kotlinCompiler1_3_72")) + runtimeOnlyData(project(":third_party", "kotlinCompiler1_4_20")) runtimeOnlyData(project(":third_party", "kotlinxCoroutines")) }
diff --git a/d8_r8/test_modules/tests_java_8/shaking/build.gradle.kts b/d8_r8/test_modules/tests_java_8/shaking/build.gradle.kts index 274e5a2..6caccd8 100644 --- a/d8_r8/test_modules/tests_java_8/shaking/build.gradle.kts +++ b/d8_r8/test_modules/tests_java_8/shaking/build.gradle.kts
@@ -22,6 +22,7 @@ runtimeOnlyData(project(":third_party", "examplesAndroidN")) runtimeOnlyData(project(":third_party", "java8Runtime")) runtimeOnlyData(project(":third_party", "jdk9")) + runtimeOnlyData(project(":third_party", "kotlinCompiler1_3_72")) runtimeOnlyData(project(":third_party", "proguard7_0_0")) runtimeOnlyData(project(":third_party", "proguard7_7_0")) runtimeOnlyData(project(":third_party", "r8"))
diff --git a/d8_r8/third_party/build.gradle.kts b/d8_r8/third_party/build.gradle.kts index bf28c09..4dfedc2 100644 --- a/d8_r8/third_party/build.gradle.kts +++ b/d8_r8/third_party/build.gradle.kts
@@ -269,6 +269,60 @@ registerTestDep("keepassdx", ThirdPartyDeps.keepassdx, "KEEPASSDX") registerTestDep( + "kotlinCompiler1_3_72", + ThirdPartyDeps.kotlinCompiler1_3_72, + "KOTLIN_COMPILER_1_3_72", +) + +registerTestDep( + "kotlinCompiler1_4_20", + ThirdPartyDeps.kotlinCompiler1_4_20, + "KOTLIN_COMPILER_1_4_20", +) + +registerTestDep("kotlinCompiler1_5_0", ThirdPartyDeps.kotlinCompiler1_5_0, "KOTLIN_COMPILER_1_5_0") + +registerTestDep("kotlinCompiler1_6_0", ThirdPartyDeps.kotlinCompiler1_6_0, "KOTLIN_COMPILER_1_6_0") + +registerTestDep("kotlinCompiler1_7_0", ThirdPartyDeps.kotlinCompiler1_7_0, "KOTLIN_COMPILER_1_7_0") + +registerTestDep("kotlinCompiler1_8_0", ThirdPartyDeps.kotlinCompiler1_8_0, "KOTLIN_COMPILER_1_8_0") + +registerTestDep( + "kotlinCompiler1_9_21", + ThirdPartyDeps.kotlinCompiler1_9_21, + "KOTLIN_COMPILER_1_9_21", +) + +registerTestDep( + "kotlinCompiler2_0_20", + ThirdPartyDeps.kotlinCompiler2_0_20, + "KOTLIN_COMPILER_2_0_20", +) + +registerTestDep( + "kotlinCompiler2_1_10", + ThirdPartyDeps.kotlinCompiler2_1_10, + "KOTLIN_COMPILER_2_1_10", +) + +registerTestDep("kotlinCompiler2_2_0", ThirdPartyDeps.kotlinCompiler2_2_0, "KOTLIN_COMPILER_2_2_0") + +registerTestDep( + "kotlinCompiler2_3_10", + ThirdPartyDeps.kotlinCompiler2_3_10, + "KOTLIN_COMPILER_2_3_10", +) + +registerTestDep( + "kotlinCompiler2_4_20", + ThirdPartyDeps.kotlinCompiler2_4_20, + "KOTLIN_COMPILER_2_4_20", +) + +registerTestDep("kotlinCompilerDev", ThirdPartyDeps.kotlinCompilerDev, "KOTLIN_COMPILER_DEV") + +registerTestDep( "kotlinR8TestResources", ThirdPartyDeps.kotlinR8TestResources, "KOTLIN_R8_TEST_RESOURCES",
diff --git a/src/test/testbase/java/com/android/tools/r8/KotlinCompilerTool.java b/src/test/testbase/java/com/android/tools/r8/KotlinCompilerTool.java index c63eac4..6dece62 100644 --- a/src/test/testbase/java/com/android/tools/r8/KotlinCompilerTool.java +++ b/src/test/testbase/java/com/android/tools/r8/KotlinCompilerTool.java
@@ -32,13 +32,13 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.function.Consumer; +import java.util.function.Supplier; import java.util.jar.Manifest; import java.util.stream.Collectors; import java.util.zip.ZipFile; @@ -78,33 +78,33 @@ } public enum KotlinCompilerVersion implements Ordered<KotlinCompilerVersion> { - KOTLINC_1_3_72("kotlin-compiler-1.3.72", CLASS, JAVA_6), - KOTLINC_1_4_20("kotlin-compiler-1.4.20", CLASS, JAVA_6), + KOTLINC_1_3_72(TestDeps::getKotlinCompiler1_3_72Dir, CLASS, JAVA_6), + KOTLINC_1_4_20(TestDeps::getKotlinCompiler1_4_20Dir, CLASS, JAVA_6), // JVM target 1,8 default from Kotlin 1.5.0, // https://kotlinlang.org/docs/whatsnew15.html#new-default-jvm-target-1-8 - KOTLINC_1_5_0("kotlin-compiler-1.5.0", CLASS, JAVA_8), - KOTLINC_1_6_0("kotlin-compiler-1.6.0", CLASS, JAVA_8), - KOTLINC_1_7_0("kotlin-compiler-1.7.0", CLASS, JAVA_8), - KOTLINC_1_8_0("kotlin-compiler-1.8.0", CLASS, JAVA_8), - KOTLINC_1_9_21("kotlin-compiler-1.9.21", CLASS, JAVA_8), - KOTLINC_2_0_20("kotlin-compiler-2.0.20", INVOKE_DYNAMIC, JAVA_8), - KOTLINC_2_1_10("kotlin-compiler-2.1.10", INVOKE_DYNAMIC, JAVA_8), - KOTLINC_2_2_0("kotlin-compiler-2.2.0", INVOKE_DYNAMIC, JAVA_8), - KOTLINC_2_3_10("kotlin-compiler-2.3.10", INVOKE_DYNAMIC, JAVA_8), - KOTLINC_2_4_20("kotlin-compiler-2.4.20", INVOKE_DYNAMIC, JAVA_8), - KOTLIN_DEV("kotlin-compiler-dev", INVOKE_DYNAMIC, JAVA_8); + KOTLINC_1_5_0(TestDeps::getKotlinCompiler1_5_0Dir, CLASS, JAVA_8), + KOTLINC_1_6_0(TestDeps::getKotlinCompiler1_6_0Dir, CLASS, JAVA_8), + KOTLINC_1_7_0(TestDeps::getKotlinCompiler1_7_0Dir, CLASS, JAVA_8), + KOTLINC_1_8_0(TestDeps::getKotlinCompiler1_8_0Dir, CLASS, JAVA_8), + KOTLINC_1_9_21(TestDeps::getKotlinCompiler1_9_21Dir, CLASS, JAVA_8), + KOTLINC_2_0_20(TestDeps::getKotlinCompiler2_0_20Dir, INVOKE_DYNAMIC, JAVA_8), + KOTLINC_2_1_10(TestDeps::getKotlinCompiler2_1_10Dir, INVOKE_DYNAMIC, JAVA_8), + KOTLINC_2_2_0(TestDeps::getKotlinCompiler2_2_0Dir, INVOKE_DYNAMIC, JAVA_8), + KOTLINC_2_3_10(TestDeps::getKotlinCompiler2_3_10Dir, INVOKE_DYNAMIC, JAVA_8), + KOTLINC_2_4_20(TestDeps::getKotlinCompiler2_4_20Dir, INVOKE_DYNAMIC, JAVA_8), + KOTLIN_DEV(TestDeps::getKotlinCompilerDevDir, INVOKE_DYNAMIC, JAVA_8); public static final KotlinCompilerVersion MIN_SUPPORTED_VERSION = KOTLINC_2_2_0; public static final KotlinCompilerVersion MAX_SUPPORTED_VERSION = KOTLINC_2_2_0; public static final KotlinCompilerVersion[] DEV_COMPILERS = new KotlinCompilerVersion[] {KOTLINC_2_3_10, KOTLINC_2_4_20, KOTLIN_DEV}; - private final String folder; + private final Supplier<Path> folder; private final KotlinLambdaGeneration defaultLambdaGeneration; private final KotlinTargetVersion defaultTargetVersion; KotlinCompilerVersion( - String folder, + Supplier<Path> folder, KotlinLambdaGeneration defaultLambdaGeneration, KotlinTargetVersion defaultTargetVersion) { this.folder = folder; @@ -164,20 +164,19 @@ public static final class KotlinCompiler { private final String name; - private final Path lib; - private final Path compiler; + private final Supplier<Path> lib; + private final Supplier<Path> compiler; private final KotlinCompilerVersion compilerVersion; public KotlinCompiler(KotlinCompilerVersion compilerVersion) { - this.lib = - Paths.get(ToolHelper.THIRD_PARTY_DIR, "kotlin", compilerVersion.folder, "kotlinc", "lib"); - this.compiler = lib.resolve("kotlin-compiler.jar"); + this.lib = () -> compilerVersion.folder.get().resolve("kotlinc").resolve("lib"); + this.compiler = () -> getFolder().resolve("kotlin-compiler.jar"); this.compilerVersion = compilerVersion; this.name = compilerVersion.name(); } public KotlinCompiler(String name, Path compiler, KotlinCompilerVersion compilerVersion) { - this.compiler = compiler; + this.compiler = () -> compiler; this.lib = null; this.compilerVersion = compilerVersion; this.name = name; @@ -188,11 +187,11 @@ } public Path getCompiler() { - return compiler; + return compiler.get(); } public Path getFolder() { - return lib; + return lib.get(); } public boolean is(KotlinCompilerVersion version) { @@ -242,6 +241,7 @@ } public void checkClasspath() throws IOException { + Path compiler = getCompiler(); try (ZipFile zipFile = new ZipFile(compiler.toFile(), UTF_8)) { Manifest manifest = new Manifest(zipFile.getInputStream(zipFile.getEntry("META-INF/MANIFEST.MF")));
diff --git a/src/test/testbase/java/com/android/tools/r8/TestDeps.java b/src/test/testbase/java/com/android/tools/r8/TestDeps.java index f966d92..4745e14 100644 --- a/src/test/testbase/java/com/android/tools/r8/TestDeps.java +++ b/src/test/testbase/java/com/android/tools/r8/TestDeps.java
@@ -122,6 +122,19 @@ dependencies.put("JDWP_TESTS", null); dependencies.put("JSR223", null); dependencies.put("KEEPASSDX", null); + dependencies.put("KOTLIN_COMPILER_1_3_72", null); + dependencies.put("KOTLIN_COMPILER_1_4_20", null); + dependencies.put("KOTLIN_COMPILER_1_5_0", null); + dependencies.put("KOTLIN_COMPILER_1_6_0", null); + dependencies.put("KOTLIN_COMPILER_1_7_0", null); + dependencies.put("KOTLIN_COMPILER_1_8_0", null); + dependencies.put("KOTLIN_COMPILER_1_9_21", null); + dependencies.put("KOTLIN_COMPILER_2_0_20", null); + dependencies.put("KOTLIN_COMPILER_2_1_10", null); + dependencies.put("KOTLIN_COMPILER_2_2_0", null); + dependencies.put("KOTLIN_COMPILER_2_3_10", null); + dependencies.put("KOTLIN_COMPILER_2_4_20", null); + dependencies.put("KOTLIN_COMPILER_DEV", null); dependencies.put("KOTLIN_R8_TEST_RESOURCES", null); dependencies.put("KOTLINX_COROUTINES", null); dependencies.put("MULTIDEX", null); @@ -446,6 +459,58 @@ return getDependency("KEEPASSDX"); } + public static Path getKotlinCompiler1_3_72Dir() { + return getDependency("KOTLIN_COMPILER_1_3_72"); + } + + public static Path getKotlinCompiler1_4_20Dir() { + return getDependency("KOTLIN_COMPILER_1_4_20"); + } + + public static Path getKotlinCompiler1_5_0Dir() { + return getDependency("KOTLIN_COMPILER_1_5_0"); + } + + public static Path getKotlinCompiler1_6_0Dir() { + return getDependency("KOTLIN_COMPILER_1_6_0"); + } + + public static Path getKotlinCompiler1_7_0Dir() { + return getDependency("KOTLIN_COMPILER_1_7_0"); + } + + public static Path getKotlinCompiler1_8_0Dir() { + return getDependency("KOTLIN_COMPILER_1_8_0"); + } + + public static Path getKotlinCompiler1_9_21Dir() { + return getDependency("KOTLIN_COMPILER_1_9_21"); + } + + public static Path getKotlinCompiler2_0_20Dir() { + return getDependency("KOTLIN_COMPILER_2_0_20"); + } + + public static Path getKotlinCompiler2_1_10Dir() { + return getDependency("KOTLIN_COMPILER_2_1_10"); + } + + public static Path getKotlinCompiler2_2_0Dir() { + return getDependency("KOTLIN_COMPILER_2_2_0"); + } + + public static Path getKotlinCompiler2_3_10Dir() { + return getDependency("KOTLIN_COMPILER_2_3_10"); + } + + public static Path getKotlinCompiler2_4_20Dir() { + return getDependency("KOTLIN_COMPILER_2_4_20"); + } + + public static Path getKotlinCompilerDevDir() { + return getDependency("KOTLIN_COMPILER_DEV"); + } + public static Path getKotlinR8TestResourcesPath(String... path) { return getDependencyPath("KOTLIN_R8_TEST_RESOURCES", path); }