Skip to content

Create Gradle cache-compliant metalava tasks. #3994

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 3 commits into from
Aug 16, 2022
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
1 change: 0 additions & 1 deletion appcheck/firebase-appcheck/ktx/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
package com.google.firebase.appcheck.ktx {

public final class FirebaseAppCheckKt {
ctor public FirebaseAppCheckKt();
method @NonNull public static com.google.firebase.appcheck.FirebaseAppCheck appCheck(@NonNull com.google.firebase.ktx.Firebase, @NonNull com.google.firebase.FirebaseApp app);
method @NonNull public static operator String component1(@NonNull com.google.firebase.appcheck.AppCheckToken);
method public static operator long component2(@NonNull com.google.firebase.appcheck.AppCheckToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
import com.github.sherter.googlejavaformatgradleplugin.GoogleJavaFormatExtension;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.firebase.gradle.plugins.apiinfo.ApiInformationTask;
import com.google.firebase.gradle.plugins.apiinfo.GenerateApiTxtFileTask;
import com.google.firebase.gradle.plugins.apiinfo.GetMetalavaJarTask;
import com.google.firebase.gradle.plugins.ci.Coverage;
import java.io.File;
import java.nio.file.Paths;
Expand Down Expand Up @@ -92,7 +89,6 @@ private static void setupStaticAnalysis(Project project, FirebaseLibraryExtensio
}

private static void setupApiInformationAnalysis(Project project) {
File metalavaOutputJarFile = new File(project.getRootProject().getBuildDir(), "metalava.jar");
SourceSet mainSourceSet =
project
.getConvention()
Expand All @@ -109,15 +105,6 @@ private static void setupApiInformationAnalysis(Project project) {
project.getPath().substring(1).replace(":", "_")));
File outputApiFile = new File(outputFile.getAbsolutePath() + "_api.txt");

project
.getTasks()
.register(
"getMetalavaJar",
GetMetalavaJarTask.class,
task -> {
task.setOutputFile(metalavaOutputJarFile);
});

File apiTxt =
project.file("api.txt").exists()
? project.file("api.txt")
Expand All @@ -129,33 +116,27 @@ private static void setupApiInformationAnalysis(Project project) {
"apiInformation",
ApiInformationTask.class,
task -> {
task.setApiTxt(apiTxt);
task.setMetalavaJarPath(metalavaOutputJarFile.getAbsolutePath());
task.setSourceSet(mainSourceSet);
task.setOutputFile(outputFile);
task.setBaselineFile(project.file("baseline.txt"));
task.setOutputApiFile(outputApiFile);
if (project.hasProperty("updateBaseline")) {
task.setUpdateBaseline(true);
} else {
task.setUpdateBaseline(false);
}
task.dependsOn("getMetalavaJar");
task.getSources()
.value(project.provider(() -> mainSourceSet.getJava().getSrcDirs()));
task.getApiTxtFile().set(apiTxt);
task.getBaselineFile().set(project.file("baseline.txt"));
task.getOutputFile().set(outputFile);
task.getOutputApiFile().set(outputApiFile);
task.getUpdateBaseline().set(project.hasProperty("updateBaseline"));
});

TaskProvider<GenerateApiTxtFileTask> generateApiTxt =
TaskProvider<GenerateApiTxtTask> generateApiTxt =
project
.getTasks()
.register(
"generateApiTxtFile",
GenerateApiTxtFileTask.class,
GenerateApiTxtTask.class,
task -> {
task.setApiTxt(project.file("api.txt"));
task.setMetalavaJarPath(metalavaOutputJarFile.getAbsolutePath());
task.setSourceSet(mainSourceSet);
task.setBaselineFile(project.file("baseline.txt"));
task.setUpdateBaseline(project.hasProperty("updateBaseline"));
task.dependsOn("getMetalavaJar");
task.getSources()
.value(project.provider(() -> mainSourceSet.getJava().getSrcDirs()));
task.getApiTxtFile().set(project.file("api.txt"));
task.getBaselineFile().set(project.file("baseline.txt"));
task.getUpdateBaseline().set(project.hasProperty("updateBaseline"));
});

TaskProvider<GenerateStubsTask> docStubs =
Expand All @@ -164,11 +145,9 @@ private static void setupApiInformationAnalysis(Project project) {
.register(
"docStubs",
GenerateStubsTask.class,
task -> {
task.dependsOn("getMetalavaJar");

task.setSourceSet(mainSourceSet);
});
task ->
task.getSources()
.value(project.provider(() -> mainSourceSet.getJava().getSrcDirs())));
project.getTasks().getByName("check").dependsOn(docStubs);

project.afterEvaluate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
import com.github.sherter.googlejavaformatgradleplugin.GoogleJavaFormatExtension;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.firebase.gradle.plugins.apiinfo.ApiInformationTask;
import com.google.firebase.gradle.plugins.apiinfo.GenerateApiTxtFileTask;
import com.google.firebase.gradle.plugins.apiinfo.GetMetalavaJarTask;
import com.google.firebase.gradle.plugins.ci.Coverage;
import com.google.firebase.gradle.plugins.ci.device.FirebaseTestServer;
import com.google.firebase.gradle.plugins.license.LicenseResolverPlugin;
Expand Down Expand Up @@ -116,7 +113,6 @@ public void apply(Project project) {
}

private static void setupApiInformationAnalysis(Project project, LibraryExtension android) {
File metalavaOutputJarFile = new File(project.getRootProject().getBuildDir(), "metalava.jar");
AndroidSourceSet mainSourceSet = android.getSourceSets().getByName("main");
File outputFile =
project
Expand All @@ -128,14 +124,6 @@ private static void setupApiInformationAnalysis(Project project, LibraryExtensio
project.getPath().substring(1).replace(":", "_")));
File outputApiFile = new File(outputFile.getAbsolutePath() + "_api.txt");

project
.getTasks()
.register(
"getMetalavaJar",
GetMetalavaJarTask.class,
task -> {
task.setOutputFile(metalavaOutputJarFile);
});
File apiTxt =
project.file("api.txt").exists()
? project.file("api.txt")
Expand All @@ -147,33 +135,27 @@ private static void setupApiInformationAnalysis(Project project, LibraryExtensio
"apiInformation",
ApiInformationTask.class,
task -> {
task.setApiTxt(apiTxt);
task.setMetalavaJarPath(metalavaOutputJarFile.getAbsolutePath());
task.setSourceSet(mainSourceSet);
task.setOutputFile(outputFile);
task.setBaselineFile(project.file("baseline.txt"));
task.setOutputApiFile(outputApiFile);
if (project.hasProperty("updateBaseline")) {
task.setUpdateBaseline(true);
} else {
task.setUpdateBaseline(false);
}
task.dependsOn("getMetalavaJar");
task.getSources()
.value(project.provider(() -> mainSourceSet.getJava().getSrcDirs()));
task.getApiTxtFile().set(apiTxt);
task.getBaselineFile().set(project.file("baseline.txt"));
task.getOutputFile().set(outputFile);
task.getOutputApiFile().set(outputApiFile);
task.getUpdateBaseline().set(project.hasProperty("updateBaseline"));
});

TaskProvider<GenerateApiTxtFileTask> generateApiTxt =
TaskProvider<GenerateApiTxtTask> generateApiTxt =
project
.getTasks()
.register(
"generateApiTxtFile",
GenerateApiTxtFileTask.class,
GenerateApiTxtTask.class,
task -> {
task.setApiTxt(project.file("api.txt"));
task.setMetalavaJarPath(metalavaOutputJarFile.getAbsolutePath());
task.setSourceSet(mainSourceSet);
task.setBaselineFile(project.file("baseline.txt"));
task.setUpdateBaseline(project.hasProperty("updateBaseline"));
task.dependsOn("getMetalavaJar");
task.getSources()
.value(project.provider(() -> mainSourceSet.getJava().getSrcDirs()));
task.getApiTxtFile().set(project.file("api.txt"));
task.getBaselineFile().set(project.file("baseline.txt"));
task.getUpdateBaseline().set(project.hasProperty("updateBaseline"));
});

TaskProvider<GenerateStubsTask> docStubs =
Expand All @@ -182,9 +164,9 @@ private static void setupApiInformationAnalysis(Project project, LibraryExtensio
.register(
"docStubs",
GenerateStubsTask.class,
task -> {
task.setSourceSet(mainSourceSet);
});
task ->
task.getSources()
.value(project.provider(() -> mainSourceSet.getJava().getSrcDirs())));
project.getTasks().getByName("check").dependsOn(docStubs);

android
Expand Down
Loading