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

Update Gradle, Error Prone plugin, and Android Gradle Plugin #294

Merged
merged 3 commits into from Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -8,7 +8,7 @@ android:
components:
- tools
- platform-tools
- build-tools-28.0.2
- build-tools-28.0.3
- android-28

before_install:
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Expand Up @@ -18,10 +18,10 @@ import net.ltgt.gradle.errorprone.CheckSeverity

plugins {
id "com.github.sherter.google-java-format" version "0.8"
id "net.ltgt.errorprone" version "0.6" apply false
id "net.ltgt.errorprone" version "0.7" apply false
id "com.github.johnrengelman.shadow" version "2.0.4" apply false
id 'com.github.kt3k.coveralls' version '2.6.3' apply false
id 'com.android.application' version '3.1.4' apply false
id 'com.android.application' version '3.3.1' apply false
}

repositories {
Expand Down
3 changes: 1 addition & 2 deletions gradle/dependencies.gradle
Expand Up @@ -36,7 +36,6 @@ def build = [
errorProneTestHelpers : "com.google.errorprone:error_prone_test_helpers:${versions.errorProne}",
checkerDataflow : ["org.checkerframework:dataflow:${versions.checkerFramework}",
"org.checkerframework:javacutil:${versions.checkerFramework}"],
gradleErrorPronePlugin : "net.ltgt.gradle:gradle-errorprone-plugin:0.0.16",
guava : "com.google.guava:guava:22.0",
javaxValidation : "javax.validation:validation-api:2.0.1.Final",
jsr305Annotations : "com.google.code.findbugs:jsr305:3.0.2",
Expand All @@ -47,7 +46,7 @@ def build = [
commonscli : "commons-cli:commons-cli:${versions.commonscli}",

// android stuff
buildToolsVersion: "28.0.2",
buildToolsVersion: "28.0.3",
compileSdkVersion: 28,
ci: "true" == System.getenv("CI"),
minSdkVersion: 16,
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.3.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
19 changes: 16 additions & 3 deletions gradlew
@@ -1,7 +1,20 @@
#!/usr/bin/env sh

# added manually
./config/hooks/install-pre-commit
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this the GJF hook installer? Why are we getting rid of it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lazaroclapp I just opened #297 on this. We should find a different way to do this. gradlew is an auto-generated file so this was a hack all along.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vote we re-add this for now, then we remove it again at the same time as we implement #297

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but then let's land #298 before this one. We really shouldn't let master be red with respect to this, hack or not :)

#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

##############################################################################
##
Expand Down Expand Up @@ -31,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems very very low, but if it works for building NullAway, then all the better, I suppose.


# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
Expand Down
18 changes: 17 additions & 1 deletion gradlew.bat
@@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
Expand All @@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
Expand Down
35 changes: 24 additions & 11 deletions sample-app/build.gradle
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import com.android.build.gradle.api.BaseVariant
import net.ltgt.gradle.errorprone.CheckSeverity

plugins {
Expand All @@ -39,6 +40,29 @@ android {
lintOptions {
abortOnError false
}

DomainObjectSet<BaseVariant> variants = getApplicationVariants() // or getLibraryVariants() in libraries
variants.addAll(getTestVariants())
variants.addAll(getUnitTestVariants())
variants.configureEach { variant ->
variant.getJavaCompileProvider().configure {
options.errorprone {
check("NullAway", CheckSeverity.ERROR)
option("NullAway:AnnotatedPackages", "com.uber")
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we tried manually injecting a null dereference on the sample app and seeing that NullAway does trigger on it? (e.g. uncomment https://github.com/uber/NullAway/blob/master/sample-app/src/main/java/com/uber/myapplication/MainActivity.java#L33 do .\gradlew build, observe error).

I am not sure we have integration tests for this config, so is worth doing that small manual sanity check :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ZacSweers, would you mind rebasing and testing this? After that I'd be glad to merge this.

Edit: Actually, never mind, testing it now :)


// If you want to disable NullAway in justs tests, you can do the below
// DomainObjectSet<BaseVariant> testVariants = getTestVariants()
// testVariants.addAll(getUnitTestVariants())
// testVariants.configureEach { variant ->
// variant.getJavaCompileProvider().configure {
// options.errorprone {
// check("NullAway", CheckSeverity.OFF)
// }
// }
// }
}

dependencies {
Expand All @@ -49,14 +73,3 @@ dependencies {
testImplementation deps.test.junit4

}

tasks.withType(JavaCompile) {
// remove the if condition if you want to run NullAway on test code
if (!name.toLowerCase().contains("test")) {
options.errorprone {
check("NullAway", CheckSeverity.ERROR)
option("NullAway:AnnotatedPackages", "com.uber")
}
}
}