Skip to content

Instantly share code, notes, and snippets.

@msridhar
Last active May 31, 2021 23:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save msridhar/6cacd429567f1d1ad9a278e06809601c to your computer and use it in GitHub Desktop.
Save msridhar/6cacd429567f1d1ad9a278e06809601c to your computer and use it in GitHub Desktop.
self-contained build.gradle for using NullAway on an Android app
buildscript {
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
// for android gradle plugin 3
google()
}
dependencies {
classpath "com.android.tools.build:gradle:3.0.1"
classpath "net.ltgt.gradle:gradle-errorprone-plugin:1.2.1"
}
}
apply plugin: 'com.android.application'
apply plugin: 'net.ltgt.errorprone'
android {
compileSdkVersion 27
buildToolsVersion "27.0.2"
defaultConfig {
applicationId "com.uber.myapplication"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
lintOptions {
abortOnError false
}
}
dependencies {
compile "com.android.support:appcompat-v7:27.0.2"
testCompile "junit:junit:4.12"
annotationProcessor "com.uber.nullaway:nullaway:0.9.1"
errorprone "com.google.errorprone:error_prone_core:2.4.0"
errorproneJavac "com.google.errorprone:javac:9+181-r4173-1"
}
tasks.withType(JavaCompile) {
// remove the if condition if you want to run NullAway on test code
if (!name.toLowerCase().contains("test")) {
// remove "-Xep:NullAway:ERROR" to have NullAway only emit warnings
options.compilerArgs += ["-Xep:NullAway:ERROR", "-XepOpt:NullAway:AnnotatedPackages=com.uber"]
}
}
@hk0i
Copy link

hk0i commented Mar 21, 2019

Is this up-to-date? Wondering why we use 0.3.0 in this example but readme shows latest as 0.6.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment