Morten Krogh-Jespersen | 81c3408 | 2023-06-22 15:37:41 +0200 | [diff] [blame] | 1 | // Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file |
| 2 | // for details. All rights reserved. Use of this source code is governed by a |
| 3 | // BSD-style license that can be found in the LICENSE file. |
| 4 | |
| 5 | import org.gradle.api.JavaVersion |
Morten Krogh-Jespersen | 81c3408 | 2023-06-22 15:37:41 +0200 | [diff] [blame] | 6 | |
| 7 | plugins { |
| 8 | `kotlin-dsl` |
| 9 | `java-library` |
| 10 | id("dependencies-plugin") |
| 11 | } |
| 12 | |
| 13 | val root = getRoot() |
| 14 | |
| 15 | java { |
| 16 | sourceSets.test.configure { |
Søren Gjesse | 00a9274 | 2023-11-01 10:39:16 +0100 | [diff] [blame] | 17 | java.srcDir(root.resolveAll("src", "test", "examplesJava21")) |
Morten Krogh-Jespersen | 81c3408 | 2023-06-22 15:37:41 +0200 | [diff] [blame] | 18 | } |
Søren Gjesse | 00a9274 | 2023-11-01 10:39:16 +0100 | [diff] [blame] | 19 | sourceCompatibility = JavaVersion.VERSION_21 |
| 20 | targetCompatibility = JavaVersion.VERSION_21 |
Morten Krogh-Jespersen | 81c3408 | 2023-06-22 15:37:41 +0200 | [diff] [blame] | 21 | } |
| 22 | |
Clément Béra | 8407eed | 2024-04-22 11:00:19 +0200 | [diff] [blame] | 23 | val testbaseJavaCompileTask = projectTask("testbase", "compileJava") |
| 24 | val testbaseDepsJarTask = projectTask("testbase", "depsJar") |
| 25 | val mainCompileTask = projectTask("main", "compileJava") |
| 26 | |
| 27 | dependencies { |
| 28 | implementation(files(testbaseDepsJarTask.outputs.files.getSingleFile())) |
| 29 | implementation(testbaseJavaCompileTask.outputs.files) |
| 30 | implementation(mainCompileTask.outputs.files) |
Ian Zerny | f87ce83 | 2024-06-04 10:55:24 +0200 | [diff] [blame] | 31 | implementation(projectTask("main", "processResources").outputs.files) |
Clément Béra | 8407eed | 2024-04-22 11:00:19 +0200 | [diff] [blame] | 32 | } |
Morten Krogh-Jespersen | 81c3408 | 2023-06-22 15:37:41 +0200 | [diff] [blame] | 33 | |
| 34 | // We just need to register the examples jars for it to be referenced by other modules. |
Søren Gjesse | 00a9274 | 2023-11-01 10:39:16 +0100 | [diff] [blame] | 35 | val buildExampleJars = buildExampleJars("examplesJava21") |
Morten Krogh-Jespersen | 81c3408 | 2023-06-22 15:37:41 +0200 | [diff] [blame] | 36 | |
| 37 | tasks { |
| 38 | withType<JavaCompile> { |
Morten Krogh-Jespersen | d477fad | 2023-09-14 15:55:20 +0200 | [diff] [blame] | 39 | dependsOn(gradle.includedBuild("shared").task(":downloadDeps")) |
Morten Krogh-Jespersen | 81c3408 | 2023-06-22 15:37:41 +0200 | [diff] [blame] | 40 | options.setFork(true) |
| 41 | options.forkOptions.memoryMaximumSize = "3g" |
Søren Gjesse | 00a9274 | 2023-11-01 10:39:16 +0100 | [diff] [blame] | 42 | options.forkOptions.executable = getCompilerPath(Jdk.JDK_21) |
Morten Krogh-Jespersen | 81c3408 | 2023-06-22 15:37:41 +0200 | [diff] [blame] | 43 | } |
Clément Béra | 8407eed | 2024-04-22 11:00:19 +0200 | [diff] [blame] | 44 | |
| 45 | withType<Test> { |
Søren Gjesse | 8e1222c | 2024-04-23 15:20:54 +0200 | [diff] [blame] | 46 | notCompatibleWithConfigurationCache( |
| 47 | "Failure storing the configuration cache: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache") |
Clément Béra | 8407eed | 2024-04-22 11:00:19 +0200 | [diff] [blame] | 48 | TestingState.setUpTestingState(this) |
| 49 | javaLauncher = getJavaLauncher(Jdk.JDK_21) |
| 50 | systemProperty("TEST_DATA_LOCATION", |
| 51 | // This should be |
| 52 | // layout.buildDirectory.dir("classes/java/test").get().toString() |
| 53 | // once the use of 'buildExampleJars' above is removed. |
| 54 | getRoot().resolveAll("build", "test", "examplesJava21", "classes")) |
| 55 | systemProperty("TESTBASE_DATA_LOCATION", |
| 56 | testbaseJavaCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0]) |
| 57 | } |
Søren Gjesse | d4e829c | 2024-11-29 14:29:37 +0100 | [diff] [blame] | 58 | |
| 59 | val testJar by registering(Jar::class) { |
| 60 | from(sourceSets.test.get().output) |
| 61 | // TODO(b/296486206): Seems like IntelliJ has a problem depending on test source sets. Renaming |
| 62 | // this from the default name (tests_java_8.jar) will allow IntelliJ to find the resources in |
| 63 | // the jar and not show red underlines. However, navigation to base classes will not work. |
| 64 | archiveFileName.set("not_named_tests_java_21.jar") |
| 65 | } |
Morten Krogh-Jespersen | 81c3408 | 2023-06-22 15:37:41 +0200 | [diff] [blame] | 66 | } |
| 67 | |