aboutsummaryrefslogtreecommitdiffstats
path: root/anttasks
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2010-05-06 18:08:46 -0700
committerXavier Ducrohet <xav@android.com>2010-05-06 18:15:18 -0700
commit0a958e76e9406faed2c76d44557c678a6caa7081 (patch)
treed418c3bc29523a757e24e34a1d252ab403cac172 /anttasks
parent360baa4689cb7afabf758066263ccab299dfef2c (diff)
downloadsdk-0a958e76e9406faed2c76d44557c678a6caa7081.zip
sdk-0a958e76e9406faed2c76d44557c678a6caa7081.tar.gz
sdk-0a958e76e9406faed2c76d44557c678a6caa7081.tar.bz2
Add support for code-less project.
Change-Id: I09e8e5b40df3b8da4b34fe4f000e98263ea5bc55
Diffstat (limited to 'anttasks')
-rw-r--r--anttasks/src/com/android/ant/ApkBuilderTask.java41
-rw-r--r--anttasks/src/com/android/ant/SetupTask.java7
2 files changed, 43 insertions, 5 deletions
diff --git a/anttasks/src/com/android/ant/ApkBuilderTask.java b/anttasks/src/com/android/ant/ApkBuilderTask.java
index a49c2c5..9e3c8e4 100644
--- a/anttasks/src/com/android/ant/ApkBuilderTask.java
+++ b/anttasks/src/com/android/ant/ApkBuilderTask.java
@@ -39,9 +39,11 @@ public class ApkBuilderTask extends Task {
private boolean mVerbose = false;
private boolean mSigned = true;
private boolean mDebug = false;
+ private boolean mHasCode = true;
private String mAbiFilter = null;
private final ArrayList<Path> mZipList = new ArrayList<Path>();
+ private final ArrayList<Path> mDexList = new ArrayList<Path>();
private final ArrayList<Path> mFileList = new ArrayList<Path>();
private final ArrayList<Path> mSourceList = new ArrayList<Path>();
private final ArrayList<Path> mJarfolderList = new ArrayList<Path>();
@@ -129,6 +131,15 @@ public class ApkBuilderTask extends Task {
}
/**
+ * Sets the hascode attribute. Default is true.
+ * If set to false, then <dex> and <sourcefolder> nodes are ignored and not processed.
+ * @param hasCode the value of the attribute.
+ */
+ public void setHascode(boolean hasCode) {
+ mHasCode = hasCode;
+ }
+
+ /**
* Returns an object representing a nested <var>zip</var> element.
*/
public Object createZip() {
@@ -138,6 +149,17 @@ public class ApkBuilderTask extends Task {
}
/**
+ * Returns an object representing a nested <var>dex</var> element.
+ * This is similar to a nested <var>file</var> element, except when {@link #mHasCode}
+ * is <code>false</code> in which case it's ignored.
+ */
+ public Object createDex() {
+ Path path = new Path(getProject());
+ mDexList.add(path);
+ return path;
+ }
+
+ /**
* Returns an object representing a nested <var>file</var> element.
*/
public Object createFile() {
@@ -210,11 +232,22 @@ public class ApkBuilderTask extends Task {
}
}
+ // only attempt to add Dex files if hasCode is true.
+ if (mHasCode) {
+ for (Path pathList : mDexList) {
+ for (String path : pathList.list()) {
+ mArchiveFiles.add(ApkBuilderImpl.getInputFile(path));
+ }
+ }
+ }
+
// now go through the list of file to directly add the to the list.
- for (Path pathList : mSourceList) {
- for (String path : pathList.list()) {
- ApkBuilderImpl.processSourceFolderForResource(new File(path),
- mJavaResources);
+ if (mHasCode) {
+ for (Path pathList : mSourceList) {
+ for (String path : pathList.list()) {
+ ApkBuilderImpl.processSourceFolderForResource(new File(path),
+ mJavaResources);
+ }
}
}
diff --git a/anttasks/src/com/android/ant/SetupTask.java b/anttasks/src/com/android/ant/SetupTask.java
index 85ebea1..0fbd3a0 100644
--- a/anttasks/src/com/android/ant/SetupTask.java
+++ b/anttasks/src/com/android/ant/SetupTask.java
@@ -107,7 +107,7 @@ public final class SetupTask extends ImportTask {
*/
private final static int ANT_COMPATIBILITY_RANGES[][] = new int[][] {
new int[] { 1, 1 },
- new int[] { 2, 3 },
+ new int[] { 2, ANT_RULES_MAX_VERSION },
};
private boolean mDoImport = true;
@@ -357,6 +357,11 @@ public final class SetupTask extends ImportTask {
}
}
+ /**
+ * Returns the revision number of a newer but still compatible Ant rules available in the
+ * tools folder of the SDK, or -1 if none is found.
+ * @param rulesRev the revision of the rules file on which compatibility is based.
+ */
private int getAntRulesFromTools(int rulesRev) {
for (int[] range : ANT_COMPATIBILITY_RANGES) {
if (range[0] <= rulesRev && rulesRev <= range[1]) {