OLD | NEW |
| (Empty) |
1 <?xml version="1.0" encoding="UTF-8"?> | |
2 <!-- | |
3 Copyright (C) 2005-2008 The Android Open Source Project | |
4 | |
5 Licensed under the Apache License, Version 2.0 (the "License"); | |
6 you may not use this file except in compliance with the License. | |
7 You may obtain a copy of the License at | |
8 | |
9 http://www.apache.org/licenses/LICENSE-2.0 | |
10 | |
11 Unless required by applicable law or agreed to in writing, software | |
12 distributed under the License is distributed on an "AS IS" BASIS, | |
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 See the License for the specific language governing permissions and | |
15 limitations under the License. | |
16 --> | |
17 | |
18 <project default="-obfuscate"> | |
19 <property name="verbose" value="false" /> | |
20 <property name="out.dir" location="${OUT_DIR}" /> | |
21 <!-- Output directories --> | |
22 <property name="out.dir" value="bin" /> | |
23 <property name="out.absolute.dir" location="${out.dir}" /> | |
24 <property name="out.classes.absolute.dir" location="${out.dir}/classes" /> | |
25 | |
26 <!-- tools location --> | |
27 <property name="sdk.dir" location="${ANDROID_SDK_ROOT}"/> | |
28 <property name="android.tools.dir" location="${sdk.dir}/tools" /> | |
29 | |
30 <property name="project.target.android.jar" location="${ANDROID_SDK_JAR}" /> | |
31 <path id="project.target.class.path"> | |
32 <pathelement location="${project.target.android.jar}" /> | |
33 </path> | |
34 | |
35 | |
36 <!-- jar file from where the tasks are loaded --> | |
37 <path id="android.antlibs"> | |
38 <pathelement path="${sdk.dir}/tools/lib/ant-tasks.jar" /> | |
39 </path> | |
40 | |
41 <!-- Custom tasks --> | |
42 <taskdef resource="anttasks.properties" classpathref="android.antlibs" /> | |
43 | |
44 <!-- Classpath for javac --> | |
45 <path id="javac.custom.classpath"> | |
46 <filelist files="${INPUT_JARS_PATHS}"/> | |
47 </path> | |
48 | |
49 <condition property="project.is.testapp" value="true" else="false"> | |
50 <equals arg1="${IS_TEST_APK}" arg2="1" /> | |
51 </condition> | |
52 | |
53 <property name="proguard.enabled" value="${PROGUARD_ENABLED}" /> | |
54 <property name="proguard.config" value="${PROGUARD_FLAGS}" /> | |
55 | |
56 <property name="manifest.file" value="${ANDROID_MANIFEST}" /> | |
57 <property name="manifest.abs.file" location="${manifest.file}" /> | |
58 | |
59 <!-- Obfuscate target | |
60 This is only active in release builds when proguard.config is defined | |
61 in default.properties. | |
62 | |
63 --> | |
64 <!-- | |
65 Override obfuscate target to pass javac.custom.classpath to Proguard. SDK to
ols do not provide | |
66 any way to pass custom class paths to Proguard. | |
67 --> | |
68 <target name="-obfuscate"> | |
69 <if condition="${project.is.testapp}"> | |
70 <then> | |
71 <!-- get the project manifest package --> | |
72 <xpath input="${manifest.abs.file}" | |
73 expression="/manifest/@package" output="project.app.package" /> | |
74 <loadresource property="project.app.packagepath"> | |
75 <propertyresource name="project.app.package"/> | |
76 <filterchain> | |
77 <replacestring from="." to="/"/> | |
78 </filterchain> | |
79 </loadresource> | |
80 <property name="create.test.jar.exclusions" value="${project.app.package
path}/R.class ${project.app.packagepath}/R$*.class ${project.app.packagepath}/Ma
nifest.class ${project.app.packagepath}/Manifest$*.class ${project.app.packagepa
th}/BuildConfig.class"/> | |
81 <jar destfile="${TEST_JAR_PATH}" | |
82 excludes="${create.test.jar.exclusions}" | |
83 duplicate="preserve" | |
84 > | |
85 <restrict> | |
86 <name name="**/*.class"/> | |
87 <archives> | |
88 <zips> | |
89 <path refid="javac.custom.classpath"/> | |
90 </zips> | |
91 </archives> | |
92 </restrict> | |
93 <fileset dir="${out.dir}/classes"/> | |
94 </jar> | |
95 </then> | |
96 </if> | |
97 <if> | |
98 <condition> | |
99 <and> | |
100 <istrue value="${proguard.enabled}"/> | |
101 <equals arg1="${CONFIGURATION_NAME}" arg2="Release"/> | |
102 </and> | |
103 </condition> | |
104 <then> | |
105 <property name="obfuscate.absolute.dir" location="${out.absolute.dir}/pr
oguard"/> | |
106 <property name="preobfuscate.jar.file" value="${obfuscate.absolute.dir}/
original.jar"/> | |
107 <property name="obfuscated.jar.file" value="${OBFUSCATED_JAR_PATH}"/> | |
108 <property name="obfuscated.jar.abs.file" location="${obfuscated.jar.file
}"/> | |
109 | |
110 <!-- Add Proguard Tasks --> | |
111 <property name="proguard.jar" location="${android.tools.dir}/proguard/li
b/proguard.jar"/> | |
112 <taskdef name="proguard" classname="proguard.ant.ProGuardTask" classpath
="${proguard.jar}"/> | |
113 | |
114 <!-- Set the android classpath Path object into a single property. It'll
be | |
115 all the jar files separated by a platform path-separator. | |
116 Each path must be quoted if it contains spaces. | |
117 --> | |
118 <pathconvert property="project.target.classpath.value" refid="project.ta
rget.class.path"> | |
119 <firstmatchmapper> | |
120 <regexpmapper from='^([^ ]*)( .*)$$' to='"\1\2"'/> | |
121 <identitymapper/> | |
122 </firstmatchmapper> | |
123 </pathconvert> | |
124 | |
125 <!-- Build a path object with all the jar files that must be obfuscated. | |
126 This include the project compiled source code and any 3rd party jar | |
127 files. --> | |
128 <path id="project.all.classes.path"> | |
129 <pathelement location="${preobfuscate.jar.file}"/> | |
130 <!-- Pass javac.custom.classpath for apks. --> | |
131 <path refid="javac.custom.classpath"/> | |
132 </path> | |
133 <!-- Set the project jar files Path object into a single property. It'll
be | |
134 all the jar files separated by a platform path-separator. | |
135 Each path must be quoted if it contains spaces. | |
136 --> | |
137 <pathconvert property="project.all.classes.value" refid="project.all.cla
sses.path"> | |
138 <firstmatchmapper> | |
139 <regexpmapper from='^([^ ]*)( .*)$$' to='"\1\2"'/> | |
140 <identitymapper/> | |
141 </firstmatchmapper> | |
142 </pathconvert> | |
143 | |
144 <!-- Turn the path property ${proguard.config} from an A:B:C property | |
145 into a series of includes: -include A -include B -include C | |
146 suitable for processing by the ProGuard task. Note - this does | |
147 not include the leading '-include "' or the closing '"'; those | |
148 are added under the <proguard> call below. | |
149 --> | |
150 <path id="proguard.configpath"> | |
151 <filelist files="${proguard.config}"/> | |
152 </path> | |
153 <pathconvert pathsep='" -include "' property="proguard.configcmd" | |
154 refid="proguard.configpath"/> | |
155 | |
156 <mkdir dir="${obfuscate.absolute.dir}"/> | |
157 <delete file="${preobfuscate.jar.file}"/> | |
158 <delete file="${obfuscated.jar.abs.file}"/> | |
159 <jar basedir="${out.classes.absolute.dir}" | |
160 destfile="${preobfuscate.jar.file}"/> | |
161 <proguard> | |
162 -include "${proguard.configcmd}" | |
163 -injars ${project.all.classes.value} | |
164 -outjars "${obfuscated.jar.abs.file}" | |
165 -libraryjars ${project.target.classpath.value} | |
166 -dump "${obfuscate.absolute.dir}/dump.txt" | |
167 -printseeds "${obfuscate.absolute.dir}/seeds.txt" | |
168 -printusage "${obfuscate.absolute.dir}/usage.txt" | |
169 -printmapping "${obfuscate.absolute.dir}/mapping.txt" | |
170 </proguard> | |
171 </then> | |
172 </if> | |
173 <touch file="${STAMP}" /> | |
174 </target> | |
175 </project> | |
OLD | NEW |