aboutsummaryrefslogtreecommitdiffstats
path: root/anttasks/src/com/android
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2010-03-18 13:37:06 -0700
committerXavier Ducrohet <xav@android.com>2010-03-18 14:24:49 -0700
commitcd23678486ef1c26e9767ccfcd5e98499bb09e7a (patch)
tree4a3a8f7d0946b7d7443c6011f3f195a2b4aef22a /anttasks/src/com/android
parent61942d88200c51d3856ae0d1757acf39db168e26 (diff)
downloadsdk-cd23678486ef1c26e9767ccfcd5e98499bb09e7a.zip
sdk-cd23678486ef1c26e9767ccfcd5e98499bb09e7a.tar.gz
sdk-cd23678486ef1c26e9767ccfcd5e98499bb09e7a.tar.bz2
Add support for the new Ant rules files.
The new Ant rules files are located in <platform>/ant instead of <platform>/templates Also, the name of the file now include the revision number to make it easier to update them, so the custom task must deal with this. Change-Id: I8fff9656b17c5afad8f22b23052dfca4c598d712
Diffstat (limited to 'anttasks/src/com/android')
-rw-r--r--anttasks/src/com/android/ant/SetupTask.java58
1 files changed, 43 insertions, 15 deletions
diff --git a/anttasks/src/com/android/ant/SetupTask.java b/anttasks/src/com/android/ant/SetupTask.java
index 2c0ad53..e1ee825 100644
--- a/anttasks/src/com/android/ant/SetupTask.java
+++ b/anttasks/src/com/android/ant/SetupTask.java
@@ -67,19 +67,28 @@ public final class SetupTask extends ImportTask {
/** current max version of the Ant rules that is supported */
private final static int ANT_RULES_MAX_VERSION = 2;
- private final static String ANDROID_RULES = "android_rules.xml";
- // additional android rules for test project - depends on android_rules.xml
- private final static String ANDROID_TEST_RULES = "android_test_rules.xml";
- // additional android rules for test project - depends on android_rules.xml
- private final static String ANDROID_LIBRARY_RULES = "android_lib_rules.xml";
+ // legacy main rules file.
+ private final static String RULES_LEGACY_MAIN = "android_rules.xml";
+ // legacy test rules file - depends on android_rules.xml
+ private final static String RULES_LEGACY_TEST = "android_test_rules.xml";
+
+ // main rules file
+ private final static String RULES_MAIN = "ant_rules_r%1$d.xml";
+ // test rules file - depends on android_rules.xml
+ private final static String RULES_TEST = "ant_test_rules_r%1$d.xml";
+ // library rules file.
+ private final static String RULES_LIBRARY = "ant_lib_rules_r%1$d.xml";
+
// ant property with the path to the android.jar
private final static String PROPERTY_ANDROID_JAR = "android.jar";
// LEGACY - compatibility with 1.6 and before
private final static String PROPERTY_ANDROID_JAR_LEGACY = "android-jar";
+
// ant property with the path to the framework.jar
private final static String PROPERTY_ANDROID_AIDL = "android.aidl";
// LEGACY - compatibility with 1.6 and before
private final static String PROPERTY_ANDROID_AIDL_LEGACY = "android-aidl";
+
// ant property with the path to the aapt tool
private final static String PROPERTY_AAPT = "aapt";
// ant property with the path to the aidl tool
@@ -250,9 +259,6 @@ public final class SetupTask extends ImportTask {
// finally sets the path in the project with a reference
antProject.addReference(REF_CLASSPATH, bootclasspath);
- // find the file to import, and import it.
- String templateFolder = androidTarget.getPath(IAndroidTarget.TEMPLATES);
-
// LEGACY support. android_rules.xml in older platforms expects properties with
// older names. This sets those properties to make sure the rules will work.
if (androidTarget.getVersion().getApiLevel() <= 4) { // 1.6 and earlier
@@ -267,25 +273,47 @@ public final class SetupTask extends ImportTask {
// Now the import section. This is only executed if the task actually has to import a file.
if (mDoImport) {
+ // find the folder containing the file to import
+ int folderID = antBuildVersion == 1 ? IAndroidTarget.TEMPLATES : IAndroidTarget.ANT;
+ String rulesOSPath = androidTarget.getPath(folderID);
+
// make sure the file exists.
- File templates = new File(templateFolder);
+ File rulesFolder = new File(rulesOSPath);
- if (templates.isDirectory() == false) {
- throw new BuildException(String.format("Template directory '%s' is missing.",
- templateFolder));
+ if (rulesFolder.isDirectory() == false) {
+ throw new BuildException(String.format("Rules directory '%s' is missing.",
+ rulesOSPath));
}
- String importedRulesFileName = isLibrary ? ANDROID_LIBRARY_RULES :
- isTestProject ? ANDROID_TEST_RULES : ANDROID_RULES;
+ String importedRulesFileName;
+ if (antBuildVersion == 1) {
+ // legacy mode
+ importedRulesFileName = isTestProject ? RULES_LEGACY_TEST : RULES_LEGACY_MAIN;
+ } else {
+ importedRulesFileName = String.format(
+ isLibrary ? RULES_LIBRARY : isTestProject ? RULES_TEST : RULES_MAIN,
+ antBuildVersion);;
+ }
// now check the rules file exists.
- File rules = new File(templateFolder, importedRulesFileName);
+ File rules = new File(rulesFolder, importedRulesFileName);
if (rules.isFile() == false) {
throw new BuildException(String.format("Build rules file '%s' is missing.",
rules));
}
+ // display the file being imported.
+ // figure out the path relative to the SDK
+ String rulesLocation = rules.getAbsolutePath();
+ if (rulesLocation.startsWith(sdkLocation)) {
+ rulesLocation = rulesLocation.substring(sdkLocation.length());
+ if (rulesLocation.startsWith(File.separator)) {
+ rulesLocation = rulesLocation.substring(1);
+ }
+ }
+ System.out.println("Importing rules file: " + rulesLocation);
+
// set the file location to import
setFile(rules.getAbsolutePath());