From ea6e7f59bc2ddcf00a5ecbd2c930ef4206a70f4b Mon Sep 17 00:00:00 2001 From: Sergio del Amo Date: Thu, 20 Nov 2025 17:49:12 +0100 Subject: [PATCH 1/3] Update README with Kotlin Gradle DSL example --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index ec2e4ead7a..eee2b212a9 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,37 @@ tasks.withType(JavaCompile) { } ``` +or to `build.gradle.kts` if you use the [Kotlin Gradle DSL](https://docs.gradle.org/current/userguide/kotlin_dsl.html): + +``kotlin +plugins { + // we assume you are already using the Java plugin + id("net.ltgt.errorprone") version "" +} +dependencies { + errorprone("com.uber.nullaway:nullaway:") + + // Some source of nullability annotations; JSpecify recommended, + // but others supported as well. + api("org.jspecify:jspecify:1.0.0") + + errorprone("com.google.errorprone:error_prone_core:") +} + +tasks.withType().configureEach { + options.errorprone { + check("NullAway", net.ltgt.gradle.errorprone.CheckSeverity.ERROR) + option("NullAway:AnnotatedPackages", "com.chessgamesarchive") + + // Disable NullAway on test code + if (name.lowercase().contains("test")) { + disable("NullAway") + } + } +} +``` + + Let's walk through this script step by step. The `plugins` section pulls in the [Gradle Error Prone plugin](https://github.com/tbroyer/gradle-errorprone-plugin) for Error Prone integration. In `dependencies`, the first `errorprone` line loads NullAway, and the `api` line loads the [JSpecify](https://jspecify.dev) library which provides suitable nullability annotations, e.g., `org.jspecify.annotations.Nullable`. NullAway allows for any `@Nullable` annotation to be used, so, e.g., `@Nullable` from the AndroidX annotations Library or JetBrains annotations is also fine. The second `errorprone` line sets the version of Error Prone is used. From 9e6f380028a7cba40d9fdcd568625db30b460cb2 Mon Sep 17 00:00:00 2001 From: Sergio del Amo Date: Thu, 20 Nov 2025 17:51:29 +0100 Subject: [PATCH 2/3] Update README.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eee2b212a9..96f5751de0 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ dependencies { tasks.withType().configureEach { options.errorprone { check("NullAway", net.ltgt.gradle.errorprone.CheckSeverity.ERROR) - option("NullAway:AnnotatedPackages", "com.chessgamesarchive") + option("NullAway:AnnotatedPackages", "com.uber") // Disable NullAway on test code if (name.lowercase().contains("test")) { From 1f31b8985e83781e93b41a18473d11cf16f7e628 Mon Sep 17 00:00:00 2001 From: Sergio del Amo Date: Thu, 20 Nov 2025 17:52:17 +0100 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 96f5751de0..dbcd9a5ce3 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ tasks.withType(JavaCompile) { or to `build.gradle.kts` if you use the [Kotlin Gradle DSL](https://docs.gradle.org/current/userguide/kotlin_dsl.html): -``kotlin +```kotlin plugins { // we assume you are already using the Java plugin id("net.ltgt.errorprone") version ""