Last active
May 31, 2021 23:47
-
-
Save msridhar/6cacd429567f1d1ad9a278e06809601c to your computer and use it in GitHub Desktop.
self-contained build.gradle for using NullAway on an Android app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is this up-to-date? Wondering why we use
0.3.0
in this example but readme shows latest as0.6.6
.