Skip to content

Remove custom DSL to disable kotlin checks. #692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import com.google.common.collect.ImmutableSet;
import com.google.firebase.gradle.plugins.ci.device.FirebaseTestLabExtension;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
Expand All @@ -39,7 +40,7 @@ public class FirebaseLibraryExtension {
public boolean publishSources;

/** Static analysis configuration. */
public final FirebaseStaticAnalysis staticAnalysis = new FirebaseStaticAnalysis();
public final FirebaseStaticAnalysis staticAnalysis;

/** Firebase Test Lab configuration/ */
public final FirebaseTestLabExtension testLab;
Expand Down Expand Up @@ -78,6 +79,20 @@ public FirebaseLibraryExtension(Project project) {
artifactId.set(new DefaultProvider<>(project::getName));
groupId.set(new DefaultProvider<>(() -> project.getGroup().toString()));
}
this.staticAnalysis = initializeStaticAnalysis(project);
}

private FirebaseStaticAnalysis initializeStaticAnalysis(Project project) {
return new FirebaseStaticAnalysis(
projectsFromProperty(project, "firebase.checks.errorproneProjects"),
projectsFromProperty(project, "firebase.checks.lintProjects"));
}

private Set<String> projectsFromProperty(Project project, String propertyName) {
if (!project.hasProperty(propertyName)) {
return Collections.emptySet();
}
return ImmutableSet.copyOf(project.property(propertyName).toString().split(",", -1));
}

/** Configure Firebase Test Lab. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,13 @@
import com.android.build.gradle.LibraryExtension;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.firebase.gradle.plugins.ci.device.FirebaseTestServer;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile;

import java.util.Set;

public class FirebaseLibraryPlugin implements Plugin<Project> {

private static final Set<String> KOTLIN_CHECKS =
ImmutableSet.of(
"FirebaseNoHardKeywords",
"FirebaseLambdaLast",
"FirebaseUnknownNullness",
"FirebaseKotlinPropertyAccess");

@Override
public void apply(Project project) {
project.apply(ImmutableMap.of("plugin", "com.android.library"));
Expand Down Expand Up @@ -106,11 +96,6 @@ private static void setupStaticAnalysis(
}
}));

library.staticAnalysis.subscribeToKotlinInteropLintDisabled(
() ->
android.lintOptions(
lintOptions -> lintOptions.disable(KOTLIN_CHECKS.toArray(new String[0]))));

project.getTasks().register("firebaseLint", task -> task.dependsOn("lint"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,15 @@

package com.google.firebase.gradle.plugins;

import com.google.common.collect.ImmutableSet;

import java.util.HashSet;
import java.util.Set;
import java.util.function.Consumer;

public class FirebaseStaticAnalysis {
public Set<String> errorproneCheckProjects;
public Set<String> androidLintCheckProjects;


private boolean disableKotlinInteropLint;

private final Set<Runnable> kotlinInteropLintDisabledSubscribers = new HashSet<>();

public FirebaseStaticAnalysis() {
this(ImmutableSet.of(":tools:errorprone"), ImmutableSet.of(":tools:lint"));
}

public FirebaseStaticAnalysis(Set<String> errorproneCheckProjects, Set<String> androidLintCheckProjects) {
public FirebaseStaticAnalysis(
Set<String> errorproneCheckProjects, Set<String> androidLintCheckProjects) {
this.errorproneCheckProjects = errorproneCheckProjects;
this.androidLintCheckProjects = androidLintCheckProjects;
}

/** Indicates whether Kotlin Interop Lint checks are enabled for public APIs of the library. */
public void disableKotlinInteropLint() {
if (disableKotlinInteropLint) {
return;
}
disableKotlinInteropLint = true;
for (Runnable subscription : kotlinInteropLintDisabledSubscribers) {
subscription.run();
}
}

void subscribeToKotlinInteropLintDisabled(Runnable subscription) {
this.kotlinInteropLintDisabledSubscribers.add(subscription);
if (disableKotlinInteropLint) {
subscription.run();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ class PublishingPluginSpec extends Specification {
plugins {
id 'firebase-library'
}
firebaseLibrary {
staticAnalysis {
errorproneCheckProjects = []
androidLintCheckProjects = []
}
}
group = '${group}'
version = '${version}'
<% if (latestReleasedVersion) println "ext.latestReleasedVersion = $latestReleasedVersion" %>
Expand Down
1 change: 0 additions & 1 deletion firebase-datatransport/firebase-datatransport.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ plugins {
firebaseLibrary {
publishJavadoc = false
publishSources = true
staticAnalysis.disableKotlinInteropLint()
}

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ plugins {
firebaseLibrary {
testLab.enabled = true
publishSources = true
staticAnalysis.disableKotlinInteropLint()
}

android {
Expand All @@ -34,9 +33,11 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

// TODO: b/111563140
lintOptions {
abortOnError false
// TODO: b/111563140
disable "InvalidPackage"

disable "FirebaseUnknownNullness"
}

compileOptions {
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ android.useAndroidX=true

org.gradle.parallel=true
org.gradle.caching=true

firebase.checks.errorproneProjects=:tools:errorprone
firebase.checks.lintProjects=:tools:lint
4 changes: 0 additions & 4 deletions protolite-well-known-types/protolite-well-known-types.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ plugins {
id 'com.google.protobuf'
}

firebaseLibrary {
staticAnalysis.disableKotlinInteropLint()
}


protobuf {
protoc {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2019 Google LLC
//
// 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.

/** @hide */
package com.google.android.datatransport;
1 change: 0 additions & 1 deletion transport/transport-api/transport-api.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ plugins {

firebaseLibrary{
publishJavadoc = false
staticAnalysis.disableKotlinInteropLint()
}

android {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2019 Google LLC
//
// 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.

/** @hide */
package com.google.android.datatransport.cct;
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ plugins {

firebaseLibrary{
publishJavadoc = false
staticAnalysis.disableKotlinInteropLint()
}

protobuf {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2019 Google LLC
//
// 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.

/** @hide */
package com.google.android.datatransport.runtime.backends;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2019 Google LLC
//
// 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.

/** @hide */
package com.google.android.datatransport.runtime;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2019 Google LLC
//
// 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.

/** @hide */
package com.google.android.datatransport.runtime.scheduling.jobscheduling;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2019 Google LLC
//
// 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.

/** @hide */
package com.google.android.datatransport.runtime.scheduling;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2019 Google LLC
//
// 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.

/** @hide */
package com.google.android.datatransport.runtime.scheduling.persistence;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2019 Google LLC
//
// 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.

/** @hide */
package com.google.android.datatransport.runtime.synchronization;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2019 Google LLC
//
// 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.

/** @hide */
package com.google.android.datatransport.runtime.time;
1 change: 0 additions & 1 deletion transport/transport-runtime/transport-runtime.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ firebaseLibrary {
device 'model=hero2lte,version=23' // Galaxy S7
device 'model=htc_m8,version=19' // HTC One (M8)
}
staticAnalysis.disableKotlinInteropLint()
}

android {
Expand Down