aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2010-10-25 14:24:09 -0700
committerXavier Ducrohet <xav@android.com>2010-10-25 14:55:32 -0700
commita6324a21d1912144ed4e468ab5e127169992ab6e (patch)
tree4c4f64eb46203d9f1965b3b2611968bb78cbdd80
parent76e0b61e01de334ec13a48b5c2ce6d81707e743d (diff)
downloadsdk-a6324a21d1912144ed4e468ab5e127169992ab6e.zip
sdk-a6324a21d1912144ed4e468ab5e127169992ab6e.tar.gz
sdk-a6324a21d1912144ed4e468ab5e127169992ab6e.tar.bz2
Fix external jar support when building with proguard.
Change-Id: I3dafb284770f475d70a212cbe22cdae6bff36ff7
-rw-r--r--anttasks/src/com/android/ant/IfElseTask.java41
-rw-r--r--files/ant/main_rules.xml26
2 files changed, 44 insertions, 23 deletions
diff --git a/anttasks/src/com/android/ant/IfElseTask.java b/anttasks/src/com/android/ant/IfElseTask.java
index 0a59466..f34e486 100644
--- a/anttasks/src/com/android/ant/IfElseTask.java
+++ b/anttasks/src/com/android/ant/IfElseTask.java
@@ -17,10 +17,9 @@
package com.android.ant;
import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.Sequential;
-import org.apache.tools.ant.taskdefs.condition.IsSet;
+import org.apache.tools.ant.taskdefs.condition.And;
/**
* If (condition) then: {@link Sequential} else: {@link Sequential}.
@@ -35,7 +34,10 @@ import org.apache.tools.ant.taskdefs.condition.IsSet;
*
* or
*
- * <if isset="propertyname">
+ * <if>
+ * <condition>
+ * ...
+ * </condition>
* <then>
* </then>
* <else>
@@ -43,6 +45,7 @@ import org.apache.tools.ant.taskdefs.condition.IsSet;
* </if>
*
* both <then> and <else> behave like <sequential>.
+ * <condition> behaves like an <and> condition.
*
* The presence of both <then> and <else> is not required, but one of them must be present.
* <if condition="${some.condition}">
@@ -56,6 +59,7 @@ public class IfElseTask extends Task {
private boolean mCondition;
private boolean mConditionIsSet = false;
+ private And mAnd;
private Sequential mThen;
private Sequential mElse;
@@ -63,28 +67,21 @@ public class IfElseTask extends Task {
* Sets the condition value
*/
public void setCondition(boolean condition) {
- if (mConditionIsSet) {
- throw new BuildException("Cannot use both condition and isset attribute");
- }
-
mCondition = condition;
mConditionIsSet = true;
}
- public void setIsset(String name) {
+ /**
+ * Creates and returns the <condition> node which is basically a <and>.
+ */
+ public Object createCondition() {
if (mConditionIsSet) {
- throw new BuildException("Cannot use both condition and isset attribute");
+ throw new BuildException("Cannot use both condition attribute and <condition> element");
}
- Project antProject = getProject();
-
- // use Isset to ensure the implementation is correct
- IsSet isSet = new IsSet();
- isSet.setProject(antProject);
- isSet.setProperty(name);
-
- mCondition = isSet.eval();
- mConditionIsSet = true;
+ mAnd = new And();
+ mAnd.setProject(getProject());
+ return mAnd;
}
/**
@@ -105,8 +102,12 @@ public class IfElseTask extends Task {
@Override
public void execute() throws BuildException {
- if (mConditionIsSet == false) {
- throw new BuildException("condition or isset attribute is missing");
+ if (mConditionIsSet == false && mAnd == null) {
+ throw new BuildException("condition attribute or element must be set.");
+ }
+
+ if (mAnd != null) {
+ mCondition = mAnd.eval();
}
// need at least one.
diff --git a/files/ant/main_rules.xml b/files/ant/main_rules.xml
index 83f2a63..f573f48 100644
--- a/files/ant/main_rules.xml
+++ b/files/ant/main_rules.xml
@@ -177,10 +177,23 @@
<element name="external-libs" optional="yes" />
<element name="extra-parameters" optional="yes" />
<sequential>
- <!-- sets the input for dex. If a pre-dex task sets it to something else
- this has no effect -->
+ <!-- sets the primary input for dex. If a pre-dex task sets it to
+ something else this has no effect -->
<property name="out.dex.input.absolute.dir" value="${out.classes.absolute.dir}" />
+ <!-- set the secondary dx input: the project (and library) jar files
+ If a pre-dex task sets it to something else this has no effect -->
+ <if>
+ <condition>
+ <isreference refid="out.dex.jar.input.ref" />
+ </condition>
+ <else>
+ <path id="out.dex.jar.input.ref">
+ <path refid="jar.libs.ref" />
+ </path>
+ </else>
+ </if>
+
<echo>Converting compiled files and external libraries into ${intermediate.dex.file}...</echo>
<apply executable="${dx}" failonerror="true" parallel="true">
<arg value="--dex" />
@@ -188,7 +201,7 @@
<extra-parameters />
<arg line="${verbose.option}" />
<arg path="${out.dex.input.absolute.dir}" />
- <path refid="jar.libs.ref" />
+ <path refid="out.dex.jar.input.ref" />
<external-libs />
</apply>
</sequential>
@@ -535,6 +548,13 @@
<isset property="proguard.config" />
</and>
</condition>
+ <if condition="${proguard.enabled}">
+ <then>
+ <!-- Secondary dx input (jar files) is empty since all the
+ jar files will be in the obfuscated jar -->
+ <path id="out.dex.jar.input.ref" />
+ </then>
+ </if>
</target>
<target name="-set-release-mode">