Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1185)

Unified Diff: build/android/ant/sdk-targets.xml

Issue 11013040: Add override for obfuscate target to support Proguard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: changes Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/ant/sdk-targets.xml
diff --git a/build/android/ant/sdk-targets.xml b/build/android/ant/sdk-targets.xml
index 7909daa32a78d7e2f5dbe62c7632f293688f81be..1ba10dee007a44d8929bdc0611e87d220f283721 100644
--- a/build/android/ant/sdk-targets.xml
+++ b/build/android/ant/sdk-targets.xml
@@ -168,4 +168,84 @@
</do-only-if-not-library>
<record-build-info />
</target>
+
+ <!--
+ Override obfuscate target to pass javac.custom.classpath to Proguard. SDK tools do not provide
+ any way to pass custom class paths to Proguard.
+ -->
+ <target name="-obfuscate">
+ <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"/>
+ <!-- input for dex will be proguard's output -->
+ <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.
+ Each path must be quoted if it contains spaces.
+ -->
+ <pathconvert property="project.target.classpath.value" refid="project.target.class.path">
+ <firstmatchmapper>
+ <regexpmapper from='^([^ ]*)( .*)$$' to='"\1\2"'/>
+ <identitymapper/>
+ </firstmatchmapper>
+ </pathconvert>
+
+ <!-- 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.all.classes.path">
+ <pathelement location="${preobfuscate.jar.file}"/>
+ <path refid="project.all.jars.path"/>
+ <!-- Pass javac.custom.classpath for apks. -->
+ <path refid="javac.custom.classpath"/>
shashi 2012/10/08 18:50:37 Relevant change here.
+ </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.
+ Each path must be quoted if it contains spaces.
+ -->
+ <pathconvert property="project.all.classes.value" refid="project.all.classes.path">
+ <firstmatchmapper>
+ <regexpmapper from='^([^ ]*)( .*)$$' to='"\1\2"'/>
+ <identitymapper/>
+ </firstmatchmapper>
+ </pathconvert>
+
+ <!-- Turn the path property ${proguard.config} from an A:B:C property
+ into a series of includes: -include A -include B -include C
+ suitable for processing by the ProGuard task. Note - this does
+ not include the leading '-include "' or the closing '"'; those
+ are added under the <proguard> call below.
+ -->
+ <path id="proguard.configpath">
+ <pathelement path="${proguard.config}"/>
+ </path>
+ <pathconvert pathsep='" -include "' property="proguard.configcmd"
+ refid="proguard.configpath"/>
+
+ <mkdir dir="${obfuscate.absolute.dir}"/>
+ <delete file="${preobfuscate.jar.file}"/>
+ <delete file="${obfuscated.jar.file}"/>
+ <jar basedir="${out.classes.absolute.dir}"
+ destfile="${preobfuscate.jar.file}"/>
+ <proguard>
+ -include "${proguard.configcmd}"
+ -include "${out.absolute.dir}/proguard.txt"
+ -injars ${project.all.classes.value}
+ -outjars "${obfuscated.jar.file}"
+ -libraryjars ${project.target.classpath.value}
+ -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>
+ </if>
+ </target>
</project>
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698