Skip to content

Commit 8f529e4

Browse files
committed
Enable errorprone only by request.
The motivation is that errorprone produces different bytecode than javac this confuses retrolambda's desugaring where it fails to correctly desugar try-with-resources. To enable errorprone one needs to run: ``` ./gradlew :mylib:mytask withErrorProne ```
1 parent 4498fcc commit 8f529e4

File tree

3 files changed

+42
-11
lines changed

3 files changed

+42
-11
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ Firebase Android libraries exercise all three types of tests recommended by the
6363
Depending on the requirements of the specific project, some or all of these
6464
tests may be used to support changes.
6565

66+
> :warning: **Running tests with errorprone**
67+
>
68+
> To run with errorprone add `withErrorProne` to the command line, e.g.
69+
>
70+
> `./gradlew :<firebase-project>:check withErrorProne`.
71+
6672
### Unit Testing
6773

6874
These are tests that run on your machine's local Java Virtual Machine (JVM). At

build.gradle

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ buildscript {
4343
}
4444

4545
apply from: 'sdkProperties.gradle'
46+
apply from: "gradle/errorProne.gradle"
4647

4748
ext {
4849
playServicesVersion = '16.0.1'
4950
supportAnnotationsVersion = '28.0.0'
50-
errorproneVersion = '2.3.2'
51-
errorproneJavacVersion = '9+181-r4173-1'
5251
googleTruthVersion = '0.45'
5352
robolectricVersion = '4.1'
5453
}
@@ -72,12 +71,7 @@ configure(subprojects) {
7271
jcenter()
7372
mavenLocal()
7473
}
75-
apply plugin: 'net.ltgt.errorprone'
76-
dependencies {
77-
errorprone "com.google.errorprone:error_prone_core:$errorproneVersion"
78-
errorproneJavac "com.google.errorprone:javac:$errorproneJavacVersion"
7974

80-
}
8175
apply plugin: 'com.github.sherter.google-java-format'
8276
googleJavaFormat {
8377
toolVersion = '1.7'
@@ -99,10 +93,6 @@ configure(subprojects) {
9993
exclude '**/package-info.java'
10094
}
10195

102-
tasks.withType(JavaCompile) {
103-
options.errorprone.excludedPaths = '.*/build/generated/.*'
104-
}
105-
10696
apply plugin: "org.jlleitschuh.gradle.ktlint"
10797
}
10898

gradle/errorProne.gradle

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2020 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
def isErrorProneRequested = getGradle().getStartParameter().getTaskNames().contains("withErrorProne")
16+
17+
def errorproneVersion = '2.3.2'
18+
def errorproneJavacVersion = '9+181-r4173-1'
19+
20+
if (isErrorProneRequested) {
21+
configure(subprojects) {
22+
apply plugin: 'net.ltgt.errorprone'
23+
dependencies {
24+
errorprone "com.google.errorprone:error_prone_core:$errorproneVersion"
25+
errorproneJavac "com.google.errorprone:javac:$errorproneJavacVersion"
26+
27+
}
28+
tasks.withType(JavaCompile) {
29+
options.errorprone.excludedPaths = '.*/build/generated/.*'
30+
}
31+
}
32+
}
33+
34+
// marker task to enable errorprone diagnostics.
35+
task withErrorProne {}

0 commit comments

Comments
 (0)