blob: 71702b7df76c72af608736a5e3899df680ea2acf [file] [log] [blame]
Morten Krogh-Jespersen81c34082023-06-22 15:37:41 +02001// 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
5import org.gradle.api.JavaVersion
Morten Krogh-Jespersen81c34082023-06-22 15:37:41 +02006
7plugins {
8 `kotlin-dsl`
9 `java-library`
10 id("dependencies-plugin")
11}
12
13val root = getRoot()
14
15java {
16 sourceSets.test.configure {
Søren Gjesse00a92742023-11-01 10:39:16 +010017 java.srcDir(root.resolveAll("src", "test", "examplesJava21"))
Morten Krogh-Jespersen81c34082023-06-22 15:37:41 +020018 }
Søren Gjesse00a92742023-11-01 10:39:16 +010019 sourceCompatibility = JavaVersion.VERSION_21
20 targetCompatibility = JavaVersion.VERSION_21
Morten Krogh-Jespersen81c34082023-06-22 15:37:41 +020021}
22
Clément Béra8407eed2024-04-22 11:00:19 +020023val testbaseJavaCompileTask = projectTask("testbase", "compileJava")
24val testbaseDepsJarTask = projectTask("testbase", "depsJar")
25val mainCompileTask = projectTask("main", "compileJava")
26
27dependencies {
28 implementation(files(testbaseDepsJarTask.outputs.files.getSingleFile()))
29 implementation(testbaseJavaCompileTask.outputs.files)
30 implementation(mainCompileTask.outputs.files)
Ian Zernyf87ce832024-06-04 10:55:24 +020031 implementation(projectTask("main", "processResources").outputs.files)
Clément Béra8407eed2024-04-22 11:00:19 +020032}
Morten Krogh-Jespersen81c34082023-06-22 15:37:41 +020033
34// We just need to register the examples jars for it to be referenced by other modules.
Søren Gjesse00a92742023-11-01 10:39:16 +010035val buildExampleJars = buildExampleJars("examplesJava21")
Morten Krogh-Jespersen81c34082023-06-22 15:37:41 +020036
37tasks {
38 withType<JavaCompile> {
Morten Krogh-Jespersend477fad2023-09-14 15:55:20 +020039 dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
Morten Krogh-Jespersen81c34082023-06-22 15:37:41 +020040 options.setFork(true)
41 options.forkOptions.memoryMaximumSize = "3g"
Søren Gjesse00a92742023-11-01 10:39:16 +010042 options.forkOptions.executable = getCompilerPath(Jdk.JDK_21)
Morten Krogh-Jespersen81c34082023-06-22 15:37:41 +020043 }
Clément Béra8407eed2024-04-22 11:00:19 +020044
45 withType<Test> {
Søren Gjesse8e1222c2024-04-23 15:20:54 +020046 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éra8407eed2024-04-22 11:00:19 +020048 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 Gjessed4e829c2024-11-29 14:29:37 +010058
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-Jespersen81c34082023-06-22 15:37:41 +020066}
67