3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-12-24 23:30:26 +01:00
Velocity/gradle/checkerframework.gradle

71 Zeilen
3.4 KiB
Groovy

2018-10-28 02:45:42 +01:00
///////////////////////////////////////////////////////////////////////////
/// Checker Framework pluggable type-checking
///
repositories {
mavenCentral()
}
configurations {
checkerFrameworkCheckerJar {
description = 'the Checker Framework, including the Type Annotations compiler'
}
checkerFrameworkAnnotatedJDK {
description = 'a copy of JDK classes with Checker Framework type qualifers inserted'
}
}
// By default, use Checker Framework from Maven Central.
// Pass -PcfLocal to use a locally-built version of the Checker Framework.
dependencies {
if (!rootProject.hasProperty('cfLocal')) {
checkerFrameworkAnnotatedJDK "org.checkerframework:jdk8:${checkerFrameworkVersion}"
checkerFrameworkCheckerJar "org.checkerframework:checker:${checkerFrameworkVersion}"
implementation "org.checkerframework:checker-qual:${checkerFrameworkVersion}"
} else if (System.getenv("CHECKERFRAMEWORK") == null) {
throw new GradleException("Environment variable CHECKERFRAMEWORK is not set")
} else if (!file(System.getenv("CHECKERFRAMEWORK")).exists()) {
2018-10-28 02:45:42 +01:00
throw new GradleException("Environment variable CHECKERFRAMEWORK is set to non-existent directory " + System.getenv("CHECKERFRAMEWORK"));
} else {
ext.checkerframeworkdist = "$System.env.CHECKERFRAMEWORK/checker/dist"
checkerFrameworkAnnotatedJDK fileTree(dir: "${ext.checkerframeworkdist}", include: "jdk8.jar")
checkerFrameworkCheckerJar fileTree(dir: "${ext.checkerframeworkdist}", include: 'checker.jar')
implementation fileTree(dir: "${ext.checkerframeworkdist}", include: 'checker-qual.jar')
}
}
// // To type-check all projects.
// allprojects {
// tasks.withType(JavaCompile).all { JavaCompile compile ->
// compile.doFirst {
// compile.options.compilerArgs = [
// '-processor', 'org.checkerframework.checker.formatter.FormatterChecker,org.checkerframework.checker.index.IndexChecker,org.checkerframework.checker.lock.LockChecker,org.checkerframework.checker.nullness.NullnessChecker,org.checkerframework.checker.signature.SignatureChecker',
// '-Xmaxerrs', '10000',
// '-Awarns', // -Awarns turns Checker Framework errors into warnings
// '-AcheckPurityAnnotations',
// '-processorpath', "${configurations.checkerFrameworkCheckerJar.asPath}",
// "-Xbootclasspath/p:${configurations.checkerFrameworkAnnotatedJDK.asPath}",
// "-Astubs=$System.env.CHECKERFRAMEWORK/checker/resources/javadoc.astub" // TODO: does not work when downloading from Maven Central
// ]
// }
// }
// }
// To typecheck only the current project's main source set (in a multi-project
// build), use this instead:
compileJava {
doFirst {
options.compilerArgs = [
'-processor', 'org.checkerframework.checker.nullness.NullnessChecker',
'-processor', 'org.checkerframework.checker.optional.OptionalChecker',
'-Xmaxerrs', '10000',
'-Xmaxwarns', '10000',
// '-Awarns', // -Awarns turns Checker Framework errors into warnings
//'-AcheckPurityAnnotations', // Disabled for Velocity, wish we could do better
'-processorpath', "${configurations.checkerFrameworkCheckerJar.asPath}",
"-Xbootclasspath/p:${configurations.checkerFrameworkAnnotatedJDK.asPath}"
]
}
}