diff options
author | Mikaël Peltier <mikaelpeltier@google.com> | 2017-10-17 15:45:42 +0200 |
---|---|---|
committer | Mikaël Peltier <mikaelpeltier@google.com> | 2017-10-17 15:45:42 +0200 |
commit | c9c1e8f02141c41fd5531afb1b79f40561a014ce (patch) | |
tree | 37a1757f2e2cca4a17e354adaf3803845f0dc7ec /build.gradle | |
parent | faee3a978d859241058a89ede1ab1dada035bfe9 (diff) | |
download | r8-c9c1e8f02141c41fd5531afb1b79f40561a014ce.tar.gz |
Enable error prone only on D8/R8 sources
Change-Id: I6369f1450c433cba5249315e25d09bbda9a3c895
Diffstat (limited to 'build.gradle')
-rw-r--r-- | build.gradle | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/build.gradle b/build.gradle index 4eb27ef33..583ae9ef4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ // Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import net.ltgt.gradle.errorprone.ErrorProneToolChain import org.gradle.internal.os.OperatingSystem import utils.Utils @@ -8,16 +9,15 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'com.google.protobuf' apply plugin: 'com.cookpad.android.licensetools' -if (project.hasProperty('with_error_prone')) { - apply plugin: "net.ltgt.errorprone" - tasks.withType(JavaCompile) { - options.compilerArgs += [ - '-XepDisableAllChecks', - '-Xep:ClassCanBeStatic:ERROR', - '-Xep:OperatorPrecedence:ERROR', - '-Xep:RemoveUnusedImports:ERROR'] - } -} +apply plugin: 'net.ltgt.errorprone-base' + +def errorProneConfiguration = [ + '-XepDisableAllChecks', + // D8 want to use reference equality, thus disable the checker explicitly + '-Xep:ReferenceEquality:OFF', + '-Xep:ClassCanBeStatic:WARN', + '-Xep:OperatorPrecedence:WARN', + '-Xep:RemoveUnusedImports:WARN'] apply from: 'copyAdditionalJctfCommonFiles.gradle' @@ -47,9 +47,7 @@ buildscript { // support java9. // classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1' classpath files("third_party/shadow/shadow-2.0.1.jar") - if (project.hasProperty('with_error_prone')) { - classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.13" - } + classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.13" } } @@ -352,6 +350,14 @@ tasks.withType(JavaCompile) { options.compilerArgs << '-Xlint:unchecked' } +if (!project.hasProperty('without_error_prone')) { + compileJava { + // Enable error prone for D8/R8 sources. + toolChain ErrorProneToolChain.create(project) + options.compilerArgs += errorProneConfiguration + } +} + compileJctfCommonJava { dependsOn 'copyAdditionalJctfCommonFiles' options.compilerArgs = ['-Xlint:none'] |