diff options
author | Josiah Gaskin <josiahgaskin@google.com> | 2011-06-24 14:58:32 -0700 |
---|---|---|
committer | Josiah Gaskin <josiahgaskin@google.com> | 2011-07-18 17:07:36 -0700 |
commit | 8c0bb5ea1702ba4f31a35cbf7c82b3be3a0a933a (patch) | |
tree | 7115fdd0d176336ee323e792038d3d8f4defb366 /anttasks | |
parent | 065dfacbf0c6e46c80f53d9207fac17afcb1fca7 (diff) | |
download | sdk-8c0bb5ea1702ba4f31a35cbf7c82b3be3a0a933a.zip sdk-8c0bb5ea1702ba4f31a35cbf7c82b3be3a0a933a.tar.gz sdk-8c0bb5ea1702ba4f31a35cbf7c82b3be3a0a933a.tar.bz2 |
Add support to Ant for packaging dependency checks
This change adds in support for making aapt generate a dependency
file for the .ap_ package generated during resource packaging. Ant
will then check this dependency file before calling aapt again and
will only repackage resources if the dependencies have been modified
in some way.
Change-Id: I56462163c5dd064c1416bc43913f044df8ee9be1
Diffstat (limited to 'anttasks')
-rw-r--r-- | anttasks/src/com/android/ant/AaptExecLoopTask.java | 68 |
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()); |