xref: /aosp_15_r20/external/nullaway/jdk-recent-unit-tests/build.gradle (revision f50c306653bc89b8210ce6c9e0b0b44fc134bc03)
1*f50c3066SAndroid Build Coastguard Worker/*
2*f50c3066SAndroid Build Coastguard Worker * Copyright (C) 2021. Uber Technologies
3*f50c3066SAndroid Build Coastguard Worker *
4*f50c3066SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*f50c3066SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*f50c3066SAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*f50c3066SAndroid Build Coastguard Worker *
8*f50c3066SAndroid Build Coastguard Worker *    http://www.apache.org/licenses/LICENSE-2.0
9*f50c3066SAndroid Build Coastguard Worker *
10*f50c3066SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*f50c3066SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*f50c3066SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*f50c3066SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*f50c3066SAndroid Build Coastguard Worker * limitations under the License.
15*f50c3066SAndroid Build Coastguard Worker */
16*f50c3066SAndroid Build Coastguard Workerplugins {
17*f50c3066SAndroid Build Coastguard Worker    id 'java-library'
18*f50c3066SAndroid Build Coastguard Worker    id 'nullaway.java-test-conventions'
19*f50c3066SAndroid Build Coastguard Worker}
20*f50c3066SAndroid Build Coastguard Worker
21*f50c3066SAndroid Build Coastguard Worker// Use JDK 21 for this module, via a toolchain
22*f50c3066SAndroid Build Coastguard Worker// We must null out sourceCompatibility and targetCompatibility to use toolchains.
23*f50c3066SAndroid Build Coastguard Workerjava.sourceCompatibility = null
24*f50c3066SAndroid Build Coastguard Workerjava.targetCompatibility = null
25*f50c3066SAndroid Build Coastguard Workerjava.toolchain.languageVersion.set JavaLanguageVersion.of(21)
26*f50c3066SAndroid Build Coastguard Worker
27*f50c3066SAndroid Build Coastguard Workerconfigurations {
28*f50c3066SAndroid Build Coastguard Worker    // We use this configuration to expose a module path that can be
29*f50c3066SAndroid Build Coastguard Worker    // used to test analysis of module-info.java files.
30*f50c3066SAndroid Build Coastguard Worker    // See com.uber.nullaway.jdk17.NullAwayModuleInfoTests
31*f50c3066SAndroid Build Coastguard Worker    testModulePath
32*f50c3066SAndroid Build Coastguard Worker}
33*f50c3066SAndroid Build Coastguard Worker
34*f50c3066SAndroid Build Coastguard Workerdependencies {
35*f50c3066SAndroid Build Coastguard Worker    testImplementation project(":nullaway")
36*f50c3066SAndroid Build Coastguard Worker    testImplementation deps.test.junit4
37*f50c3066SAndroid Build Coastguard Worker    testImplementation deps.test.junit5Jupiter
38*f50c3066SAndroid Build Coastguard Worker    testImplementation deps.test.assertJ
39*f50c3066SAndroid Build Coastguard Worker    testImplementation(deps.build.errorProneTestHelpers) {
40*f50c3066SAndroid Build Coastguard Worker        exclude group: "junit", module: "junit"
41*f50c3066SAndroid Build Coastguard Worker    }
42*f50c3066SAndroid Build Coastguard Worker    testImplementation deps.build.jsr305Annotations
43*f50c3066SAndroid Build Coastguard Worker    testModulePath deps.test.cfQual
44*f50c3066SAndroid Build Coastguard Worker}
45*f50c3066SAndroid Build Coastguard Worker
46*f50c3066SAndroid Build Coastguard Workertest {
47*f50c3066SAndroid Build Coastguard Worker    jvmArgs += [
48*f50c3066SAndroid Build Coastguard Worker        // Expose a module path for tests as a JVM property.
49*f50c3066SAndroid Build Coastguard Worker        // Used by com.uber.nullaway.jdk17.NullAwayModuleInfoTests
50*f50c3066SAndroid Build Coastguard Worker        "-Dtest.module.path=${configurations.testModulePath.asPath}"
51*f50c3066SAndroid Build Coastguard Worker    ]
52*f50c3066SAndroid Build Coastguard Worker}
53*f50c3066SAndroid Build Coastguard Worker
54*f50c3066SAndroid Build Coastguard Workertasks.getByName('testJdk21').configure {
55*f50c3066SAndroid Build Coastguard Worker    // We don't need this task since we already run the tests on JDK 21
56*f50c3066SAndroid Build Coastguard Worker    onlyIf { false }
57*f50c3066SAndroid Build Coastguard Worker}
58