aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--anttasks/src/com/android/ant/AaptExecLoopTask.java68
1 files changed, 46 insertions, 22 deletions
diff --git a/anttasks/src/com/android/ant/AaptExecLoopTask.java b/anttasks/src/com/android/ant/AaptExecLoopTask.java
index ed0277a..aac61b1 100644
--- a/anttasks/src/com/android/ant/AaptExecLoopTask.java
+++ b/anttasks/src/com/android/ant/AaptExecLoopTask.java
@@ -282,34 +282,57 @@ public final class AaptExecLoopTask extends BaseTask {
// Get whether we have libraries
Object libResRef = taskProject.getReference(AntConstants.PROP_PROJECT_LIBS_RES_REF);
- if (generateRClass) {
- // If the only reason we're here is to generate R.java and that doesn't need updating
- // we can skip what comes next. First we grab the dependency file.
- // Then query to see if an update is needed.
- ArrayList<File> watchPaths = new ArrayList<File>();
- // We need to watch for changes in the main project res folder
- for (Path pathList : mResources) {
- for (String path : pathList.list()) {
- watchPaths.add(new File(path));
- }
+ // Set up our folders to check for changed files
+ ArrayList<File> watchPaths = new ArrayList<File>();
+ // We need to watch for changes in the main project res folder
+ for (Path pathList : mResources) {
+ for (String path : pathList.list()) {
+ watchPaths.add(new File(path));
}
- // and if libraries exist, in their res folders
- if (libResRef instanceof Path) {
- for (String path : ((Path)libResRef).list()) {
- watchPaths.add(new File(path));
- }
+ }
+ // and if libraries exist, in their res folders
+ if (libResRef instanceof Path) {
+ for (String path : ((Path)libResRef).list()) {
+ watchPaths.add(new File(path));
+ }
+ }
+ // If we're here to generate a .ap_ file we need to watch assets as well
+ if (!generateRClass) {
+ File assetsDir = new File(mAssets);
+ if (mAssets != null && assetsDir.isDirectory()) {
+ watchPaths.add(assetsDir);
}
+ }
+
+ // Now we figure out what we need to do
+ if (generateRClass) {
+ // Check to see if our dependencies have changed. If not, then skip
if (initDependencies(mRFolder + File.separator + "R.d", watchPaths)
&& dependenciesHaveChanged() == false) {
System.out.println("No changed resources. R.java and Manifest.java untouched.");
return;
}
- } else if (mResourceFilter == null) {
- System.out.println("Creating full resource package...");
} else {
- System.out.println(String.format(
- "Creating resource package with filter: (%1$s)...",
- mResourceFilter));
+ // Find our dependency file. It should have the same name as our target .ap_ but
+ // with a .d extension
+ String dependencyFilePath = mApkFolder + File.separator + mApkName;
+ dependencyFilePath =
+ dependencyFilePath.substring(0, dependencyFilePath.lastIndexOf(".")) + ".d";
+
+ // Check to see if our dependencies have changed
+ if (initDependencies(dependencyFilePath , watchPaths)
+ && dependenciesHaveChanged() == false) {
+ System.out.println("No changed resources or assets. " + dependencyFilePath
+ + " remains untouched");
+ return;
+ }
+ if (mResourceFilter == null) {
+ System.out.println("Creating full resource package...");
+ } else {
+ System.out.println(String.format(
+ "Creating resource package with filter: (%1$s)...",
+ mResourceFilter));
+ }
}
// create a task for the default apk.
@@ -441,10 +464,11 @@ public final class AaptExecLoopTask extends BaseTask {
if (generateRClass) {
task.createArg().setValue("-J");
task.createArg().setValue(mRFolder);
- // Use dependency generation
- task.createArg().setValue("--generate-dependencies");
}
+ // Use dependency generation
+ task.createArg().setValue("--generate-dependencies");
+
// final setup of the task
task.setProject(taskProject);
task.setOwningTarget(getOwningTarget());