xref: /aosp_15_r20/external/nullaway/guava-recent-unit-tests/build.gradle (revision f50c306653bc89b8210ce6c9e0b0b44fc134bc03)
1/*
2 * Copyright (C) 2022. Uber Technologies
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *    http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16plugins {
17    id 'java-library'
18    id 'nullaway.java-test-conventions'
19}
20
21// We need this separate build target to test newer versions of Guava
22// (e.g. 31+) than that which NullAway currently depends on.
23
24dependencies {
25    testImplementation project(":nullaway")
26    testImplementation deps.test.junit4
27    testImplementation(deps.build.errorProneTestHelpers) {
28        exclude group: "junit", module: "junit"
29    }
30    testImplementation deps.build.jsr305Annotations
31    testImplementation "com.google.guava:guava:31.1-jre"
32}
33
34// Create a task to test on JDK 8
35def jdk8Test = tasks.register("testJdk8", Test) {
36    onlyIf {
37        // Only if we are using a version of Error Prone compatible with JDK 8
38        deps.versions.errorProneApi == "2.10.0"
39    }
40
41    javaLauncher = javaToolchains.launcherFor {
42        languageVersion = JavaLanguageVersion.of(8)
43    }
44
45    description = "Runs the test suite on JDK 8"
46    group = LifecycleBasePlugin.VERIFICATION_GROUP
47
48    // Copy inputs from normal Test task.
49    def testTask = tasks.getByName("test")
50    classpath = testTask.classpath
51    testClassesDirs = testTask.testClassesDirs
52    jvmArgs "-Xbootclasspath/p:${configurations.errorproneJavac.asPath}"
53}
54
55tasks.named('check').configure {
56    dependsOn(jdk8Test)
57}
58