Skip to content

Commit af38de9

Browse files
authored
Remove custom DSL to disable kotlin checks. (#692)
Teams can explicitly opt-out by either adding `@hide` to affected packages or modifying `android.lintOptions`.
1 parent 75d0130 commit af38de9

File tree

20 files changed

+169
-65
lines changed

20 files changed

+169
-65
lines changed

buildSrc/src/main/groovy/com/google/firebase/gradle/plugins/FirebaseLibraryExtension.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import com.google.common.collect.ImmutableSet;
1818
import com.google.firebase.gradle.plugins.ci.device.FirebaseTestLabExtension;
19+
import java.util.Collections;
1920
import java.util.HashSet;
2021
import java.util.Set;
2122
import java.util.stream.Collectors;
@@ -39,7 +40,7 @@ public class FirebaseLibraryExtension {
3940
public boolean publishSources;
4041

4142
/** Static analysis configuration. */
42-
public final FirebaseStaticAnalysis staticAnalysis = new FirebaseStaticAnalysis();
43+
public final FirebaseStaticAnalysis staticAnalysis;
4344

4445
/** Firebase Test Lab configuration/ */
4546
public final FirebaseTestLabExtension testLab;
@@ -78,6 +79,20 @@ public FirebaseLibraryExtension(Project project) {
7879
artifactId.set(new DefaultProvider<>(project::getName));
7980
groupId.set(new DefaultProvider<>(() -> project.getGroup().toString()));
8081
}
82+
this.staticAnalysis = initializeStaticAnalysis(project);
83+
}
84+
85+
private FirebaseStaticAnalysis initializeStaticAnalysis(Project project) {
86+
return new FirebaseStaticAnalysis(
87+
projectsFromProperty(project, "firebase.checks.errorproneProjects"),
88+
projectsFromProperty(project, "firebase.checks.lintProjects"));
89+
}
90+
91+
private Set<String> projectsFromProperty(Project project, String propertyName) {
92+
if (!project.hasProperty(propertyName)) {
93+
return Collections.emptySet();
94+
}
95+
return ImmutableSet.copyOf(project.property(propertyName).toString().split(",", -1));
8196
}
8297

8398
/** Configure Firebase Test Lab. */

buildSrc/src/main/groovy/com/google/firebase/gradle/plugins/FirebaseLibraryPlugin.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,13 @@
1717
import com.android.build.gradle.LibraryExtension;
1818
import com.google.common.collect.ImmutableList;
1919
import com.google.common.collect.ImmutableMap;
20-
import com.google.common.collect.ImmutableSet;
2120
import com.google.firebase.gradle.plugins.ci.device.FirebaseTestServer;
2221
import org.gradle.api.Plugin;
2322
import org.gradle.api.Project;
2423
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile;
2524

26-
import java.util.Set;
27-
2825
public class FirebaseLibraryPlugin implements Plugin<Project> {
2926

30-
private static final Set<String> KOTLIN_CHECKS =
31-
ImmutableSet.of(
32-
"FirebaseNoHardKeywords",
33-
"FirebaseLambdaLast",
34-
"FirebaseUnknownNullness",
35-
"FirebaseKotlinPropertyAccess");
36-
3727
@Override
3828
public void apply(Project project) {
3929
project.apply(ImmutableMap.of("plugin", "com.android.library"));
@@ -106,11 +96,6 @@ private static void setupStaticAnalysis(
10696
}
10797
}));
10898

109-
library.staticAnalysis.subscribeToKotlinInteropLintDisabled(
110-
() ->
111-
android.lintOptions(
112-
lintOptions -> lintOptions.disable(KOTLIN_CHECKS.toArray(new String[0]))));
113-
11499
project.getTasks().register("firebaseLint", task -> task.dependsOn("lint"));
115100
}
116101

buildSrc/src/main/groovy/com/google/firebase/gradle/plugins/FirebaseStaticAnalysis.java

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,45 +14,15 @@
1414

1515
package com.google.firebase.gradle.plugins;
1616

17-
import com.google.common.collect.ImmutableSet;
18-
19-
import java.util.HashSet;
2017
import java.util.Set;
21-
import java.util.function.Consumer;
2218

2319
public class FirebaseStaticAnalysis {
2420
public Set<String> errorproneCheckProjects;
2521
public Set<String> androidLintCheckProjects;
2622

27-
28-
private boolean disableKotlinInteropLint;
29-
30-
private final Set<Runnable> kotlinInteropLintDisabledSubscribers = new HashSet<>();
31-
32-
public FirebaseStaticAnalysis() {
33-
this(ImmutableSet.of(":tools:errorprone"), ImmutableSet.of(":tools:lint"));
34-
}
35-
36-
public FirebaseStaticAnalysis(Set<String> errorproneCheckProjects, Set<String> androidLintCheckProjects) {
23+
public FirebaseStaticAnalysis(
24+
Set<String> errorproneCheckProjects, Set<String> androidLintCheckProjects) {
3725
this.errorproneCheckProjects = errorproneCheckProjects;
3826
this.androidLintCheckProjects = androidLintCheckProjects;
3927
}
40-
41-
/** Indicates whether Kotlin Interop Lint checks are enabled for public APIs of the library. */
42-
public void disableKotlinInteropLint() {
43-
if (disableKotlinInteropLint) {
44-
return;
45-
}
46-
disableKotlinInteropLint = true;
47-
for (Runnable subscription : kotlinInteropLintDisabledSubscribers) {
48-
subscription.run();
49-
}
50-
}
51-
52-
void subscribeToKotlinInteropLintDisabled(Runnable subscription) {
53-
this.kotlinInteropLintDisabledSubscribers.add(subscription);
54-
if (disableKotlinInteropLint) {
55-
subscription.run();
56-
}
57-
}
5828
}

buildSrc/src/test/groovy/com/google/firebase/gradle/plugins/publish/PublishingPluginSpec.groovy

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ class PublishingPluginSpec extends Specification {
2929
plugins {
3030
id 'firebase-library'
3131
}
32-
firebaseLibrary {
33-
staticAnalysis {
34-
errorproneCheckProjects = []
35-
androidLintCheckProjects = []
36-
}
37-
}
3832
group = '${group}'
3933
version = '${version}'
4034
<% if (latestReleasedVersion) println "ext.latestReleasedVersion = $latestReleasedVersion" %>

firebase-datatransport/firebase-datatransport.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ plugins {
1919
firebaseLibrary {
2020
publishJavadoc = false
2121
publishSources = true
22-
staticAnalysis.disableKotlinInteropLint()
2322
}
2423

2524
android {

firebase-inappmessaging-display/firebase-inappmessaging-display.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ plugins {
1919
firebaseLibrary {
2020
testLab.enabled = true
2121
publishSources = true
22-
staticAnalysis.disableKotlinInteropLint()
2322
}
2423

2524
android {
@@ -34,9 +33,11 @@ android {
3433
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3534
}
3635

37-
// TODO: b/111563140
3836
lintOptions {
39-
abortOnError false
37+
// TODO: b/111563140
38+
disable "InvalidPackage"
39+
40+
disable "FirebaseUnknownNullness"
4041
}
4142

4243
compileOptions {

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ android.useAndroidX=true
2020

2121
org.gradle.parallel=true
2222
org.gradle.caching=true
23+
24+
firebase.checks.errorproneProjects=:tools:errorprone
25+
firebase.checks.lintProjects=:tools:lint

protolite-well-known-types/protolite-well-known-types.gradle

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ plugins {
1717
id 'com.google.protobuf'
1818
}
1919

20-
firebaseLibrary {
21-
staticAnalysis.disableKotlinInteropLint()
22-
}
23-
2420

2521
protobuf {
2622
protoc {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2019 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+
/** @hide */
16+
package com.google.android.datatransport;

transport/transport-api/transport-api.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ plugins {
1818

1919
firebaseLibrary{
2020
publishJavadoc = false
21-
staticAnalysis.disableKotlinInteropLint()
2221
}
2322

2423
android {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2019 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+
/** @hide */
16+
package com.google.android.datatransport.cct;

transport/transport-backend-cct/transport-backend-cct.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ plugins {
1919

2020
firebaseLibrary{
2121
publishJavadoc = false
22-
staticAnalysis.disableKotlinInteropLint()
2322
}
2423

2524
protobuf {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2019 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+
/** @hide */
16+
package com.google.android.datatransport.runtime.backends;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2019 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+
/** @hide */
16+
package com.google.android.datatransport.runtime;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2019 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+
/** @hide */
16+
package com.google.android.datatransport.runtime.scheduling.jobscheduling;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2019 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+
/** @hide */
16+
package com.google.android.datatransport.runtime.scheduling;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2019 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+
/** @hide */
16+
package com.google.android.datatransport.runtime.scheduling.persistence;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2019 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+
/** @hide */
16+
package com.google.android.datatransport.runtime.synchronization;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2019 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+
/** @hide */
16+
package com.google.android.datatransport.runtime.time;

transport/transport-runtime/transport-runtime.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ firebaseLibrary {
3232
device 'model=hero2lte,version=23' // Galaxy S7
3333
device 'model=htc_m8,version=19' // HTC One (M8)
3434
}
35-
staticAnalysis.disableKotlinInteropLint()
3635
}
3736

3837
android {

0 commit comments

Comments
 (0)