Skip to content

Add dummy task in javadoc plugin to generate an empty api.txt file #2447

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
Feb 18, 2021
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
18 changes: 18 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
plugins {
id "org.gradle.kotlin.kotlin-dsl" version "1.2.6"
id "org.jlleitschuh.gradle.ktlint" version "9.2.1"
id 'com.github.sherter.google-java-format' version '0.9'
}

repositories {
Expand All @@ -35,6 +36,23 @@ repositories {
// Refer go/fireperf-plugin-test-on-head for more details.
def perfPluginVersion = System.getenv("FIREBASE_PERF_PLUGIN_VERSION") ?: "1.3.4"

googleJavaFormat {
toolVersion = '1.7'
}
tasks.googleJavaFormat {
source '.'
include '**/java/**/*.java'
exclude '**/generated/**'
exclude '**/package-info.java'
}

tasks.verifyGoogleJavaFormat {
source '.'
include '**/java/**/*.java'
exclude '**/generated/**'
exclude '**/package-info.java'
}

dependencies {
// Firebase performance plugin, it should be added here because of how gradle dependency
// resolution works, otherwise it breaks Fireperf Test Apps.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static void configure(
BuildTypeAttr.ATTRIBUTE, project.getObjects().named(BuildTypeAttr.class, "release"));
}
Configuration runtimeOnly = project.getConfigurations().findByName("runtimeOnly");
if(runtimeOnly != null) {
if (runtimeOnly != null) {
javadocClasspath.extendsFrom(runtimeOnly);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.
package com.google.firebase.gradle.plugins;

import static com.google.firebase.gradle.plugins.ProjectUtilsKt.toBoolean;
import static com.google.firebase.gradle.plugins.ClosureUtil.closureOf;
import static com.google.firebase.gradle.plugins.ProjectUtilsKt.toBoolean;

import com.android.build.gradle.LibraryExtension;
import com.google.common.collect.ImmutableList;
Expand Down Expand Up @@ -93,11 +93,14 @@ private static void applyDoclava(Project project) {
generateJavadoc,
closureOf(
(Javadoc javadoc) -> {
project.getTasks().all(it -> {
if (it.getName().equals("assembleRelease")) {
javadoc.dependsOn(it);
}
});
project
.getTasks()
.all(
it -> {
if (it.getName().equals("assembleRelease")) {
javadoc.dependsOn(it);
}
});
// Besides third party libraries, firestore depends on the sibling module
// :immutable-collection,
// which needs to be in the classpath when javadoc is run
Expand Down Expand Up @@ -148,8 +151,9 @@ private static void applyDoclava(Project project) {
javadoc.setClasspath(
javadoc
.getClasspath()
.plus(getJars(variant.getCompileConfiguration())
.plus(getJars(variant.getRuntimeConfiguration()))));
.plus(
getJars(variant.getCompileConfiguration())
.plus(getJars(variant.getRuntimeConfiguration()))));

// this includes compiled sources which avoids "cannot find symbol" errors
javadoc.setClasspath(
Expand Down Expand Up @@ -260,9 +264,12 @@ private static void applyDoclava(Project project) {
}));
project
.getTasks()
.create(TasksKt.JAVADOC_TASK_NAME, task -> {
task.dependsOn(generateJavadoc);
});
.create(
TasksKt.JAVADOC_TASK_NAME,
task -> {
task.dependsOn(generateJavadoc);
createEmptyApiFile(project);
});
}

private static void applyDokka(Project project) {
Expand All @@ -275,20 +282,25 @@ private static void applyDokka(Project project) {
private static Task applyDummyJavadoc(Project project) {
return project
.getTasks()
.create(TasksKt.JAVADOC_TASK_NAME, task -> {
task.doLast(
t -> {
File dir = project.file(project.getBuildDir() + "/tmp/javadoc");
project.mkdir(dir);
try {
project.file(dir + "/api.txt").createNewFile();
} catch (IOException e) {
throw new GradleException("Unable to create file", e);
}
});
task.doLast(
t -> project.mkdir(project.getBuildDir() + "/docs/javadoc/reference"));
});
.create(
TasksKt.JAVADOC_TASK_NAME,
task -> {
task.doLast(
t -> {
createEmptyApiFile(project);
});
task.doLast(t -> project.mkdir(project.getBuildDir() + "/docs/javadoc/reference"));
});
}

private static void createEmptyApiFile(Project project) {
File dir = project.file(project.getBuildDir() + "/tmp/javadoc");
project.mkdir(dir);
try {
project.file(dir + "/api.txt").createNewFile();
} catch (IOException e) {
throw new GradleException("Unable to create file", e);
}
}

private static FileCollection getJars(Configuration configuration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ public void apply(Project project) {
Task connectedCheckDependents = sub.task("connectedCheckDependents");
Task deviceCheckDependents = sub.task("deviceCheckDependents");

sub
.getConfigurations()
sub.getConfigurations()
.all(
cfg -> {
if ("releaseUnitTestRuntimeClasspath".equals(cfg.getName())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,37 @@

package com.google.firebase.gradle.plugins.ci.device;


import org.gradle.api.model.ObjectFactory;
import org.gradle.api.provider.SetProperty;

import java.util.Collections;
import java.util.Set;

import javax.inject.Inject;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.provider.SetProperty;

public class FirebaseTestLabExtension {
private final SetProperty<String> devices;
private boolean enabled;
private final SetProperty<String> devices;
private boolean enabled;

@Inject
public FirebaseTestLabExtension(ObjectFactory objectFactory) {
devices = objectFactory.setProperty(String.class);
}
@Inject
public FirebaseTestLabExtension(ObjectFactory objectFactory) {
devices = objectFactory.setProperty(String.class);
}

public void setEnabled(boolean value) {
enabled = value;
}
public void setEnabled(boolean value) {
enabled = value;
}

public boolean getEnabled() {
return enabled;
}
public boolean getEnabled() {
return enabled;
}

public void device(String device) {
devices.add(device);
}
public void device(String device) {
devices.add(device);
}

Set<String> getDevices() {
if( devices.get().isEmpty()) {
return Collections.singleton("model=Pixel2,version=27,locale=en,orientation=portrait");
}
return devices.get();
Set<String> getDevices() {
if (devices.get().isEmpty()) {
return Collections.singleton("model=Pixel2,version=27,locale=en,orientation=portrait");
}
return devices.get();
}
}
Loading