Skip to content

Commit

Permalink
Update Gradle, Error Prone plugin, and Android Gradle Plugin (#294)
Browse files Browse the repository at this point in the history
Modernizes the android example with the new lazy task configuration APIs. Based on implementation figured out here: uber/AutoDispose#330
  • Loading branch information
ZacSweers authored and lazaroclapp committed Apr 8, 2019
1 parent 244a587 commit 4d7b4d0
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 19 deletions.
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 @@ -37,7 +37,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 @@ -48,7 +47,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
17 changes: 16 additions & 1 deletion gradlew
@@ -1,4 +1,19 @@
#!/usr/bin/env sh
#
# 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 @@ -28,7 +43,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"'

# 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")
}
}
}

// 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")
}
}
}

0 comments on commit 4d7b4d0

Please sign in to comment.