Skip to content
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 @@ -126,27 +126,19 @@ class GoogleServicesPlugin implements Plugin<Project> {
.register(
"process${variant.name.capitalize()}GoogleServices",
GoogleServicesTask) { task ->
task.setIntermediateDir(outputDir)
task.outputDirectory.set(outputDir)
task.applicationId.set(variant.applicationId)
task.setBuildType(variant.buildType.name)
task.setProductFlavors(variant.productFlavors.collect { it.name })

// This is necessary for backwards compatibility with versions of gradle that do not support
// this new API.
if (variant.respondsTo("registerGeneratedResFolders")) {
task.ext.generatedResFolders = project.files(outputDir).builtBy(task)
variant.registerGeneratedResFolders(task.generatedResFolders)
} else {
//noinspection GrDeprecatedAPIUsage
variant.registerResGeneratingTask(task, outputDir)
}
}
if (variant.respondsTo("getMergeResourcesProvider")) {
variant.mergeResourcesProvider.configure { dependsOn(processTask) }
} else {
//noinspection GrDeprecatedAPIUsage
variant.mergeResources.dependsOn(processTask)
}
if (variant.respondsTo("registerGeneratedResFolders")) {
variant.registerGeneratedResFolders(
project.files(processTask.flatMap {task -> task.outputDirectory})
)
} else {
//noinspection GrDeprecatedAPIUsage Support for AGP 2.2 and below (perhaps we can drop that support?)
variant.registerResGeneratingTask(processTask.get(), processTask.get().outputDirectory.get().asFile)
}
}

public static class GoogleServicesPluginConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
import com.google.gson.JsonPrimitive;
import org.gradle.api.DefaultTask;
import org.gradle.api.GradleException;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.model.ObjectFactory;

import org.gradle.api.provider.Property;
import org.gradle.api.resources.TextResource;
import org.gradle.api.tasks.Input;
Expand Down Expand Up @@ -61,7 +63,6 @@ public abstract class GoogleServicesTask extends DefaultTask {

private static final String OAUTH_CLIENT_TYPE_WEB = "3";

private File intermediateDir;
private String buildType;
private List<String> productFlavors;
private ObjectFactory objectFactory;
Expand All @@ -72,9 +73,7 @@ public GoogleServicesTask(ObjectFactory objectFactory) {
}

@OutputDirectory
public File getIntermediateDir() {
return intermediateDir;
}
public abstract DirectoryProperty getOutputDirectory();

@Input
public String getBuildType() {
Expand All @@ -86,10 +85,6 @@ public List<String> getProductFlavors() {
return productFlavors;
}

public void setIntermediateDir(File intermediateDir) {
this.intermediateDir = intermediateDir;
}

public void setBuildType(String buildType) {
this.buildType = buildType;
}
Expand Down Expand Up @@ -125,6 +120,7 @@ public void action() throws IOException {
getLogger().info("Parsing json file: " + quickstartFile.getPath());

// delete content of outputdir.
File intermediateDir = getOutputDirectory().get().getAsFile();
deleteFolder(intermediateDir);
if (!intermediateDir.mkdirs()) {
throw new GradleException("Failed to create folder: " + intermediateDir);
Expand Down Expand Up @@ -260,7 +256,7 @@ private void handleAnalytics(JsonObject clientObject, Map<String, String> resVal

resValues.put("ga_trackingId", trackingId.getAsString());

File xml = new File(intermediateDir, "xml");
File xml = new File(getOutputDirectory().get().getAsFile(), "xml");
if (!xml.exists() && !xml.mkdirs()) {
throw new GradleException("Failed to create folder: " + xml);
}
Expand Down