aboutsummaryrefslogtreecommitdiff
path: root/gradle
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@google.com>2013-11-07 17:31:18 -0800
committerXavier Ducrohet <xav@google.com>2013-11-07 17:31:56 -0800
commit3b6b3bc5c372d788874aa8f155f6dbff1621d667 (patch)
tree34099a7a6d503398965164aafcd96498aa65d40d /gradle
parentf266f92a7a8c76ebe4b5f9b7f13602c3e671ed7a (diff)
downloadbuild-3b6b3bc5c372d788874aa8f155f6dbff1621d667.tar.gz
Switch to the Gradle input file detection mechanism.
Change-Id: Id054d857e64a0fe7620e3b80ae8d44f8e7ce3d90
Diffstat (limited to 'gradle')
-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
6 files changed, 28 insertions, 85 deletions
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()