aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builder/src/main/java/com/android/builder/internal/incremental/ChangeManager.java133
-rw-r--r--builder/src/main/java/com/android/builder/internal/incremental/FileManager.java244
-rw-r--r--builder/src/test/java/com/android/builder/internal/incremental/FileManagerTest.java158
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/BasePlugin.groovy7
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/internal/tasks/DependencyBasedCompileTask.groovy2
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/internal/tasks/IncrementalTask.groovy89
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/tasks/AidlCompile.groovy5
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/tasks/MergeAssets.groovy5
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/tasks/MergeResources.groovy5
9 files changed, 28 insertions, 620 deletions
diff --git a/builder/src/main/java/com/android/builder/internal/incremental/ChangeManager.java b/builder/src/main/java/com/android/builder/internal/incremental/ChangeManager.java
deleted file mode 100644
index 62395fe..0000000
--- a/builder/src/main/java/com/android/builder/internal/incremental/ChangeManager.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * 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.
- */
-
-package com.android.builder.internal.incremental;
-
-import com.android.annotations.NonNull;
-import com.android.ide.common.res2.FileStatus;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Map;
-
-/**
- * Class handling changes in input and output.
- *
- * The class stores the state of inputs/outputs after a task is run, and on subsequent runs can
- * compare this to the current state of detect exact file changes in the inputs or outputs.
- *
- * Gradle already does this to figure out if a task needs to be run, but does not offer this
- * information to the task.
- * This should become available in the Gradle plugin in the future, but in the meantime this
- * provides the same information, allowing us to build truly incremental tasks.
- *
- */
-public class ChangeManager {
-
- private static final String FN_INPUTS_DATA = "inputs.data";
- private static final String FN_OUTPUTS_DATA = "outputs.data";
-
- private FileManager mInputs = new FileManager();
- private FileManager mOutputs = new FileManager();
-
- public ChangeManager() {
- }
-
- /**
- * Loads the known state.
- *
- * @param incrementalFolder the folder in which to store the incremental data
- * @return false if the loading failed.
- */
- public boolean load(File incrementalFolder) {
- File inputs = new File(incrementalFolder, FN_INPUTS_DATA);
- File outputs = new File(incrementalFolder, FN_OUTPUTS_DATA);
- return inputs.exists() && outputs.exists() &&
- mInputs.load(inputs) && mOutputs.load(outputs);
- }
-
- /**
- * Writes the incremental data to a given folder.
- * @param incrementalFolder the name of the folder to write to.
- *
- * @throws IOException
- */
- public void write(File incrementalFolder) throws IOException {
- if (!incrementalFolder.isDirectory() && !incrementalFolder.mkdirs()) {
- throw new IOException("Failed to create directory " + incrementalFolder);
- }
-
- mInputs.write(new File(incrementalFolder, FN_INPUTS_DATA));
- mOutputs.write(new File(incrementalFolder, FN_OUTPUTS_DATA));
- }
-
- /**
- * Delete the incremental data from the given folder.
- * @param incrementalFolder the folder to delete the incremental data from.
- */
- public static void delete(File incrementalFolder) {
- File file = new File(incrementalFolder, FN_INPUTS_DATA);
- //noinspection ResultOfMethodCallIgnored
- file.delete();
- file = new File(incrementalFolder, FN_OUTPUTS_DATA);
- //noinspection ResultOfMethodCallIgnored
- file.delete();
- }
-
- /**
- * Add an input file or folder.
- * @param file the file.
- */
- public void addInput(File file) {
- mInputs.addFile(file);
- }
-
- /**
- * Adds a new output file or folder
- * @param file the file.
- */
- public void addOutput(File file) {
- mOutputs.addFile(file);
- }
-
- /**
- * Get the list of changed inputs. Empty list means no input changes.
- *
- * @return a map of (File, FileStatus) for all changed input.
- */
- @NonNull
- public Map<File, FileStatus> getChangedInputs() {
- return mInputs.getChangedFiles();
- }
-
- /**
- * Returns a list of changed output. Empty list means no output changes.
- *
- * @return a map of (file, status) for all changed output files.
- */
- @NonNull
- public Map<File, FileStatus> getChangedOutputs() {
- return mOutputs.getChangedFiles();
- }
-
- /**
- * Update the outputs before writing the file states
- */
- public void updateOutputs(Collection<File> outputs) {
- mOutputs.update(outputs);
- }
-}
diff --git a/builder/src/main/java/com/android/builder/internal/incremental/FileManager.java b/builder/src/main/java/com/android/builder/internal/incremental/FileManager.java
deleted file mode 100644
index 6408c26..0000000
--- a/builder/src/main/java/com/android/builder/internal/incremental/FileManager.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * 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.
- */
-
-package com.android.builder.internal.incremental;
-
-import com.android.annotations.NonNull;
-import com.android.ide.common.res2.FileStatus;
-import com.google.common.base.Charsets;
-import com.google.common.collect.Maps;
-import com.google.common.io.Closeables;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Class handling changes in a set of files.
- *
- * The class can store the state of the files, and later reload it and compare it to the
- * previous known state.
- *
- */
-class FileManager {
-
- private static final Pattern READ_PATTERN = Pattern.compile(
- "^(\\d+)\\s+(\\d+)\\s+([0-9a-f]+)\\s+(.+)$");
-
- private Map<File, FileEntity> mLoadedFiles = Maps.newHashMap();
- private Map<File, FileEntity> mProcessedFiles = Maps.newHashMap();
- private Map<File, FileStatus> mResults = Maps.newHashMap();
- private Map<File, FileStatus> mReturnedMap = null;
-
- public FileManager() {
- }
-
- /**
- * Loads the known state.
- *
- * @param stateFile the file to load the state from.
- * @return false if the loading failed.
- *
- * @see #write(java.io.File)
- */
- public boolean load(File stateFile) {
- if (!stateFile.exists()) {
- return false;
- }
-
- BufferedReader reader = null;
- try {
- reader = new BufferedReader(new InputStreamReader(
- new FileInputStream(stateFile), Charsets.UTF_8));
-
- String line = null;
- while ((line = reader.readLine()) != null) {
- // skip comments
- if (line.charAt(0) == '#') {
- continue;
- }
-
- // get the data with a regexp
- Matcher m = READ_PATTERN.matcher(line);
- if (m.matches()) {
- String path = m.group(4);
- File f = new File(path);
-
- FileEntity entity = new FileEntity(
- f,
- Long.parseLong(m.group(1)),
- Long.parseLong(m.group(2)),
- m.group(3));
-
- mLoadedFiles.put(f, entity);
- }
- }
-
- return true;
- } catch (FileNotFoundException ignored) {
- // won't happen, we check up front.
- } catch (UnsupportedEncodingException ignored) {
- // shouldn't happen, but if it does, we just won't have a cache.
- } catch (IOException ignored) {
- // shouldn't happen, but if it does, we just won't have a cache.
- } finally {
- Closeables.closeQuietly(reader);
- }
-
- return false;
- }
-
- /**
- * Writes the state to a file
- * @param stateFile the file to write the state to.
- *
- * @throws IOException
- *
- * @see #load(java.io.File)
- */
- public void write(File stateFile) throws IOException {
- OutputStreamWriter writer = null;
- try {
- // first make sure the folders exist!
- File parentFolder = stateFile.getParentFile();
- if (!parentFolder.isDirectory() && !parentFolder.mkdirs()) {
- throw new IOException("Failed to create directory " + parentFolder);
- }
-
- // then write the file.
- writer = new OutputStreamWriter(new FileOutputStream(stateFile), Charsets.UTF_8);
-
- writer.write("# incremental data. DO NOT EDIT.\n");
- writer.write("# format is <lastModified> <length> <SHA-1> <path>\n");
- writer.write("# Encoding is UTF-8\n");
-
- for (FileEntity entity : mProcessedFiles.values()) {
- String sha1 = entity.getSha1();
- if (sha1 == null) {
- sha1 = "0123456789012345678901234567890123456789"; // TODO: find a better way to detect missing sha1
- }
-
- writer.write(String.format("%d %d %s %s\n",
- entity.getLastModified(),
- entity.getLength(),
- sha1,
- entity.getFile().getAbsolutePath()));
- }
- } finally {
- Closeables.closeQuietly(writer);
- }
- }
-
- /**
- * Add an input file or folder.
- * @param file the file.
- */
- public void addFile(File file) {
- processFile(file);
- }
-
- /**
- * Get the list of changed inputs. Empty list means no input changes.
- *
- * @return a map of (File, FileStatus) for all changed input.
- */
- @NonNull
- public Map<File, FileStatus> getChangedFiles() {
- if (mReturnedMap == null) {
- // create a map with the content of the result map.
- mReturnedMap = Maps.newHashMap(mResults);
-
- // at this point, all the files that needed processing have been processed,
- // but there may be removed files remaining in the loaded file map.
- for (File f : mLoadedFiles.keySet()) {
- mReturnedMap.put(f, FileStatus.REMOVED);
- }
-
- // wrap this
- mReturnedMap = Collections.unmodifiableMap(mReturnedMap);
- }
-
- return mReturnedMap;
- }
-
- private void processFile(File file) {
- if (file.isFile()) {
- if (file.getName().startsWith(".")) {
- return;
- }
-
- // get the FileEntity for the new(?) version.
- FileEntity newFileEntity = new FileEntity(file);
-
- // see if it existed before.
- FileEntity fileEntity = mLoadedFiles.get(file);
-
- if (fileEntity == null) {
- // new file!
- mResults.put(file, FileStatus.NEW);
-
- // add it to the list of processed files
- mProcessedFiles.put(file, newFileEntity);
- } else {
- // remove it from the loaded files.
- mLoadedFiles.remove(file);
-
- if (newFileEntity.isDifferentThan(fileEntity)) {
- mResults.put(file, FileStatus.CHANGED);
-
- // put the newFileEntity in the processed files.
- mProcessedFiles.put(file, newFileEntity);
- } else {
- // just move the original entity so avoid recomputing the sha1.
- // FileEntity.isDifferentThan doesn't necessarily compute it.
- mProcessedFiles.put(file, fileEntity);
- }
- }
- } else if (file.isDirectory()) {
- File[] files = file.listFiles();
- if (files != null && files.length > 0) {
- for (File f : files) {
- processFile(f);
- }
- }
- }
- }
-
- /**
- * Updates the existing files with the given files/folders.
- * @param files the new folders/files to process.
- */
- void update(Collection<File> files) {
- mLoadedFiles.clear();
- mLoadedFiles.putAll(mProcessedFiles);
- mResults.clear();
- mProcessedFiles.clear();
- for (File f : files) {
- processFile(f);
- }
- }
-}
diff --git a/builder/src/test/java/com/android/builder/internal/incremental/FileManagerTest.java b/builder/src/test/java/com/android/builder/internal/incremental/FileManagerTest.java
deleted file mode 100644
index 3ac6bb3..0000000
--- a/builder/src/test/java/com/android/builder/internal/incremental/FileManagerTest.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * 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.
- */
-
-package com.android.builder.internal.incremental;
-
-import com.android.ide.common.res2.FileStatus;
-import com.android.testutils.TestUtils;
-import com.google.common.base.Charsets;
-import com.google.common.collect.Maps;
-import com.google.common.io.Files;
-import junit.framework.TestCase;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Map;
-import java.util.regex.Matcher;
-
-public class FileManagerTest extends TestCase {
-
- private static FileManager sFileManager = null;
- private static File sFilesFolder = null;
-
- public void testUntouched() throws Exception {
- FileManager fileManager = getFileManager();
- Map<File, FileStatus> changedFiles = fileManager.getChangedFiles();
-
- File file = new File(sFilesFolder, "untouched.png");
- FileStatus status = changedFiles.get(file);
- assertNull(status);
- }
-
- public void testUntouchedDateBefore() throws Exception {
- FileManager fileManager = getFileManager();
- Map<File, FileStatus> changedFiles = fileManager.getChangedFiles();
-
- File file = new File(sFilesFolder, "untouched_date_before.png");
- FileStatus status = changedFiles.get(file);
- // no change
- assertNull(status);
- }
-
- public void testUntouchedDateAfter() throws Exception {
- FileManager fileManager = getFileManager();
- Map<File, FileStatus> changedFiles = fileManager.getChangedFiles();
-
- File file = new File(sFilesFolder, "untouched_date_after.png");
- FileStatus status = changedFiles.get(file);
- // no change
- assertNull(status);
- }
-
- public void testContentChanged() throws Exception {
- FileManager fileManager = getFileManager();
- Map<File, FileStatus> changedFiles = fileManager.getChangedFiles();
-
- File file = new File(sFilesFolder, "content_changed.png");
- FileStatus status = changedFiles.get(file);
- assertEquals(FileStatus.CHANGED, status);
- }
-
- public void testSizeChanged() throws Exception {
- FileManager fileManager = getFileManager();
- Map<File, FileStatus> changedFiles = fileManager.getChangedFiles();
-
- File file = new File(sFilesFolder, "size_changed.png");
- FileStatus status = changedFiles.get(file);
- assertEquals(FileStatus.CHANGED, status);
- }
-
- public void testRemoved() throws Exception {
- FileManager fileManager = getFileManager();
- Map<File, FileStatus> changedFiles = fileManager.getChangedFiles();
-
- File file = new File(sFilesFolder, "removed.png");
- FileStatus status = changedFiles.get(file);
- assertEquals(FileStatus.REMOVED, status);
- }
-
- public void testNew() throws Exception {
- FileManager fileManager = getFileManager();
- Map<File, FileStatus> changedFiles = fileManager.getChangedFiles();
-
- File file = new File(sFilesFolder, "new.png");
- FileStatus status = changedFiles.get(file);
- assertEquals(FileStatus.NEW, status);
- }
-
- private FileManager getFileManager() throws IOException {
- if (sFileManager == null) {
- File root = TestUtils.getCanonicalRoot("changeManager");
- File dataFile = new File(root, "files.data");
- sFilesFolder = new File(root, "files");
-
- // update the last modified on some of the files.
- Map<String, String> placeHolderMap = Maps.newHashMap();
- String[] files = new String[] { "untouched" };
- for (String filename : files) {
- File file = new File(sFilesFolder, filename + ".png");
- placeHolderMap.put(
- String.format("\\$lm_%s\\$", filename),
- String.format("%d", file.lastModified()));
- }
-
- File trueDataFile = getDataFile(dataFile, sFilesFolder, placeHolderMap);
-
- sFileManager = new FileManager();
- sFileManager.load(trueDataFile);
-
- sFileManager.addFile(sFilesFolder);
- }
-
- return sFileManager;
- }
-
- /**
- * Returns a data file where the placeholders have been updated with the real folder based
- * on where the tests are run from.
- *
- * @param file the data folder.
- * @param targetFolder the targetFolder
- * @param placeholders additional placeholders and values to replace.
- *
- * @return a new data file that's been updated with the targetFolder
- * @throws IOException
- */
- private static File getDataFile(File file, File targetFolder, Map<String, String> placeholders)
- throws IOException {
-
- String content = Files.toString(file, Charsets.UTF_8);
-
- // search and replace $TOP$ with the root and $SEP$ with the platform separator.
- content = content.replaceAll("\\$TOP\\$", Matcher.quoteReplacement(targetFolder.getAbsolutePath()))
- .replaceAll("\\$SEP\\$", Matcher.quoteReplacement(File.separator));
-
- // now replace the additional placeholders
- for (Map.Entry<String, String> entry : placeholders.entrySet()) {
- content = content.replaceAll(entry.getKey(), Matcher.quoteReplacement(entry.getValue()));
- }
-
- File tmp = File.createTempFile("android", "getDataFile");
- Files.write(content, tmp, Charsets.UTF_8);
-
- return tmp;
- }
-}
diff --git a/gradle/src/main/groovy/com/android/build/gradle/BasePlugin.groovy b/gradle/src/main/groovy/com/android/build/gradle/BasePlugin.groovy
index 0df2a27..6f8e9c6 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/BasePlugin.groovy
+++ b/gradle/src/main/groovy/com/android/build/gradle/BasePlugin.groovy
@@ -505,7 +505,7 @@ public abstract class BasePlugin {
mergeAssetsTask.plugin = this
mergeAssetsTask.variant = variantData
mergeAssetsTask.incrementalFolder =
- project.file("$project.buildDir/incremental/mergeAssets/$variantData.dirName")
+ project.file("$project.buildDir/incremental/mergeAssets/$variantData.dirName")
mergeAssetsTask.conventionMapping.inputAssetSets = {
variantData.variantConfiguration.getAssetSets(includeDependencies)
@@ -642,8 +642,7 @@ public abstract class BasePlugin {
compileTask.plugin = this
compileTask.variant = variantData
compileTask.incrementalFolder =
- project.file("$project.buildDir/incremental/aidl/$variantData.dirName")
-
+ project.file("$project.buildDir/incremental/aidl/$variantData.dirName")
compileTask.conventionMapping.sourceDirs = { variantConfiguration.aidlSourceList }
compileTask.conventionMapping.importDirs = { variantConfiguration.aidlImports }
@@ -1121,8 +1120,6 @@ public abstract class BasePlugin {
dexTask.plugin = this
dexTask.variant = variantData
- dexTask.incrementalFolder =
- project.file("$project.buildDir/incremental/dex/$variantData.dirName")
dexTask.conventionMapping.libraries = libraryClosure
dexTask.conventionMapping.sourceFiles = sourceClosure
diff --git a/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/DependencyBasedCompileTask.groovy b/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/DependencyBasedCompileTask.groovy
index 4e10aa8..f264bc9 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/DependencyBasedCompileTask.groovy
+++ b/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/DependencyBasedCompileTask.groovy
@@ -15,7 +15,6 @@
*/
package com.android.build.gradle.internal.tasks
-
import com.android.annotations.NonNull
import com.android.annotations.Nullable
import com.android.builder.compiling.DependencyFileProcessor
@@ -28,7 +27,6 @@ import com.google.common.collect.Multimap
import org.gradle.api.tasks.OutputDirectory
import java.util.concurrent.Callable
-
/**
* Base task for source generators that generate and use dependency files.
*/
diff --git a/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/IncrementalTask.groovy b/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/IncrementalTask.groovy
index aef4319..2a86114 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/IncrementalTask.groovy
+++ b/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/IncrementalTask.groovy
@@ -14,16 +14,14 @@
* limitations under the License.
*/
package com.android.build.gradle.internal.tasks
-
-import com.android.builder.internal.incremental.ChangeManager
import com.android.ide.common.res2.FileStatus
import com.android.ide.common.res2.SourceSet
import com.google.common.collect.Lists
-import org.gradle.api.file.FileCollection
+import com.google.common.collect.Maps
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
-import org.gradle.api.tasks.TaskInputs
+import org.gradle.api.tasks.incremental.IncrementalTaskInputs
public abstract class IncrementalTask extends BaseTask {
@@ -31,7 +29,7 @@ public abstract class IncrementalTask extends BaseTask {
File incrementalFolder
/**
- * Whether this task can support incremental update using the {@link ChangeManager}
+ * Whether this task can support incremental update.
*
* @return whether this task can support incremental update.
*/
@@ -44,7 +42,7 @@ public abstract class IncrementalTask extends BaseTask {
* {@link #isIncremental()} returns false.
*
*/
- protected abstract void doFullTaskAction();
+ protected abstract void doFullTaskAction()
/**
* Optional incremental task action.
@@ -56,79 +54,44 @@ public abstract class IncrementalTask extends BaseTask {
// do nothing.
}
- protected Collection<File> getOutputForIncrementalBuild() {
- return Collections.emptyList();
- }
-
/**
* Actual entry point for the action.
* Calls out to the doTaskAction as needed.
*/
@TaskAction
- void taskAction() {
- try {
- if (!isIncremental() || incrementalFolder == null) {
- doFullTaskAction()
- return;
- }
-
- // load known state.
- ChangeManager changeManager = new ChangeManager()
- boolean fullBuild = !changeManager.load(incrementalFolder)
-
- // update with current files.
- TaskInputs inputs = getInputs()
- FileCollection inputCollection = inputs.getFiles()
-
- for (File f : inputCollection.files) {
- changeManager.addInput(f)
- }
-
- for (File f : getOutputForIncrementalBuild()) {
- changeManager.addOutput(f);
- }
-
- // force full build if output changed somehow.
- Map<File, FileStatus> changedOutputs = changeManager.getChangedOutputs()
- Map<File, FileStatus> changedInputs = changeManager.getChangedInputs()
- if (fullBuild) {
- project.logger.info("No incremental data: full task run")
- doFullTaskAction();
- } else if (!changedOutputs.isEmpty()) {
- project.logger.info("Changed output: full task run")
-
- doFullTaskAction();
- } else if (changedInputs.isEmpty() && changedOutputs.isEmpty()) {
- // both input and output are empty, this is something we don't control
- // through files, just do a full run
- project.logger.info("Changed non file input/output: full task run")
- doFullTaskAction()
- } else {
- doIncrementalTaskAction(changeManager.getChangedInputs())
- }
+ void taskAction(IncrementalTaskInputs inputs) {
+ if (!isIncremental()) {
+ doFullTaskAction()
+ return
+ }
- // update the outputs post task-action, to record their state
- // for the next run
- changeManager.updateOutputs(getOutputForIncrementalBuild())
+ if (!inputs.isIncremental()) {
+ project.logger.info("Unable do incremental execution: full task run")
+ doFullTaskAction()
+ return
+ }
- // write the result down to be used next time the task is run.
- changeManager.write(incrementalFolder)
- } catch (Exception e) {
- // Easiest to do here, is to delete the incremental Data so that
- // next run is full.
- ChangeManager.delete(incrementalFolder)
+ Map<File, FileStatus> changedInputs = Maps.newHashMap()
+ inputs.outOfDate { change ->
+ //noinspection GroovyAssignabilityCheck
+ changedInputs.put(change.file, change.isAdded() ? FileStatus.NEW : FileStatus.CHANGED)
+ }
- throw e
+ inputs.removed { change ->
+ //noinspection GroovyAssignabilityCheck
+ changedInputs.put(change.file, FileStatus.REMOVED)
}
+
+ doIncrementalTaskAction(changedInputs)
}
public static List<File> flattenSourceSets(List<? extends SourceSet> resourceSets) {
- List<File> list = Lists.newArrayList();
+ List<File> list = Lists.newArrayList()
for (SourceSet sourceSet : resourceSets) {
list.addAll(sourceSet.sourceFiles)
}
- return list;
+ return list
}
}
diff --git a/gradle/src/main/groovy/com/android/build/gradle/tasks/AidlCompile.groovy b/gradle/src/main/groovy/com/android/build/gradle/tasks/AidlCompile.groovy
index d698bd7..6ad9277 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/tasks/AidlCompile.groovy
+++ b/gradle/src/main/groovy/com/android/build/gradle/tasks/AidlCompile.groovy
@@ -47,11 +47,6 @@ public class AidlCompile extends DependencyBasedCompileTask {
}
@Override
- protected Collection<File> getOutputForIncrementalBuild() {
- return Collections.singletonList(getSourceOutputDir())
- }
-
- @Override
protected void compileAllFiles(DependencyFileProcessor dependencyFileProcessor) {
getBuilder().compileAllAidlFiles(
getSourceDirs(),
diff --git a/gradle/src/main/groovy/com/android/build/gradle/tasks/MergeAssets.groovy b/gradle/src/main/groovy/com/android/build/gradle/tasks/MergeAssets.groovy
index b40a87a..79f6190 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/tasks/MergeAssets.groovy
+++ b/gradle/src/main/groovy/com/android/build/gradle/tasks/MergeAssets.groovy
@@ -50,11 +50,6 @@ public class MergeAssets extends IncrementalTask {
}
@Override
- protected Collection<File> getOutputForIncrementalBuild() {
- return Collections.singletonList(getOutputDir())
- }
-
- @Override
protected void doFullTaskAction() {
// this is full run, clean the previous output
File destinationDir = getOutputDir()
diff --git a/gradle/src/main/groovy/com/android/build/gradle/tasks/MergeResources.groovy b/gradle/src/main/groovy/com/android/build/gradle/tasks/MergeResources.groovy
index b7d4c56..16f6ff3 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/tasks/MergeResources.groovy
+++ b/gradle/src/main/groovy/com/android/build/gradle/tasks/MergeResources.groovy
@@ -54,11 +54,6 @@ public class MergeResources extends IncrementalTask {
}
@Override
- protected Collection<File> getOutputForIncrementalBuild() {
- return Collections.singletonList(getOutputDir())
- }
-
- @Override
protected void doFullTaskAction() {
// this is full run, clean the previous output
File destinationDir = getOutputDir()