blob: c57c7e2f209f3492654586ee9851bf08babb212d [file] [log] [blame]
/*
* Copyright (C) 2017. Uber Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import net.ltgt.gradle.errorprone.CheckSeverity
plugins {
id 'java-library'
id 'nullaway.jacoco-conventions'
}
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
configurations {
nullawayJar
}
dependencies {
compileOnly deps.apt.autoValueAnnot
annotationProcessor deps.apt.autoValue
compileOnly deps.apt.autoServiceAnnot
annotationProcessor deps.apt.autoService
compileOnly deps.build.errorProneCheckApi
implementation deps.build.checkerDataflow
implementation deps.build.guava
testImplementation deps.test.junit4
testImplementation(deps.build.errorProneTestHelpers) {
exclude group: "junit", module: "junit"
}
testImplementation deps.test.jetbrainsAnnotations
testImplementation deps.test.junit5Jupiter
testImplementation deps.test.cfQual
testImplementation deps.test.cfCompatQual
testImplementation project(":test-java-lib")
testImplementation deps.test.inferAnnotations
testImplementation deps.apt.jakartaInject
testImplementation deps.apt.javaxInject
testImplementation deps.test.rxjava2
testImplementation deps.test.commonsLang
testImplementation deps.test.commonsLang3
testImplementation project(":test-library-models")
testImplementation deps.test.lombok
testImplementation deps.test.springBeans
testImplementation deps.test.springContext
testImplementation deps.test.grpcCore
// This ends up being resolved to the NullAway jar under nullaway/build/libs
nullawayJar "com.uber.nullaway:nullaway:$VERSION_NAME"
}
javadoc {
failOnError = false
}
test {
maxHeapSize = "1024m"
if (!JavaVersion.current().java9Compatible) {
jvmArgs "-Xbootclasspath/p:${configurations.errorproneJavac.asPath}"
} else {
// to expose necessary JDK types on JDK 16+; see https://errorprone.info/docs/installation#java-9-and-newer
jvmArgs += [
"--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
// Accessed by Lombok tests
"--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED",
]
}
}
apply plugin: 'com.vanniktech.maven.publish'
// Create a task to build NullAway with NullAway checking enabled
// For some reason, this doesn't work on Java 8
if (JavaVersion.current() >= JavaVersion.VERSION_11) {
tasks.register('buildWithNullAway', JavaCompile) {
// Configure compilation to run with Error Prone and NullAway
source = sourceSets.main.java
classpath = sourceSets.main.compileClasspath
destinationDirectory = file("$buildDir/ignoredClasses")
def nullawayDeps = configurations.nullawayJar.asCollection()
options.annotationProcessorPath = files(
configurations.errorprone.asCollection(),
sourceSets.main.annotationProcessorPath,
nullawayDeps)
options.errorprone.enabled = true
options.errorprone {
option("NullAway:AnnotatedPackages", "com.uber")
}
// Make sure the jar has already been built
dependsOn 'jar'
// Check that the NullAway jar actually exists (without this,
// Gradle will run the compilation even if the jar doesn't exist)
doFirst {
nullawayDeps.forEach { f ->
assert f.exists()
}
}
}
}