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="-dex"> | |
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 <property name="out.dexed.absolute.dir" location="${out.dir}/dexedLibs" /> | |
26 <property name="out.manifest.abs.file" location="${out.dir}/AndroidManifest.xm
l" /> | |
27 | |
28 <!-- tools location --> | |
29 <property name="sdk.dir" location="${ANDROID_SDK_ROOT}"/> | |
30 <property name="target" value="android-${ANDROID_SDK_VERSION}"/> | |
31 <property name="android.tools.dir" location="${sdk.dir}/tools" /> | |
32 <property name="android.platform.tools.dir" location="${sdk.dir}/platform-tool
s" /> | |
33 | |
34 <property name="project.target.android.jar" location="${ANDROID_SDK_JAR}" /> | |
35 <path id="project.target.class.path"> | |
36 <pathelement location="${project.target.android.jar}" /> | |
37 </path> | |
38 | |
39 | |
40 <!-- jar file from where the tasks are loaded --> | |
41 <path id="android.antlibs"> | |
42 <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" /> | |
43 </path> | |
44 | |
45 <!-- Custom tasks --> | |
46 <taskdef resource="anttasks.properties" classpathref="android.antlibs" /> | |
47 | |
48 | |
49 <path id="javac.srcdirs.additional"> | |
50 <filelist files="${ADDITIONAL_SRC_DIRS}"/> | |
51 <filelist files="${GENERATED_SRC_DIRS}"/> | |
52 </path> | |
53 | |
54 <!-- Classpath for javac --> | |
55 <path id="javac.custom.classpath"> | |
56 <filelist files="${INPUT_JARS_PATHS}"/> | |
57 </path> | |
58 | |
59 <!-- | |
60 TODO(cjhopman): This is wrong for proguard builds. In that case, it should b
e just the | |
61 obfuscated jar. | |
62 --> | |
63 <path id="out.dex.jar.input.ref"> | |
64 <path refid="javac.custom.classpath"/> | |
65 </path> | |
66 | |
67 <!-- compilation options --> | |
68 <property name="java.encoding" value="UTF-8" /> | |
69 <property name="java.target" value="1.5" /> | |
70 <property name="java.source" value="1.5" /> | |
71 <property name="java.compilerargs" value="" /> | |
72 | |
73 <property name="source.dir" value="${SOURCE_DIR}" /> | |
74 <property name="source.absolute.dir" location="${source.dir}" /> | |
75 <property name="gen.absolute.dir" value="${out.dir}/gen"/> | |
76 | |
77 <property name="dx" location="${android.platform.tools.dir}/dx" /> | |
78 | |
79 <property name="need.javac.fork" value="false" /> | |
80 <condition property="project.is.testapp" value="true" else="false"> | |
81 <equals arg1="${IS_TEST_APK}" arg2="1" /> | |
82 </condition> | |
83 | |
84 <!-- | |
85 Override the -compile target. | |
86 This target requires 'javac.custom.classpath' to be set to reference | |
87 of classpath to be used for javac. Also accepts custom path for | |
88 sources: 'javac.custom.sourcepath'. | |
89 --> | |
90 <!-- Compiles this project's .java files into .class files. --> | |
91 <target name="-compile"> | |
92 | |
93 <mkdir dir="${out.classes.absolute.dir}" /> | |
94 <mkdir dir="${out.dexed.absolute.dir}" /> | |
95 <delete> | |
96 <fileset dir="${out.classes.absolute.dir}" includes="**/*.class"/> | |
97 </delete> | |
98 | |
99 <javac | |
100 bootclasspathref="project.target.class.path" | |
101 classpathref="javac.custom.classpath" | |
102 debug="true" | |
103 destdir="${out.classes.absolute.dir}" | |
104 encoding="${java.encoding}" | |
105 extdirs="" | |
106 fork="${need.javac.fork}" | |
107 includeantruntime="false" | |
108 source="${java.source}" | |
109 target="${java.target}" | |
110 verbose="${verbose}"> | |
111 <src path="${source.absolute.dir}"/> | |
112 <src path="${gen.absolute.dir}"/> | |
113 <src> | |
114 <path refid="javac.srcdirs.additional"/> | |
115 </src> | |
116 <compilerarg value="-Xlint:unchecked"/> | |
117 <compilerarg line="${java.compilerargs}"/> | |
118 </javac> | |
119 | |
120 <if condition="${project.is.testapp}"> | |
121 <then> | |
122 <!-- get the project manifest package --> | |
123 <xpath input="${out.manifest.abs.file}" | |
124 expression="/manifest/@package" output="project.app.package" /> | |
125 <property name="create.test.jar.file" | |
126 location="${CREATE_TEST_JAR_PATH}" /> | |
127 <script language="javascript" src="${create.test.jar.file}"/> | |
128 </then> | |
129 </if> | |
130 | |
131 <!-- Package all the compiled .class files into a .jar. --> | |
132 <jar | |
133 jarfile="${JAR_PATH}" | |
134 basedir="${out.classes.absolute.dir}" | |
135 /> | |
136 </target> | |
137 | |
138 <property name="proguard.enabled" value="${PROGUARD_ENABLED}" /> | |
139 <property name="proguard.config" value="${PROGUARD_FLAGS}" /> | |
140 | |
141 <!-- Obfuscate target | |
142 This is only active in release builds when proguard.config is defined | |
143 in default.properties. | |
144 | |
145 --> | |
146 <!-- | |
147 Override obfuscate target to pass javac.custom.classpath to Proguard. SDK to
ols do not provide | |
148 any way to pass custom class paths to Proguard. | |
149 --> | |
150 <target name="-obfuscate" depends="-compile"> | |
151 <if condition="${proguard.enabled}"> | |
152 <then> | |
153 <path id="out.dex.jar.input.ref" /> | |
154 <property name="obfuscate.absolute.dir" location="${out.absolute.dir}/pr
oguard"/> | |
155 <property name="preobfuscate.jar.file" value="${obfuscate.absolute.dir}/
original.jar"/> | |
156 <property name="obfuscated.jar.file" value="${obfuscate.absolute.dir}/ob
fuscated.jar"/> | |
157 <!-- input for dex will be proguard's output --> | |
158 <property name="out.dex.input.absolute.dir" value="${obfuscated.jar.file
}"/> | |
159 | |
160 <!-- Add Proguard Tasks --> | |
161 <property name="proguard.jar" location="${android.tools.dir}/proguard/li
b/proguard.jar"/> | |
162 <taskdef name="proguard" classname="proguard.ant.ProGuardTask" classpath
="${proguard.jar}"/> | |
163 | |
164 <!-- Set the android classpath Path object into a single property. It'll
be | |
165 all the jar files separated by a platform path-separator. | |
166 Each path must be quoted if it contains spaces. | |
167 --> | |
168 <pathconvert property="project.target.classpath.value" refid="project.ta
rget.class.path"> | |
169 <firstmatchmapper> | |
170 <regexpmapper from='^([^ ]*)( .*)$$' to='"\1\2"'/> | |
171 <identitymapper/> | |
172 </firstmatchmapper> | |
173 </pathconvert> | |
174 | |
175 <!-- Build a path object with all the jar files that must be obfuscated. | |
176 This include the project compiled source code and any 3rd party jar | |
177 files. --> | |
178 <path id="project.all.classes.path"> | |
179 <pathelement location="${preobfuscate.jar.file}"/> | |
180 <!-- Pass javac.custom.classpath for apks. --> | |
181 <path refid="javac.custom.classpath"/> | |
182 </path> | |
183 <!-- Set the project jar files Path object into a single property. It'll
be | |
184 all the jar files separated by a platform path-separator. | |
185 Each path must be quoted if it contains spaces. | |
186 --> | |
187 <pathconvert property="project.all.classes.value" refid="project.all.cla
sses.path"> | |
188 <firstmatchmapper> | |
189 <regexpmapper from='^([^ ]*)( .*)$$' to='"\1\2"'/> | |
190 <identitymapper/> | |
191 </firstmatchmapper> | |
192 </pathconvert> | |
193 | |
194 <!-- Turn the path property ${proguard.config} from an A:B:C property | |
195 into a series of includes: -include A -include B -include C | |
196 suitable for processing by the ProGuard task. Note - this does | |
197 not include the leading '-include "' or the closing '"'; those | |
198 are added under the <proguard> call below. | |
199 --> | |
200 <path id="proguard.configpath"> | |
201 <pathelement path="${proguard.config}"/> | |
202 </path> | |
203 <pathconvert pathsep='" -include "' property="proguard.configcmd" | |
204 refid="proguard.configpath"/> | |
205 | |
206 <mkdir dir="${obfuscate.absolute.dir}"/> | |
207 <delete file="${preobfuscate.jar.file}"/> | |
208 <delete file="${obfuscated.jar.file}"/> | |
209 <jar basedir="${out.classes.absolute.dir}" | |
210 destfile="${preobfuscate.jar.file}"/> | |
211 <proguard> | |
212 -include "${proguard.configcmd}" | |
213 -include "${out.absolute.dir}/proguard.txt" | |
214 -injars ${project.all.classes.value} | |
215 -outjars "${obfuscated.jar.file}" | |
216 -libraryjars ${project.target.classpath.value} | |
217 -dump "${obfuscate.absolute.dir}/dump.txt" | |
218 -printseeds "${obfuscate.absolute.dir}/seeds.txt" | |
219 -printusage "${obfuscate.absolute.dir}/usage.txt" | |
220 -printmapping "${obfuscate.absolute.dir}/mapping.txt" | |
221 </proguard> | |
222 </then> | |
223 </if> | |
224 </target> | |
225 | |
226 <property name="dex.file.name" value="classes.dex" /> | |
227 <property name="intermediate.dex.file" location="${out.absolute.dir}/${dex.fil
e.name}" /> | |
228 | |
229 <!-- Converts this project's .class files into .dex files --> | |
230 <target name="-dex" depends="-obfuscate"> | |
231 <!-- sets the primary input for dex. If a pre-dex task sets it to | |
232 something else this has no effect --> | |
233 <property name="out.dex.input.absolute.dir" value="${out.classes.absolute.
dir}" /> | |
234 <property name="dex.force.jumbo" value="false" /> | |
235 | |
236 <dex executable="${dx}" | |
237 output="${intermediate.dex.file}" | |
238 dexedlibs="${out.dexed.absolute.dir}" | |
239 nolocals="false" | |
240 forceJumbo="${dex.force.jumbo}" | |
241 verbose="${verbose}"> | |
242 <path path="${out.dex.input.absolute.dir}"/> | |
243 <path refid="out.dex.jar.input.ref" /> | |
244 </dex> | |
245 <touch file="${STAMP}" /> | |
246 </target> | |
247 </project> | |
OLD | NEW |