Closed pwittchen closed 7 years ago
I followed instructions in README.md
and couldn't make it work quickly, so I decided to abandon this idea for now. We can consider that solution when it'll be more stable and working OOTB.
@pwittchen I'm a maintainer of NullAway. Is there a specific problem you ran into? Please feel free to file an issue if something didn't work as you expected; we can fix or try to clear up the docs
Hi, @msridhar. I simply followed the instructions in the NullAway project.
In my build.gradle I've added the following code:
allprojects {
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
}
Then, I've updated library/build.gradle file as follows:
apply plugin: 'com.android.library'
apply plugin: 'jacoco'
apply plugin: 'jacoco-android'
apply from: '../config/quality.gradle'
apply from: '../maven_push.gradle'
plugins {
id "net.ltgt.apt" version "0.11"
id "net.ltgt.errorprone" version "0.0.11"
id "java"
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.compileSdkVersion
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
testCoverageEnabled true
}
}
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE.txt'
}
testOptions {
unitTests.all {
jacoco {
includeNoLocationClasses = true
}
}
}
}
jacocoAndroidUnitTestReport {
csv.enabled false
html.enabled true
xml.enabled true
}
dependencies {
compile deps.rxjava2
compile deps.rxandroid2
compile deps.supportannotations
testCompile deps.junit
testCompile deps.truth
testCompile deps.robolectric
testCompile deps.mockitocore
apt "com.uber.nullaway:nullaway:0.1.2"
compile "com.google.code.findbugs:jsr305:3.0.2"
errorprone "com.google.errorprone:error_prone_core:2.1.1"
errorprone "org.checkerframework:dataflow:2.1.14"
}
compileJava {
options.compilerArgs += ["-Xep:NullAway:ERROR", "-XepOpt:NullAway:AnnotatedPackages=com.uber"]
}
task wrapper(type: Wrapper) {
gradleVersion = rootProject.ext.gradleVersion
}
Next, I've executed ./gradlew clean build
command and received the following error:
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
FAILURE: Build failed with an exception.
* Where:
Build file '/home/piotr/Development/android/projects/private/ReactiveNetwork/library/build.gradle' line: 7
* What went wrong:
Could not compile build file '/home/piotr/Development/android/projects/private/ReactiveNetwork/library/build.gradle'.
> startup failed:
build file '/home/piotr/Development/android/projects/private/ReactiveNetwork/library/build.gradle': 7: only buildscript {} and other plugins {} script blocks are allowed before plugins {} blocks, no other statements are allowed
See https://docs.gradle.org/3.3/userguide/plugins.html#sec:plugins_block for information on the plugins {} block
@ line 7, column 1.
plugins {
^
1 error
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Do you know how to fix that issue?
Hi, yeah, we need to clarify our README for your configuration a bit. One thing I notice is that you probably can't combine the apply plugin
syntax (older style) with the plugins
block (newer style). Also you don't need the id "java"
line for an Android library.
We are working on giving a better example for Android code. Once that's done, I'll ping back and we'll see if things work better.
Thanks, @msridhar. I tried to replace plugins sections with the apply syntax for your configurations, but I also received some errors. When you'll have some news, I'll be happy to see them.
PR with this update is in #226.
The code was updated and PR is merged.
See details here: https://github.com/uber/NullAway This library satisfies clean code principles and avoids passing null as a method parameter.