Add remaining simple examples
Bug: b/270105162
Change-Id: Iee14451d895acea5621656772eef5c1faab75dc1
diff --git a/.gitignore b/.gitignore
index 90f5857..acb3642 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,10 +12,12 @@
*~
.#*
.gradle/
+**/.gradle/
.gradle_user_home
.idea/
android-data*/
build/
+**/build/
buildSrc/out/
src/*/out
d8_r8/*/out
diff --git a/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt b/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt
index c5d5c76..ab4a518 100644
--- a/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt
+++ b/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt
@@ -108,21 +108,22 @@
fun Project.buildJavaExamplesJars(examplesName : String) : Task {
val outputFiles : MutableList<File> = mutableListOf()
val jarTasks : MutableList<Task> = mutableListOf()
- extensions
+ var testSourceSet = extensions
.getByType(JavaPluginExtension::class.java)
.sourceSets
// The TEST_SOURCE_SET_NAME is the source set defined by writing java { sourcesets.test { ... }}
.getByName(SourceSet.TEST_SOURCE_SET_NAME)
- .output
- .classesDirs
+ testSourceSet
+ .java
+ .sourceDirectories
.files
- .forEach { buildDir ->
- buildDir.listFiles(File::isDirectory)?.forEach {
- jarTasks.add(tasks.register<Jar>("jar-examples$examplesName-${it.name}") {
+ .forEach { srcDir ->
+ srcDir.listFiles(File::isDirectory)?.forEach { exampleDir ->
+ jarTasks.add(tasks.register<Jar>("jar-examples$examplesName-${exampleDir.name}") {
dependsOn("compileTestJava")
- archiveFileName.set("${it.name}.jar")
+ archiveFileName.set("${exampleDir.name}.jar")
destinationDirectory.set(getRoot().resolveAll("build", "test", "examples$examplesName"))
- from(it) {
+ from(testSourceSet.output.classesDirs.files.map{ it.resolve(exampleDir.name) }) {
include("**/*.class")
}
}.get())
@@ -251,6 +252,7 @@
const val junitVersion = "4.13-beta-2"
const val kotlinVersion = "1.8.10"
const val kotlinMetadataVersion = "0.6.2"
+ const val mockito = "2.10.0"
const val smaliVersion = "3.0.3"
}
@@ -267,6 +269,7 @@
"org.jetbrains.kotlinx:kotlinx-metadata-jvm:${Versions.kotlinMetadataVersion}" }
val kotlinStdLib by lazy { "org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlinVersion}" }
val kotlinReflect by lazy { "org.jetbrains.kotlin:kotlin-reflect:${Versions.kotlinVersion}" }
+ val mockito by lazy { "org.mockito:mockito-core:${Versions.mockito}" }
val smali by lazy { "com.android.tools.smali:smali:${Versions.smaliVersion}" }
val errorprone by lazy { "com.google.errorprone:error_prone_core:${Versions.errorproneVersion}" }
}
diff --git a/d8_r8/test/settings.gradle.kts b/d8_r8/test/settings.gradle.kts
index 5feddef..ed1f4ea 100644
--- a/d8_r8/test/settings.gradle.kts
+++ b/d8_r8/test/settings.gradle.kts
@@ -6,5 +6,13 @@
val root = rootProject.projectDir.parentFile
includeBuild(root.resolve("main"))
+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_examplesAndroidP"))
+includeBuild(root.resolve("test_modules").resolve("tests_java_examplesAndroidO"))
includeBuild(root.resolve("test_modules").resolve("tests_java_8"))
includeBuild(root.resolve("test_modules").resolve("tests_java_9"))
+includeBuild(root.resolve("test_modules").resolve("tests_java_10"))
+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"))
diff --git a/d8_r8/test_modules/tests_java_10/build.gradle.kts b/d8_r8/test_modules/tests_java_10/build.gradle.kts
new file mode 100644
index 0000000..f24610d
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_10/build.gradle.kts
@@ -0,0 +1,36 @@
+// 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.srcDir(root.resolveAll("src", "test", "examplesJava10"))
+ }
+ sourceCompatibility = JavaVersion.VERSION_1_10
+ targetCompatibility = JavaVersion.VERSION_1_10
+}
+
+dependencies { }
+
+// We just need to register the examples jars for it to be referenced by other modules.
+val buildExampleJars = buildJavaExamplesJars("Java10")
+
+tasks {
+ withType<JavaCompile> {
+ options.setFork(true)
+ options.forkOptions.memoryMaximumSize = "3g"
+ options.forkOptions.executable = getCompilerPath(Jdk.JDK_11)
+ }
+}
+
diff --git a/d8_r8/test_modules/tests_java_10/gradle.properties b/d8_r8/test_modules/tests_java_10/gradle.properties
new file mode 100644
index 0000000..1de43f9
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_10/gradle.properties
@@ -0,0 +1,17 @@
+# 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=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_10/settings.gradle.kts b/d8_r8/test_modules/tests_java_10/settings.gradle.kts
new file mode 100644
index 0000000..247cb9c
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_10/settings.gradle.kts
@@ -0,0 +1,5 @@
+// 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.
+
+rootProject.name = "tests_java_10"
diff --git a/d8_r8/test_modules/tests_java_11/build.gradle.kts b/d8_r8/test_modules/tests_java_11/build.gradle.kts
new file mode 100644
index 0000000..1ff3ea8
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_11/build.gradle.kts
@@ -0,0 +1,36 @@
+// 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.srcDir(root.resolveAll("src", "test", "examplesJava11"))
+ }
+ sourceCompatibility = JavaVersion.VERSION_11
+ targetCompatibility = JavaVersion.VERSION_11
+}
+
+dependencies { }
+
+// We just need to register the examples jars for it to be referenced by other modules.
+val buildExampleJars = buildJavaExamplesJars("Java11")
+
+tasks {
+ withType<JavaCompile> {
+ options.setFork(true)
+ options.forkOptions.memoryMaximumSize = "3g"
+ options.forkOptions.executable = getCompilerPath(Jdk.JDK_11)
+ }
+}
+
diff --git a/d8_r8/test_modules/tests_java_11/gradle.properties b/d8_r8/test_modules/tests_java_11/gradle.properties
new file mode 100644
index 0000000..1de43f9
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_11/gradle.properties
@@ -0,0 +1,17 @@
+# 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=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_11/settings.gradle.kts b/d8_r8/test_modules/tests_java_11/settings.gradle.kts
new file mode 100644
index 0000000..e737a8a
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_11/settings.gradle.kts
@@ -0,0 +1,5 @@
+// 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.
+
+rootProject.name = "tests_java_11"
diff --git a/d8_r8/test_modules/tests_java_17/build.gradle.kts b/d8_r8/test_modules/tests_java_17/build.gradle.kts
new file mode 100644
index 0000000..9e0f2b7
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_17/build.gradle.kts
@@ -0,0 +1,36 @@
+// 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.srcDir(root.resolveAll("src", "test", "examplesJava17"))
+ }
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
+}
+
+dependencies { }
+
+// We just need to register the examples jars for it to be referenced by other modules.
+val buildExampleJars = buildJavaExamplesJars("Java17")
+
+tasks {
+ withType<JavaCompile> {
+ options.setFork(true)
+ options.forkOptions.memoryMaximumSize = "3g"
+ options.forkOptions.executable = getCompilerPath(Jdk.JDK_17)
+ }
+}
+
diff --git a/d8_r8/test_modules/tests_java_17/gradle.properties b/d8_r8/test_modules/tests_java_17/gradle.properties
new file mode 100644
index 0000000..1de43f9
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_17/gradle.properties
@@ -0,0 +1,17 @@
+# 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=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_17/settings.gradle.kts b/d8_r8/test_modules/tests_java_17/settings.gradle.kts
new file mode 100644
index 0000000..aa2b7b1
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_17/settings.gradle.kts
@@ -0,0 +1,5 @@
+// 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.
+
+rootProject.name = "tests_java_17"
diff --git a/d8_r8/test_modules/tests_java_20/build.gradle.kts b/d8_r8/test_modules/tests_java_20/build.gradle.kts
new file mode 100644
index 0000000..85cd393
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_20/build.gradle.kts
@@ -0,0 +1,36 @@
+// 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.srcDir(root.resolveAll("src", "test", "examplesJava20"))
+ }
+ sourceCompatibility = JavaVersion.VERSION_20
+ targetCompatibility = JavaVersion.VERSION_20
+}
+
+dependencies { }
+
+// We just need to register the examples jars for it to be referenced by other modules.
+val buildExampleJars = buildJavaExamplesJars("Java20")
+
+tasks {
+ withType<JavaCompile> {
+ options.setFork(true)
+ options.forkOptions.memoryMaximumSize = "3g"
+ options.forkOptions.executable = getCompilerPath(Jdk.JDK_20)
+ }
+}
+
diff --git a/d8_r8/test_modules/tests_java_20/gradle.properties b/d8_r8/test_modules/tests_java_20/gradle.properties
new file mode 100644
index 0000000..1de43f9
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_20/gradle.properties
@@ -0,0 +1,17 @@
+# 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=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_20/settings.gradle.kts b/d8_r8/test_modules/tests_java_20/settings.gradle.kts
new file mode 100644
index 0000000..eaac41f
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_20/settings.gradle.kts
@@ -0,0 +1,5 @@
+// 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.
+
+rootProject.name = "tests_java_20"
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 97611fe..3493286 100644
--- a/d8_r8/test_modules/tests_java_8/build.gradle.kts
+++ b/d8_r8/test_modules/tests_java_8/build.gradle.kts
@@ -60,8 +60,16 @@
+ ThirdPartyDeps.androidVMs
+ ThirdPartyDeps.jdks)
-val sourceSetDependenciesTasks = listOf(
- projectTask("tests_java_9", getExamplesJarsTaskName("Java9")))
+val sourceSetDependenciesTasks = arrayOf(
+ projectTask("tests_java_examples", getExamplesJarsTaskName("")),
+ projectTask("tests_java_examplesAndroidN", getExamplesJarsTaskName("AndroidN")),
+ projectTask("tests_java_examplesAndroidO", getExamplesJarsTaskName("AndroidO")),
+ projectTask("tests_java_examplesAndroidP", getExamplesJarsTaskName("AndroidP")),
+ projectTask("tests_java_9", getExamplesJarsTaskName("Java9")),
+ projectTask("tests_java_10", getExamplesJarsTaskName("Java10")),
+ projectTask("tests_java_11", getExamplesJarsTaskName("Java11")),
+ projectTask("tests_java_17", getExamplesJarsTaskName("Java17")),
+ projectTask("tests_java_20", getExamplesJarsTaskName("Java20")))
fun testDependencies() : FileCollection {
return sourceSets
@@ -100,14 +108,15 @@
}
withType<Test> {
+ environment.put("USE_NEW_GRADLE_SETUP", "true")
dependsOn(thirdPartyRuntimeDependenciesTask)
- dependsOn(sourceSetDependenciesTasks)
+ dependsOn(*sourceSetDependenciesTasks)
println("NOTE: Number of processors " + Runtime.getRuntime().availableProcessors())
val userDefinedCoresPerFork = System.getenv("R8_GRADLE_CORES_PER_FORK")
val processors = Runtime.getRuntime().availableProcessors()
// See https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html.
if (!userDefinedCoresPerFork.isNullOrEmpty()) {
- maxParallelForks = userDefinedCoresPerFork.toInt()
+ maxParallelForks = processors / userDefinedCoresPerFork.toInt()
} else {
// On normal work machines this seems to give the best test execution time (without freezing)
maxParallelForks = processors / 3
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 ec3fab0..73f5d73 100644
--- a/d8_r8/test_modules/tests_java_8/settings.gradle.kts
+++ b/d8_r8/test_modules/tests_java_8/settings.gradle.kts
@@ -11,4 +11,13 @@
// will compete with the test to compile the source files.
includeBuild(root.resolve("main"))
+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_9"))
+includeBuild(root.resolve("test_modules").resolve("tests_java_10"))
+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"))
+
diff --git a/d8_r8/test_modules/tests_java_examples/build.gradle.kts b/d8_r8/test_modules/tests_java_examples/build.gradle.kts
new file mode 100644
index 0000000..05798be
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_examples/build.gradle.kts
@@ -0,0 +1,41 @@
+// 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)
+}
+
+// We just need to register the examples jars for it to be referenced by other modules.
+val buildExampleJars = buildJavaExamplesJars("")
+
+tasks {
+ withType<JavaCompile> {
+ options.setFork(true)
+ options.forkOptions.memoryMaximumSize = "3g"
+ options.forkOptions.jvmArgs = listOf(
+ "-Xss256m",
+ // Set the bootclass path so compilation is consistent with 1.8 target compatibility.
+ "-Xbootclasspath/a:third_party/openjdk/openjdk-rt-1.8/rt.jar")
+ }
+}
diff --git a/d8_r8/test_modules/tests_java_examples/gradle.properties b/d8_r8/test_modules/tests_java_examples/gradle.properties
new file mode 100644
index 0000000..1de43f9
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_examples/gradle.properties
@@ -0,0 +1,17 @@
+# 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=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
new file mode 100644
index 0000000..89c7a6f
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_examples/settings.gradle.kts
@@ -0,0 +1,5 @@
+// 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.
+
+rootProject.name = "tests_java_examples"
diff --git a/d8_r8/test_modules/tests_java_examplesAndroidN/build.gradle.kts b/d8_r8/test_modules/tests_java_examplesAndroidN/build.gradle.kts
new file mode 100644
index 0000000..8cfe7d2
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_examplesAndroidN/build.gradle.kts
@@ -0,0 +1,41 @@
+// 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 = buildJavaExamplesJars("AndroidN")
+
+tasks {
+ withType<JavaCompile> {
+ options.setFork(true)
+ options.forkOptions.memoryMaximumSize = "3g"
+ options.forkOptions.jvmArgs = listOf(
+ "-Xss256m",
+ // Set the bootclass path so compilation is consistent with 1.8 target compatibility.
+ "-Xbootclasspath/a:third_party/openjdk/openjdk-rt-1.8/rt.jar")
+ }
+}
diff --git a/d8_r8/test_modules/tests_java_examplesAndroidN/gradle.properties b/d8_r8/test_modules/tests_java_examplesAndroidN/gradle.properties
new file mode 100644
index 0000000..1de43f9
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_examplesAndroidN/gradle.properties
@@ -0,0 +1,17 @@
+# 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=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
new file mode 100644
index 0000000..d0f1704
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_examplesAndroidN/settings.gradle.kts
@@ -0,0 +1,5 @@
+// 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.
+
+rootProject.name = "tests_java_examplesAndroidN"
diff --git a/d8_r8/test_modules/tests_java_examplesAndroidO/build.gradle.kts b/d8_r8/test_modules/tests_java_examplesAndroidO/build.gradle.kts
new file mode 100644
index 0000000..44ed59d
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_examplesAndroidO/build.gradle.kts
@@ -0,0 +1,41 @@
+// 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
+}
+
+dependencies {
+ testCompileOnly(Deps.asm)
+}
+
+// We just need to register the examples jars for it to be referenced by other modules.
+val buildExampleJars = buildJavaExamplesJars("AndroidO")
+
+tasks {
+ withType<JavaCompile> {
+ options.setFork(true)
+ options.forkOptions.memoryMaximumSize = "3g"
+ options.forkOptions.jvmArgs = listOf(
+ "-Xss256m",
+ // Set the bootclass path so compilation is consistent with 1.8 target compatibility.
+ "-Xbootclasspath/a:third_party/openjdk/openjdk-rt-1.8/rt.jar")
+ }
+}
diff --git a/d8_r8/test_modules/tests_java_examplesAndroidO/gradle.properties b/d8_r8/test_modules/tests_java_examplesAndroidO/gradle.properties
new file mode 100644
index 0000000..1de43f9
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_examplesAndroidO/gradle.properties
@@ -0,0 +1,17 @@
+# 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=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
new file mode 100644
index 0000000..0faef5f
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_examplesAndroidO/settings.gradle.kts
@@ -0,0 +1,5 @@
+// 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.
+
+rootProject.name = "tests_java_examplesAndroidO"
diff --git a/d8_r8/test_modules/tests_java_examplesAndroidP/build.gradle.kts b/d8_r8/test_modules/tests_java_examplesAndroidP/build.gradle.kts
new file mode 100644
index 0000000..7e58f3b
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_examplesAndroidP/build.gradle.kts
@@ -0,0 +1,41 @@
+// 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 = buildJavaExamplesJars("AndroidP")
+
+tasks {
+ withType<JavaCompile> {
+ options.setFork(true)
+ options.forkOptions.memoryMaximumSize = "3g"
+ options.forkOptions.jvmArgs = listOf(
+ "-Xss256m",
+ // Set the bootclass path so compilation is consistent with 1.8 target compatibility.
+ "-Xbootclasspath/a:third_party/openjdk/openjdk-rt-1.8/rt.jar")
+ }
+}
diff --git a/d8_r8/test_modules/tests_java_examplesAndroidP/gradle.properties b/d8_r8/test_modules/tests_java_examplesAndroidP/gradle.properties
new file mode 100644
index 0000000..1de43f9
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_examplesAndroidP/gradle.properties
@@ -0,0 +1,17 @@
+# 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=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
new file mode 100644
index 0000000..6add507
--- /dev/null
+++ b/d8_r8/test_modules/tests_java_examplesAndroidP/settings.gradle.kts
@@ -0,0 +1,5 @@
+// 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.
+
+rootProject.name = "tests_java_examplesAndroidP"
diff --git a/src/test/java/com/android/tools/r8/ToolHelper.java b/src/test/java/com/android/tools/r8/ToolHelper.java
index 4883a0f..df4bcd9 100644
--- a/src/test/java/com/android/tools/r8/ToolHelper.java
+++ b/src/test/java/com/android/tools/r8/ToolHelper.java
@@ -1308,7 +1308,7 @@
public static Path getClassPathForTests() {
if (isNewGradleSetup()) {
- return Paths.get(TEST_MODULE_DIR, "tests_java_8", "build", "classes", "java", "main");
+ return Paths.get(TEST_MODULE_DIR, "tests_java_8", "build", "classes", "java", "test");
} else {
return Paths.get(BUILD_DIR, "classes", "java", "test");
}