/** 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
// 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
// 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());
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" */
* 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;