aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--anttasks/src/com/android/ant/SetupTask.java58
-rw-r--r--sdkmanager/libs/sdklib/src/com/android/sdklib/IAndroidTarget.java2
-rw-r--r--sdkmanager/libs/sdklib/src/com/android/sdklib/PlatformTarget.java1
-rw-r--r--sdkmanager/libs/sdklib/src/com/android/sdklib/SdkConstants.java6
4 files changed, 52 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());
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/IAndroidTarget.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/IAndroidTarget.java
index b143fb1..1016ba8 100644
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/IAndroidTarget.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/IAndroidTarget.java
@@ -71,6 +71,8 @@ public interface IAndroidTarget extends Comparable<IAndroidTarget> {
public final static int DX = 22;
/** OS Path to the target's version of the dx.jar file. */
public final static int DX_JAR = 23;
+ /** OS Path to the "ant" folder which contains the ant build rules (ver 2 and above) */
+ public final static int ANT = 24;
/**
* Return value for {@link #getUsbVendorId()} meaning no USB vendor IDs are defined by the
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/PlatformTarget.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/PlatformTarget.java
index ed09e5f..4d912b7 100644
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/PlatformTarget.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/PlatformTarget.java
@@ -90,6 +90,7 @@ final class PlatformTarget implements IAndroidTarget {
mPaths.put(DX, mLocation + SdkConstants.OS_SDK_TOOLS_FOLDER + SdkConstants.FN_DX);
mPaths.put(DX_JAR, mLocation + SdkConstants.OS_SDK_TOOLS_LIB_FOLDER +
SdkConstants.FN_DX_JAR);
+ mPaths.put(ANT, mLocation + SdkConstants.OS_PLATFORM_ANT_FOLDER);
}
public String getLocation() {
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkConstants.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkConstants.java
index 747081d..d6cf0fc 100644
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkConstants.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkConstants.java
@@ -181,6 +181,8 @@ public final class SdkConstants {
public final static String FD_SAMPLES = "samples";
/** Name of the SDK templates folder, i.e. "templates" */
public final static String FD_TEMPLATES = "templates";
+ /** Name of the SDK Ant folder, i.e. "ant" */
+ public final static String FD_ANT = "ant";
/** Name of the SDK data folder, i.e. "data" */
public final static String FD_DATA = "data";
/** Name of the SDK resources folder, i.e. "res" */
@@ -250,6 +252,10 @@ public final class SdkConstants {
* This is an OS path, ending with a separator. */
public final static String OS_PLATFORM_TEMPLATES_FOLDER = FD_TEMPLATES + File.separator;
+ /** Path of the Ant build rules directory relative to a platform folder.
+ * This is an OS path, ending with a separator. */
+ public final static String OS_PLATFORM_ANT_FOLDER = FD_ANT + File.separator;
+
/** Path of the attrs.xml file relative to a platform folder. */
public final static String OS_PLATFORM_ATTRS_XML =
OS_PLATFORM_RESOURCES_FOLDER + FD_VALUES + File.separator + FN_ATTRS_XML;