From c9c1e8f02141c41fd5531afb1b79f40561a014ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Peltier?= Date: Tue, 17 Oct 2017 15:45:42 +0200 Subject: Enable error prone only on D8/R8 sources Change-Id: I6369f1450c433cba5249315e25d09bbda9a3c895 --- build.gradle | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'build.gradle') 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'] -- cgit v1.2.3