Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checkerframework and errorprone #2941

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions build-logic/build-parameters/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
plugins {
id("org.gradlex.build-parameters") version "1.4.3"
}

buildParameters {
pluginId("testng.build-parameters")
bool("enableCheckerframework") {
defaultValue.set(false)
description.set("Run CheckerFramework (nullness) verifications")
}
bool("enableErrorprone") {
defaultValue.set(true)
description.set("Enable ErrorProne verifications")
}
}
2 changes: 2 additions & 0 deletions build-logic/code-quality/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ repositories {
dependencies {
implementation("org.sonarqube:org.sonarqube.gradle.plugin:2.8")
implementation("com.github.autostyle:autostyle-plugin-gradle:3.1")
implementation("org.checkerframework:checkerframework-gradle-plugin:0.6.29")
implementation("net.ltgt.gradle:gradle-errorprone-plugin:3.1.0")
}

tasks.withType<KotlinCompile>().configureEach {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import org.checkerframework.gradle.plugin.CheckerFrameworkExtension

plugins {
id("org.checkerframework")
}

dependencies {
checkerFramework("org.checkerframework:checker:3.36.0")
}

configure<CheckerFrameworkExtension> {
checkers = listOf(
"org.checkerframework.checker.nullness.NullnessChecker",
"org.checkerframework.checker.optional.OptionalChecker"
)
}

tasks.withType<JavaCompile>().configureEach {
// Don't run the checker on generated code.
if (name.startsWith("compileMainGenerated")) {
checkerFramework {
skipCheckerFramework = true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import net.ltgt.gradle.errorprone.errorprone

plugins {
id("net.ltgt.errorprone")
}

dependencies {
errorprone("com.google.errorprone:error_prone_core:2.20.0")
}

tasks.withType<JavaCompile>().configureEach {
options.errorprone.disableWarningsInGeneratedCode.set(true)
}
8 changes: 8 additions & 0 deletions build-logic/jvm/src/main/kotlin/testng.java.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
`java-base`
id("testng.versioning")
id("testng.style")
// id("testng.build-parameters") // Plugin [id: 'testng.build-parameters'] was not found
id("testng.repositories")
// Improves Gradle Test logging
// See https://github.com/vlsi/vlsi-release-plugins/tree/master/plugins/gradle-extensions-plugin
Expand All @@ -13,6 +14,13 @@ java {
targetCompatibility = JavaVersion.VERSION_11
}

if (true /*buildParameters.enableCheckerframework*/) {
apply(plugin = "testng.checkerframework")
}
if (true /*buildParameters.enableErrorprone*/) {
apply(plugin = "testng.errorprone")
}

tasks.withType<JavaCompile>().configureEach {
inputs.property("java.version", System.getProperty("java.version"))
inputs.property("java.vendor", System.getProperty("java.vendor"))
Expand Down
1 change: 1 addition & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dependencyResolutionManagement {
rootProject.name = "build-logic"

include(":basics")
include(":build-parameters")
include(":code-quality")
include(":jvm")
include(":publishing")
Loading