aboutsummaryrefslogtreecommitdiffstats
path: root/anttasks
diff options
context:
space:
mode:
authorJosiah Gaskin <josiahgaskin@google.com>2011-06-09 15:45:04 -0700
committerJosiah Gaskin <josiahgaskin@google.com>2011-07-18 16:59:48 -0700
commitad94adc4e79ee99741635db328e0b85c4ed712ec (patch)
treee3aa0f9c97ffa1fdfaea0ead1fad02ac5c377345 /anttasks
parent42374d0bbbbc2f37124c31dbcaa282eface0b2dd (diff)
downloadsdk-ad94adc4e79ee99741635db328e0b85c4ed712ec.zip
sdk-ad94adc4e79ee99741635db328e0b85c4ed712ec.tar.gz
sdk-ad94adc4e79ee99741635db328e0b85c4ed712ec.tar.bz2
Adding support to ADT and ant for smart R.java gen
This change lets ADT and ant make use of the new --extra-packages flag in aapt to allow for all the R.java files to be generated using only one call rather than one call per library. Change-Id: Ibc060b1218010cfbae108f4f1aba2c25fe69a964
Diffstat (limited to 'anttasks')
-rw-r--r--anttasks/src/com/android/ant/AaptExecLoopTask.java34
1 files changed, 12 insertions, 22 deletions
diff --git a/anttasks/src/com/android/ant/AaptExecLoopTask.java b/anttasks/src/com/android/ant/AaptExecLoopTask.java
index d7d53c9..725f6b6 100644
--- a/anttasks/src/com/android/ant/AaptExecLoopTask.java
+++ b/anttasks/src/com/android/ant/AaptExecLoopTask.java
@@ -253,37 +253,27 @@ public final class AaptExecLoopTask extends Task {
public void execute() throws BuildException {
Project taskProject = getProject();
- // first do a full resource package
- callAapt(null /*customPackage*/);
+ String libPkgProp = null;
// if the parameters indicate generation of the R class, check if
// more R classes need to be created for libraries.
if (mRFolder != null && new File(mRFolder).isDirectory()) {
- String libPkgProp = taskProject.getProperty(AntConstants.PROP_PROJECT_LIBS_PKG);
- if (libPkgProp != null) {
- // get the main package to compare in case the libraries use the same
- String mainPackage = taskProject.getProperty(AntConstants.PROP_MANIFEST_PACKAGE);
-
- String[] libPkgs = libPkgProp.split(";");
- for (String libPkg : libPkgs) {
- if (libPkg.length() > 0 && mainPackage.equals(libPkg) == false) {
- // FIXME: instead of recreating R.java from scratch, maybe copy
- // the files (R.java and manifest.java)? This would force to replace
- // the package line on the fly.
- callAapt(libPkg);
- }
- }
- }
+ libPkgProp = taskProject.getProperty(AntConstants.PROP_PROJECT_LIBS_PKG);
+ // Replace ";" with ":" since that's what aapt expects
+ libPkgProp = libPkgProp.replace(';', ':');
}
+ // Call aapt. If there are libraries, we'll pass a non-null string of libs.
+ callAapt(libPkgProp);
}
/**
* Calls aapt with the given parameters.
* @param resourceFilter the resource configuration filter to pass to aapt (if configName is
* non null)
- * @param customPackage an optional custom package.
+ * @param extraPackages an optional list of colon-separated packages. Can be null
+ * Ex: com.foo.one:com.foo.two:com.foo.lib
*/
- private void callAapt(String customPackage) {
+ private void callAapt(String extraPackages) {
Project taskProject = getProject();
final boolean generateRClass = mRFolder != null && new File(mRFolder).isDirectory();
@@ -351,9 +341,9 @@ public final class AaptExecLoopTask extends Task {
}
}
- if (customPackage != null) {
- task.createArg().setValue("--custom-package");
- task.createArg().setValue(customPackage);
+ if (extraPackages != null) {
+ task.createArg().setValue("--extra-packages");
+ task.createArg().setValue(extraPackages);
}
// if the project contains libraries, force auto-add-overlay