aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2010-09-16 18:53:44 -0700
committerXavier Ducrohet <xav@android.com>2010-09-24 16:33:38 -0700
commita66ca8ad997527af0e7a07ba851da0a6d379fad0 (patch)
tree0827f8d51c3d55ecf4abc0f2b824feafdf211a4f
parent03dec99d1bc5fc418e58235c5e6dd0543b41413e (diff)
downloadsdk-a66ca8ad997527af0e7a07ba851da0a6d379fad0.zip
sdk-a66ca8ad997527af0e7a07ba851da0a6d379fad0.tar.gz
sdk-a66ca8ad997527af0e7a07ba851da0a6d379fad0.tar.bz2
Use proguard for release builds through Ant.
This is only activated if default.properties contains a property "proguard.config" with the name of a proguard config file. Some clean-up in the Ant tasks and in the name of the properties used by the rules and the custom tasks to make them clearer. Added a new test app with a project using a jar file as well as a library using a jar file. Change-Id: Ia8f4d873025993d454c0a484e61d47ae679ea79c
-rw-r--r--anttasks/src/com/android/ant/AaptExecLoopTask.java13
-rw-r--r--anttasks/src/com/android/ant/AntConstants.java58
-rw-r--r--anttasks/src/com/android/ant/IfElseTask.java35
-rw-r--r--anttasks/src/com/android/ant/MultiApkExportTask.java12
-rw-r--r--anttasks/src/com/android/ant/SetupTask.java39
-rw-r--r--files/ant/main_rules.xml100
-rw-r--r--testapps/basicJar/build.xml10
-rw-r--r--testapps/basicJar/src/com/android/tests/basicjar/Foo.java16
-rw-r--r--testapps/basicLibWithJar/AndroidManifest.xml16
-rw-r--r--testapps/basicLibWithJar/build.properties17
-rw-r--r--testapps/basicLibWithJar/build.xml84
-rw-r--r--testapps/basicLibWithJar/default.properties12
-rw-r--r--testapps/basicLibWithJar/libs/basicJar.jarbin0 -> 2713 bytes
-rw-r--r--testapps/basicLibWithJar/res/drawable/icon.pngbin0 -> 2574 bytes
-rw-r--r--testapps/basicLibWithJar/res/layout/main.xml13
-rw-r--r--testapps/basicLibWithJar/res/values/strings.xml4
-rw-r--r--testapps/basicLibWithJar/src/com/android/tests/basiclibwithjar/Main.java21
-rw-r--r--testapps/basicProject/default.properties1
-rw-r--r--testapps/basicProjectWithJar/AndroidManifest.xml16
-rw-r--r--testapps/basicProjectWithJar/build.properties17
-rw-r--r--testapps/basicProjectWithJar/build.xml84
-rw-r--r--testapps/basicProjectWithJar/default.properties12
-rw-r--r--testapps/basicProjectWithJar/libs/basicJar.jarbin0 -> 2713 bytes
-rw-r--r--testapps/basicProjectWithJar/res/drawable/icon.pngbin0 -> 2574 bytes
-rw-r--r--testapps/basicProjectWithJar/res/layout/main.xml13
-rw-r--r--testapps/basicProjectWithJar/res/values/strings.xml4
-rw-r--r--testapps/basicProjectWithJar/src/com/android/tests/basicprojectwithjar/Main.java20
-rw-r--r--testapps/basicProjectWithLib/AndroidManifest.xml9
-rw-r--r--testapps/basicProjectWithLib/default.properties4
-rw-r--r--testapps/proguard.config31
30 files changed, 602 insertions, 59 deletions
diff --git a/anttasks/src/com/android/ant/AaptExecLoopTask.java b/anttasks/src/com/android/ant/AaptExecLoopTask.java
index 171e781..f3824ef 100644
--- a/anttasks/src/com/android/ant/AaptExecLoopTask.java
+++ b/anttasks/src/com/android/ant/AaptExecLoopTask.java
@@ -259,10 +259,10 @@ public final class AaptExecLoopTask extends Task {
// if the parameters indicate generation of the R class, check if
// more R classes need to be created for libraries.
if (mRFolder != null && new File(mRFolder).isDirectory()) {
- String libPkgProp = taskProject.getProperty("android.libraries.package");
+ String libPkgProp = taskProject.getProperty(AntConstants.PROP_PROJECT_LIBS_PKG);
if (libPkgProp != null) {
// get the main package to compare in case the libraries use the same
- String mainPackage = taskProject.getProperty("manifest.package");
+ String mainPackage = taskProject.getProperty(AntConstants.PROP_MANIFEST_PACKAGE);
String[] libPkgs = libPkgProp.split(";");
for (String libPkg : libPkgs) {
@@ -354,8 +354,8 @@ public final class AaptExecLoopTask extends Task {
}
// if the project contains libraries, force auto-add-overlay
- Object libSrc = taskProject.getReference("android.libraries.res");
- if (libSrc != null) {
+ Object libResRef = taskProject.getReference(AntConstants.PROP_PROJECT_LIBS_RES_REF);
+ if (libResRef != null) {
task.createArg().setValue("--auto-add-overlay");
}
@@ -385,9 +385,8 @@ public final class AaptExecLoopTask extends Task {
}
// add other resources coming from library project
- Object libPath = taskProject.getReference("android.libraries.res");
- if (libPath instanceof Path) {
- for (String path : ((Path)libPath).list()) {
+ if (libResRef instanceof Path) {
+ for (String path : ((Path)libResRef).list()) {
// This may not exists, and aapt doesn't like it, so we check first.
File res = new File(path);
if (res.isDirectory()) {
diff --git a/anttasks/src/com/android/ant/AntConstants.java b/anttasks/src/com/android/ant/AntConstants.java
new file mode 100644
index 0000000..81c6682
--- /dev/null
+++ b/anttasks/src/com/android/ant/AntConstants.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.ant;
+
+/**
+ * Constants used by custom tasks and the rules files.
+ */
+public interface AntConstants {
+
+ /** ant property with the path to the android.jar */
+ public final static String PROP_ANDROID_JAR = "android.jar";
+
+ /** ant property with the path to the framework.jar */
+ public final static String PROP_ANDROID_AIDL = "android.aidl";
+
+ /** ant property with the path to the aapt tool */
+ public final static String PROP_AAPT = "aapt";
+ /** ant property with the path to the aidl tool */
+ public final static String PROP_AIDL = "aidl";
+ /** ant property with the path to the dx tool */
+ public final static String PROP_DX = "dx";
+ /** ref id to the <path> object containing all the boot classpaths. */
+ public final static String PROP_CLASSPATH_REF = "android.target.classpath";
+
+ /** ant property ref to the list of source folder for the project libraries */
+ public static final String PROP_PROJECT_LIBS_SRC_REF = "project.libraries.src";
+ /** ant property ref to the list of jars for the project libraries */
+ public static final String PROP_PROJECT_LIBS_JARS_REF = "project.libraries.jars";
+ /** ant property ref to the list of libs folder for the project libraries */
+ public static final String PROP_PROJECT_LIBS_LIBS_REF = "project.libraries.libs";
+ /** ant property ref to the list of res folder for the project libraries */
+ public static final String PROP_PROJECT_LIBS_RES_REF = "project.libraries.res";
+ /** ant property for semi-colon separated packages for the project libraries */
+ public static final String PROP_PROJECT_LIBS_PKG = "project.libraries.package";
+ /** ant property for the test project directory */
+ public static final String PROP_TESTED_PROJECT_DIR = "tested.project.dir";
+
+ public static final String PROP_MANIFEST_PACKAGE = "manifest.package";
+
+ public static final String PROP_OUT_ABS_DIR = "out.absolute.dir";
+
+ public static final String PROP_KEY_STORE_PASSWORD = "key.store.password";
+ public static final String PROP_KEY_ALIAS_PASSWORD = "key.alias.password";
+}
diff --git a/anttasks/src/com/android/ant/IfElseTask.java b/anttasks/src/com/android/ant/IfElseTask.java
index fd4f9d0..0a59466 100644
--- a/anttasks/src/com/android/ant/IfElseTask.java
+++ b/anttasks/src/com/android/ant/IfElseTask.java
@@ -17,14 +17,25 @@
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;
/**
* If (condition) then: {@link Sequential} else: {@link Sequential}.
*
* In XML:
- * <if condition="${some.condition}">
+ * <if condition="${prop with a boolean value}">
+ * <then>
+ * </then>
+ * <else>
+ * </else>
+ * </if>
+ *
+ * or
+ *
+ * <if isset="propertyname">
* <then>
* </then>
* <else>
@@ -52,10 +63,30 @@ 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) {
+ if (mConditionIsSet) {
+ throw new BuildException("Cannot use both condition and isset attribute");
+ }
+
+ 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;
+ }
+
/**
* Creates and returns the <then> {@link Sequential}
*/
@@ -75,7 +106,7 @@ public class IfElseTask extends Task {
@Override
public void execute() throws BuildException {
if (mConditionIsSet == false) {
- throw new BuildException("Condition has not been set.");
+ throw new BuildException("condition or isset attribute is missing");
}
// need at least one.
diff --git a/anttasks/src/com/android/ant/MultiApkExportTask.java b/anttasks/src/com/android/ant/MultiApkExportTask.java
index 03e27e9..a21478e 100644
--- a/anttasks/src/com/android/ant/MultiApkExportTask.java
+++ b/anttasks/src/com/android/ant/MultiApkExportTask.java
@@ -117,7 +117,7 @@ public class MultiApkExportTask extends Task {
mXPathFactory = XPathFactory.newInstance();
File exportProjectOutput = new File(
- getValidatedProperty(antProject, "out.absolute.dir"));
+ getValidatedProperty(antProject, AntConstants.PROP_OUT_ABS_DIR));
// if there's no error, and we can sign, prompt for the passwords.
String keyStorePassword = null;
@@ -127,21 +127,23 @@ public class MultiApkExportTask extends Task {
Input input = new Input();
input.setProject(antProject);
- input.setAddproperty("key.store.password");
+ input.setAddproperty(AntConstants.PROP_KEY_STORE_PASSWORD);
input.setMessage(String.format("Please enter keystore password (store: %1$s):",
keyStore));
input.execute();
input = new Input();
input.setProject(antProject);
- input.setAddproperty("key.alias.password");
+ input.setAddproperty(AntConstants.PROP_KEY_ALIAS_PASSWORD);
input.setMessage(String.format("Please enter password for alias '%1$s':",
keyAlias));
input.execute();
// and now read the property so that they can be set into the sub ant task.
- keyStorePassword = getValidatedProperty(antProject, "key.store.password");
- keyAliasPassword = getValidatedProperty(antProject, "key.alias.password");
+ keyStorePassword = getValidatedProperty(antProject,
+ AntConstants.PROP_KEY_STORE_PASSWORD);
+ keyAliasPassword = getValidatedProperty(antProject,
+ AntConstants.PROP_KEY_ALIAS_PASSWORD);
}
for (ApkData apk : apks) {
diff --git a/anttasks/src/com/android/ant/SetupTask.java b/anttasks/src/com/android/ant/SetupTask.java
index 966956f..ba62403 100644
--- a/anttasks/src/com/android/ant/SetupTask.java
+++ b/anttasks/src/com/android/ant/SetupTask.java
@@ -71,21 +71,6 @@ public final class SetupTask extends ImportTask {
// library rules file.
private final static String RULES_LIBRARY = "lib_rules.xml";
- // ant property with the path to the android.jar
- private final static String PROPERTY_ANDROID_JAR = "android.jar";
-
- // ant property with the path to the framework.jar
- private final static String PROPERTY_ANDROID_AIDL = "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
- private final static String PROPERTY_AIDL = "aidl";
- // ant property with the path to the dx tool
- private final static String PROPERTY_DX = "dx";
- // ref id to the <path> object containing all the boot classpaths.
- private final static String REF_CLASSPATH = "android.target.classpath";
-
private boolean mDoImport = true;
@Override
@@ -112,7 +97,7 @@ public final class SetupTask extends ImportTask {
boolean isTestProject = false;
- if (antProject.getProperty("tested.project.dir") != null) {
+ if (antProject.getProperty(AntConstants.PROP_TESTED_PROJECT_DIR) != null) {
isTestProject = true;
}
@@ -185,14 +170,14 @@ public final class SetupTask extends ImportTask {
// sets up the properties to find android.jar/framework.aidl/target tools
String androidJar = androidTarget.getPath(IAndroidTarget.ANDROID_JAR);
- antProject.setProperty(PROPERTY_ANDROID_JAR, androidJar);
+ antProject.setProperty(AntConstants.PROP_ANDROID_JAR, androidJar);
String androidAidl = androidTarget.getPath(IAndroidTarget.ANDROID_AIDL);
- antProject.setProperty(PROPERTY_ANDROID_AIDL, androidAidl);
+ antProject.setProperty(AntConstants.PROP_ANDROID_AIDL, androidAidl);
- antProject.setProperty(PROPERTY_AAPT, androidTarget.getPath(IAndroidTarget.AAPT));
- antProject.setProperty(PROPERTY_AIDL, androidTarget.getPath(IAndroidTarget.AIDL));
- antProject.setProperty(PROPERTY_DX, androidTarget.getPath(IAndroidTarget.DX));
+ antProject.setProperty(AntConstants.PROP_AAPT, androidTarget.getPath(IAndroidTarget.AAPT));
+ antProject.setProperty(AntConstants.PROP_AIDL, androidTarget.getPath(IAndroidTarget.AIDL));
+ antProject.setProperty(AntConstants.PROP_DX, androidTarget.getPath(IAndroidTarget.DX));
// sets up the boot classpath
@@ -219,7 +204,7 @@ public final class SetupTask extends ImportTask {
}
// finally sets the path in the project with a reference
- antProject.addReference(REF_CLASSPATH, bootclasspath);
+ antProject.addReference(AntConstants.PROP_CLASSPATH_REF, bootclasspath);
// Now the import section. This is only executed if the task actually has to import a file.
if (mDoImport) {
@@ -436,14 +421,14 @@ public final class SetupTask extends ImportTask {
// even with no libraries, always setup these so that various tasks in Ant don't complain
// (the task themselves can handle a ref to an empty Path)
- antProject.addReference("android.libraries.src", sourcePath);
- antProject.addReference("android.libraries.jars", jarsPath);
- antProject.addReference("android.libraries.libs", libsPath);
+ antProject.addReference(AntConstants.PROP_PROJECT_LIBS_SRC_REF, sourcePath);
+ antProject.addReference(AntConstants.PROP_PROJECT_LIBS_JARS_REF, jarsPath);
+ antProject.addReference(AntConstants.PROP_PROJECT_LIBS_LIBS_REF, libsPath);
// the rest is done only if there's a library.
if (sourcePath.list().length > 0) {
- antProject.addReference("android.libraries.res", resPath);
- antProject.setProperty("android.libraries.package", sb.toString());
+ antProject.addReference(AntConstants.PROP_PROJECT_LIBS_RES_REF, resPath);
+ antProject.setProperty(AntConstants.PROP_PROJECT_LIBS_PKG, sb.toString());
}
}
diff --git a/files/ant/main_rules.xml b/files/ant/main_rules.xml
index 7059f3a..7ce46e4 100644
--- a/files/ant/main_rules.xml
+++ b/files/ant/main_rules.xml
@@ -60,8 +60,14 @@
<property name="asset.absolute.dir" location="${asset.dir}" />
<!-- Directory for the third party java libraries -->
- <property name="external.libs.dir" value="libs" />
- <property name="external.libs.absolute.dir" location="${external.libs.dir}" />
+ <property name="jar.libs.dir" value="libs" />
+ <property name="jar.libs.absolute.dir" location="${jar.libs.dir}" />
+ <!-- create a path with all the jar files, from the main project and the
+ libraries -->
+ <path id="jar.libs.ref">
+ <fileset dir="${jar.libs.absolute.dir}" includes="*.jar" />
+ <path refid="project.libraries.jars" />
+ </path>
<!-- Directory for the native libraries -->
<property name="native.libs.dir" value="libs" />
@@ -72,7 +78,6 @@
<property name="out.absolute.dir" location="${out.dir}" />
<property name="out.classes.dir" value="${out.absolute.dir}/classes" />
<property name="out.classes.absolute.dir" location="${out.classes.dir}" />
- <property name="out.dex.input.absolute.dir" value="${out.classes.absolute.dir}" />
<!-- Intermediate files -->
<property name="dex.file.name" value="classes.dex" />
@@ -179,8 +184,7 @@
<extra-parameters />
<arg line="${verbose.option}" />
<arg path="${out.dex.input.absolute.dir}" />
- <fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
- <path refid="android.libraries.jars" />
+ <path refid="jar.libs.ref" />
<external-libs />
</apply>
</sequential>
@@ -209,11 +213,11 @@
hascode="${manifest.hasCode}">
<dex path="${intermediate.dex.file}"/>
<sourcefolder path="${source.absolute.dir}"/>
- <sourcefolder refid="android.libraries.src"/>
- <jarfolder path="${external.libs.absolute.dir}" />
- <jarfolder refid="android.libraries.libs" />
+ <sourcefolder refid="project.libraries.src"/>
+ <jarfolder path="${jar.libs.absolute.dir}" />
+ <jarfolder refid="project.libraries.libs" />
<nativefolder path="${native.libs.absolute.dir}" />
- <nativefolder refid="android.libraries.libs" />
+ <nativefolder refid="project.libraries.libs" />
<extra-jars/>
</apkbuilder>
</sequential>
@@ -256,7 +260,7 @@
<target name="-dirs">
<echo>Creating output directories if needed...</echo>
<mkdir dir="${resource.absolute.dir}" />
- <mkdir dir="${external.libs.absolute.dir}" />
+ <mkdir dir="${jar.libs.absolute.dir}" />
<mkdir dir="${out.absolute.dir}" />
<if condition="${manifest.hasCode}">
<then>
@@ -298,7 +302,7 @@
<aidl executable="${aidl}" framework="${android.aidl}"
genFolder="${gen.absolute.dir}">
<source path="${source.absolute.dir}"/>
- <source refid="android.libraries.src"/>
+ <source refid="project.libraries.src"/>
</aidl>
</then>
<else>
@@ -325,7 +329,7 @@
</condition>
<condition property="extensible.libs.classpath"
value="${tested.project.absolute.dir}/libs"
- else="./libs">
+ else="${jar.libs.dir}">
<isset property="tested.project.absolute.dir" />
</condition>
<javac encoding="${java.encoding}"
@@ -335,12 +339,11 @@
bootclasspathref="android.target.classpath"
verbose="${verbose}"
classpath="${extensible.classpath}"
- classpathref="android.libraries.jars">
+ classpathref="jar.libs.ref">
<src path="${source.absolute.dir}" />
<src path="${gen.absolute.dir}" />
- <src refid="android.libraries.src" />
+ <src refid="project.libraries.src" />
<classpath>
- <fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
<fileset dir="${extensible.libs.classpath}" includes="*.jar" />
</classpath>
</javac>
@@ -355,8 +358,57 @@
your build.xml and it'll be called instead of this one. -->
<target name="-post-compile"/>
+ <target name="-pre-dex" unless="do.not.compile">
+ <if condition="${proguard.enabled}">
+ <then>
+ <property name="obfuscate.absolute.dir" location="${out.absolute.dir}/proguard" />
+ <property name="preobfuscate.jar.file" value="${obfuscate.absolute.dir}/original.jar" />
+ <property name="obfuscated.jar.file" value="${obfuscate.absolute.dir}/obfuscated.jar" />
+ <property name="out.dex.input.absolute.dir" value="${obfuscated.jar.file}" />
+
+ <!-- Add Proguard Tasks -->
+ <property name="proguard.jar" location="${android.tools.dir}/proguard/lib/proguard.jar" />
+ <taskdef name="proguard" classname="proguard.ant.ProGuardTask" classpath="${proguard.jar}" />
+
+ <!-- Set the android classpath Path object into a single property. It'll be
+ all the jar files separated by a platform path-separator.
+ -->
+ <property name="android.libraryjars" refid="android.target.classpath"/>
+ <!-- Build a path object with all the jar files that must be obfuscated.
+ This include the project compiled source code and any 3rd party jar
+ files. -->
+ <path id="project.jars.ref">
+ <pathelement location="${preobfuscate.jar.file}" />
+ <path refid="jar.libs.ref" />
+ </path>
+ <!-- Set the project jar files Path object into a single property. It'll be
+ all the jar files separated by a platform path-separator.
+ -->
+ <property name="project.jars" refid="project.jars.ref" />
+
+ <mkdir dir="${obfuscate.absolute.dir}" />
+ <delete file="${preobfuscate.jar.file}"/>
+ <delete file="${obfuscated.jar.file}"/>
+ <jar basedir="${out.classes.dir}" destfile="${preobfuscate.jar.file}" />
+ <proguard>
+ @${proguard.config}
+ -injars ${project.jars}
+ -outjars ${obfuscated.jar.file}
+ -libraryjars ${android.libraryjars}
+ -dump ${obfuscate.absolute.dir}/dump.txt
+ -printseeds ${obfuscate.absolute.dir}/seeds.txt
+ -printusage ${obfuscate.absolute.dir}/usage.txt
+ -printmapping ${obfuscate.absolute.dir}/mapping.txt
+ </proguard>
+ </then>
+ <else>
+ <property name="out.dex.input.absolute.dir" value="${out.classes.absolute.dir}" />
+ </else>
+ </if>
+ </target>
+
<!-- Converts this project's .class files into .dex files -->
- <target name="-dex" depends="compile, -post-compile"
+ <target name="-dex" depends="compile, -post-compile, -pre-dex"
unless="do.not.compile">
<if condition="${manifest.hasCode}">
<then>
@@ -417,6 +469,10 @@
<!-- whether the build is a debug build. always set. -->
<property name="build.debug" value="true" />
+
+ <!-- dex input file: in debug mode, no proguard, input
+ is always the out class folder -->
+ <property name="proguard.enabled" value="false"/>
</target>
<!-- Builds debug output package, provided all the necessary files are already dexed -->
@@ -455,6 +511,18 @@
<!-- whether the build is a debug build. always set. -->
<property name="build.debug" value="false" />
+
+ <!-- dex input file: in release mode, it's dependent on whether
+ proguard is used. -->
+ <if isset="proguard.config">
+ <then>
+ <property name="proguard.enabled" value="true"/>
+ </then>
+ <else>
+ <property name="proguard.enabled" value="false"/>
+ <property name="out.dex.input.absolute.dir" value="${out.classes.absolute.dir}" />
+ </else>
+ </if>
</target>
<!-- This runs -package-release and -release-nosign first and then runs
diff --git a/testapps/basicJar/build.xml b/testapps/basicJar/build.xml
new file mode 100644
index 0000000..178e6b0
--- /dev/null
+++ b/testapps/basicJar/build.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="basicJar" default="compile">
+ <target name="compile">
+ <mkdir dir="${basedir}/bin" />
+ <mkdir dir="${basedir}/bin/classes" />
+ <javac encoding="ascii" target="1.5" debug="true" extdirs=""
+ srcdir="src" destdir="${basedir}/bin/classes" />
+ <jar basedir="${basedir}/bin/classes" destfile="${basedir}/bin/${ant.project.name}.jar" />
+ </target>
+</project> \ No newline at end of file
diff --git a/testapps/basicJar/src/com/android/tests/basicjar/Foo.java b/testapps/basicJar/src/com/android/tests/basicjar/Foo.java
new file mode 100644
index 0000000..6a9536f
--- /dev/null
+++ b/testapps/basicJar/src/com/android/tests/basicjar/Foo.java
@@ -0,0 +1,16 @@
+package com.android.tests.basicjar;
+
+import java.util.Random;
+
+public class Foo {
+ public static int FOO = 42;
+
+ public int getFoo() {
+ return FOO;
+ }
+
+ public int getRandomFoo() {
+ Random r = new Random(System.currentTimeMillis());
+ return r.nextInt(FOO);
+ }
+} \ No newline at end of file
diff --git a/testapps/basicLibWithJar/AndroidManifest.xml b/testapps/basicLibWithJar/AndroidManifest.xml
new file mode 100644
index 0000000..c8650f8
--- /dev/null
+++ b/testapps/basicLibWithJar/AndroidManifest.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.tests.basiclibwithjar"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <application android:label="@string/app_name" android:icon="@drawable/icon">
+ <activity android:name="Main"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+ <uses-sdk android:minSdkVersion="AOSP" />
+</manifest>
diff --git a/testapps/basicLibWithJar/build.properties b/testapps/basicLibWithJar/build.properties
new file mode 100644
index 0000000..ee52d86
--- /dev/null
+++ b/testapps/basicLibWithJar/build.properties
@@ -0,0 +1,17 @@
+# This file is used to override default values used by the Ant build system.
+#
+# This file must be checked in Version Control Systems, as it is
+# integral to the build system of your project.
+
+# This file is only used by the Ant script.
+
+# You can use this to override default values such as
+# 'source.dir' for the location of your java source folder and
+# 'out.dir' for the location of your output folder.
+
+# You can also use it define how the release builds are signed by declaring
+# the following properties:
+# 'key.store' for the location of your keystore and
+# 'key.alias' for the name of the key to use.
+# The password will be asked during the build when you use the 'release' target.
+
diff --git a/testapps/basicLibWithJar/build.xml b/testapps/basicLibWithJar/build.xml
new file mode 100644
index 0000000..ea34e33
--- /dev/null
+++ b/testapps/basicLibWithJar/build.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="basicLib" default="help">
+
+<!-- The local.properties file is created and updated by the 'android'
+ tool.
+ It contains the path to the SDK. It should *NOT* be checked into
+ Version Control Systems. -->
+ <property file="local.properties" />
+
+ <!-- The build.properties file can be created by you and is never touched
+ by the 'android' tool. This is the place to change some of the
+ default property values used by the Ant rules.
+ Here are some properties you may want to change/update:
+
+ source.dir
+ The name of the source directory. Default is 'src'.
+ out.dir
+ The name of the output directory. Default is 'bin'.
+
+ Properties related to the SDK location or the project target should
+ be updated using the 'android' tool with the 'update' action.
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems.
+
+ -->
+ <property file="build.properties" />
+
+ <!-- The default.properties file is created and updated by the 'android'
+ tool, as well as ADT.
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems. -->
+ <property file="default.properties" />
+
+ <!-- Custom Android task to deal with the project target, and import the
+ proper rules.
+ This requires ant 1.6.0 or above. -->
+ <path id="android.antlibs">
+ <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
+ </path>
+
+ <taskdef name="setup"
+ classname="com.android.ant.SetupTask"
+ classpathref="android.antlibs" />
+
+<!-- extension targets. Uncomment the ones where you want to do custom work
+ in between standard targets -->
+<!--
+ <target name="-pre-build">
+ </target>
+ <target name="-pre-compile">
+ </target>
+
+ [This is typically used for code obfuscation.
+ Compiled code location: ${out.classes.absolute.dir}
+ If this is not done in place, override ${out.dex.input.absolute.dir}]
+ <target name="-post-compile">
+ </target>
+-->
+
+
+ <!-- Execute the Android Setup task that will setup some properties
+ specific to the target, and import the build rules files.
+
+ The rules file is imported from
+ <SDK>/platforms/<target_platform>/ant/ant_rules_r#.xml
+
+ To customize existing targets, there are two options:
+ - Customize only one target:
+ - copy/paste the target into this file, *before* the
+ <setup> task.
+ - customize it to your needs.
+ - Customize the whole script.
+ - copy/paste the content of the rules files (minus the top node)
+ into this file, *after* the <setup> task
+ - disable the import of the rules by changing the setup task
+ below to <setup import="false" />.
+ - customize to your needs.
+ -->
+ <setup />
+
+</project>
diff --git a/testapps/basicLibWithJar/default.properties b/testapps/basicLibWithJar/default.properties
new file mode 100644
index 0000000..beef685
--- /dev/null
+++ b/testapps/basicLibWithJar/default.properties
@@ -0,0 +1,12 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "build.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-AOSP
+android.library=true
diff --git a/testapps/basicLibWithJar/libs/basicJar.jar b/testapps/basicLibWithJar/libs/basicJar.jar
new file mode 100644
index 0000000..8169064
--- /dev/null
+++ b/testapps/basicLibWithJar/libs/basicJar.jar
Binary files differ
diff --git a/testapps/basicLibWithJar/res/drawable/icon.png b/testapps/basicLibWithJar/res/drawable/icon.png
new file mode 100644
index 0000000..a07c69f
--- /dev/null
+++ b/testapps/basicLibWithJar/res/drawable/icon.png
Binary files differ
diff --git a/testapps/basicLibWithJar/res/layout/main.xml b/testapps/basicLibWithJar/res/layout/main.xml
new file mode 100644
index 0000000..b79cddb
--- /dev/null
+++ b/testapps/basicLibWithJar/res/layout/main.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ >
+<TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="Hello World, Main"
+ />
+</LinearLayout>
+
diff --git a/testapps/basicLibWithJar/res/values/strings.xml b/testapps/basicLibWithJar/res/values/strings.xml
new file mode 100644
index 0000000..549e4ea
--- /dev/null
+++ b/testapps/basicLibWithJar/res/values/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">Main</string>
+</resources>
diff --git a/testapps/basicLibWithJar/src/com/android/tests/basiclibwithjar/Main.java b/testapps/basicLibWithJar/src/com/android/tests/basiclibwithjar/Main.java
new file mode 100644
index 0000000..f973cc2
--- /dev/null
+++ b/testapps/basicLibWithJar/src/com/android/tests/basiclibwithjar/Main.java
@@ -0,0 +1,21 @@
+package com.android.tests.basiclibwithjar;
+
+import com.android.tests.basicjar.Foo;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+public class Main extends Activity
+{
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ Foo foo = new Foo();
+ int a = foo.getRandomFoo();
+
+ }
+}
diff --git a/testapps/basicProject/default.properties b/testapps/basicProject/default.properties
index 8ee25b8..6bd3afc 100644
--- a/testapps/basicProject/default.properties
+++ b/testapps/basicProject/default.properties
@@ -9,3 +9,4 @@
# Project target.
target=android-AOSP
+proguard.config=../proguard.config \ No newline at end of file
diff --git a/testapps/basicProjectWithJar/AndroidManifest.xml b/testapps/basicProjectWithJar/AndroidManifest.xml
new file mode 100644
index 0000000..1a2b54c
--- /dev/null
+++ b/testapps/basicProjectWithJar/AndroidManifest.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.tests.basicprojectwithjar"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <application android:label="@string/app_name" android:icon="@drawable/icon">
+ <activity android:name="Main"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+ <uses-sdk android:minSdkVersion="AOSP" />
+</manifest>
diff --git a/testapps/basicProjectWithJar/build.properties b/testapps/basicProjectWithJar/build.properties
new file mode 100644
index 0000000..ee52d86
--- /dev/null
+++ b/testapps/basicProjectWithJar/build.properties
@@ -0,0 +1,17 @@
+# This file is used to override default values used by the Ant build system.
+#
+# This file must be checked in Version Control Systems, as it is
+# integral to the build system of your project.
+
+# This file is only used by the Ant script.
+
+# You can use this to override default values such as
+# 'source.dir' for the location of your java source folder and
+# 'out.dir' for the location of your output folder.
+
+# You can also use it define how the release builds are signed by declaring
+# the following properties:
+# 'key.store' for the location of your keystore and
+# 'key.alias' for the name of the key to use.
+# The password will be asked during the build when you use the 'release' target.
+
diff --git a/testapps/basicProjectWithJar/build.xml b/testapps/basicProjectWithJar/build.xml
new file mode 100644
index 0000000..3503448
--- /dev/null
+++ b/testapps/basicProjectWithJar/build.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="basicProjectWithJar" default="help">
+
+<!-- The local.properties file is created and updated by the 'android'
+ tool.
+ It contains the path to the SDK. It should *NOT* be checked into
+ Version Control Systems. -->
+ <property file="local.properties" />
+
+ <!-- The build.properties file can be created by you and is never touched
+ by the 'android' tool. This is the place to change some of the
+ default property values used by the Ant rules.
+ Here are some properties you may want to change/update:
+
+ source.dir
+ The name of the source directory. Default is 'src'.
+ out.dir
+ The name of the output directory. Default is 'bin'.
+
+ Properties related to the SDK location or the project target should
+ be updated using the 'android' tool with the 'update' action.
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems.
+
+ -->
+ <property file="build.properties" />
+
+ <!-- The default.properties file is created and updated by the 'android'
+ tool, as well as ADT.
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems. -->
+ <property file="default.properties" />
+
+ <!-- Custom Android task to deal with the project target, and import the
+ proper rules.
+ This requires ant 1.6.0 or above. -->
+ <path id="android.antlibs">
+ <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
+ </path>
+
+ <taskdef name="setup"
+ classname="com.android.ant.SetupTask"
+ classpathref="android.antlibs" />
+
+<!-- extension targets. Uncomment the ones where you want to do custom work
+ in between standard targets -->
+<!--
+ <target name="-pre-build">
+ </target>
+ <target name="-pre-compile">
+ </target>
+
+ [This is typically used for code obfuscation.
+ Compiled code location: ${out.classes.absolute.dir}
+ If this is not done in place, override ${out.dex.input.absolute.dir}]
+ <target name="-post-compile">
+ </target>
+-->
+
+
+ <!-- Execute the Android Setup task that will setup some properties
+ specific to the target, and import the build rules files.
+
+ The rules file is imported from
+ <SDK>/platforms/<target_platform>/ant/ant_rules_r#.xml
+
+ To customize existing targets, there are two options:
+ - Customize only one target:
+ - copy/paste the target into this file, *before* the
+ <setup> task.
+ - customize it to your needs.
+ - Customize the whole script.
+ - copy/paste the content of the rules files (minus the top node)
+ into this file, *after* the <setup> task
+ - disable the import of the rules by changing the setup task
+ below to <setup import="false" />.
+ - customize to your needs.
+ -->
+ <setup />
+
+</project>
diff --git a/testapps/basicProjectWithJar/default.properties b/testapps/basicProjectWithJar/default.properties
new file mode 100644
index 0000000..38db660
--- /dev/null
+++ b/testapps/basicProjectWithJar/default.properties
@@ -0,0 +1,12 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "build.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-AOSP
+proguard.config=../proguard.config
diff --git a/testapps/basicProjectWithJar/libs/basicJar.jar b/testapps/basicProjectWithJar/libs/basicJar.jar
new file mode 100644
index 0000000..8169064
--- /dev/null
+++ b/testapps/basicProjectWithJar/libs/basicJar.jar
Binary files differ
diff --git a/testapps/basicProjectWithJar/res/drawable/icon.png b/testapps/basicProjectWithJar/res/drawable/icon.png
new file mode 100644
index 0000000..a07c69f
--- /dev/null
+++ b/testapps/basicProjectWithJar/res/drawable/icon.png
Binary files differ
diff --git a/testapps/basicProjectWithJar/res/layout/main.xml b/testapps/basicProjectWithJar/res/layout/main.xml
new file mode 100644
index 0000000..b79cddb
--- /dev/null
+++ b/testapps/basicProjectWithJar/res/layout/main.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ >
+<TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="Hello World, Main"
+ />
+</LinearLayout>
+
diff --git a/testapps/basicProjectWithJar/res/values/strings.xml b/testapps/basicProjectWithJar/res/values/strings.xml
new file mode 100644
index 0000000..549e4ea
--- /dev/null
+++ b/testapps/basicProjectWithJar/res/values/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">Main</string>
+</resources>
diff --git a/testapps/basicProjectWithJar/src/com/android/tests/basicprojectwithjar/Main.java b/testapps/basicProjectWithJar/src/com/android/tests/basicprojectwithjar/Main.java
new file mode 100644
index 0000000..fdcc019
--- /dev/null
+++ b/testapps/basicProjectWithJar/src/com/android/tests/basicprojectwithjar/Main.java
@@ -0,0 +1,20 @@
+package com.android.tests.basicprojectwithjar;
+
+import com.android.tests.basicjar.Foo;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+public class Main extends Activity
+{
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ Foo foo = new Foo();
+ int a = foo.getRandomFoo();
+ }
+}
diff --git a/testapps/basicProjectWithLib/AndroidManifest.xml b/testapps/basicProjectWithLib/AndroidManifest.xml
index fe394f2..052d387 100644
--- a/testapps/basicProjectWithLib/AndroidManifest.xml
+++ b/testapps/basicProjectWithLib/AndroidManifest.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.tests.basicProjectWithLib"
+ package="com.android.tests.basicprojectwithlib"
android:versionCode="1"
android:versionName="1.0">
<application android:label="@string/app_name" android:icon="@drawable/icon">
@@ -11,6 +11,13 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+ <activity android:name="com.android.tests.basiclibwithjar.Main"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
</application>
<uses-sdk android:minSdkVersion="AOSP" />
</manifest>
diff --git a/testapps/basicProjectWithLib/default.properties b/testapps/basicProjectWithLib/default.properties
index eb80ff8..60423bf 100644
--- a/testapps/basicProjectWithLib/default.properties
+++ b/testapps/basicProjectWithLib/default.properties
@@ -9,4 +9,6 @@
# Project target.
target=android-AOSP
-android.library.reference.1=../basicLib \ No newline at end of file
+proguard.config=../proguard.config
+android.library.reference.1=../basicLib
+android.library.reference.2=../basicLibWithJar \ No newline at end of file
diff --git a/testapps/proguard.config b/testapps/proguard.config
new file mode 100644
index 0000000..b9dab40
--- /dev/null
+++ b/testapps/proguard.config
@@ -0,0 +1,31 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+ native <methods>;
+}
+
+-keepclasseswithmembernames class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembernames class * {
+ public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+