OLD | NEW |
1 <?xml version="1.0" encoding="UTF-8"?> | 1 <?xml version="1.0" encoding="UTF-8"?> |
2 <!-- | 2 <!-- |
3 Copyright (C) 2005-2008 The Android Open Source Project | 3 Copyright (C) 2005-2008 The Android Open Source Project |
4 | 4 |
5 Licensed under the Apache License, Version 2.0 (the "License"); | 5 Licensed under the Apache License, Version 2.0 (the "License"); |
6 you may not use this file except in compliance with 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 | 7 You may obtain a copy of the License at |
8 | 8 |
9 http://www.apache.org/licenses/LICENSE-2.0 | 9 http://www.apache.org/licenses/LICENSE-2.0 |
10 | 10 |
11 Unless required by applicable law or agreed to in writing, software | 11 Unless required by applicable law or agreed to in writing, software |
12 distributed under the License is distributed on an "AS IS" BASIS, | 12 distributed under the License is distributed on an "AS IS" BASIS, |
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 See the License for the specific language governing permissions and | 14 See the License for the specific language governing permissions and |
15 limitations under the License. | 15 limitations under the License. |
16 --> | 16 --> |
17 | 17 |
18 <project default="-dex"> | 18 <project default="-obfuscate"> |
19 <property name="verbose" value="false" /> | 19 <property name="verbose" value="false" /> |
20 <property name="out.dir" location="${OUT_DIR}" /> | 20 <property name="out.dir" location="${OUT_DIR}" /> |
21 <!-- Output directories --> | 21 <!-- Output directories --> |
22 <property name="out.dir" value="bin" /> | 22 <property name="out.dir" value="bin" /> |
23 <property name="out.absolute.dir" location="${out.dir}" /> | 23 <property name="out.absolute.dir" location="${out.dir}" /> |
24 <property name="out.classes.absolute.dir" location="${out.dir}/classes" /> | 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" /> | 25 <property name="out.manifest.abs.file" location="${out.dir}/AndroidManifest.xm
l" /> |
27 | 26 |
28 <!-- tools location --> | 27 <!-- tools location --> |
29 <property name="sdk.dir" location="${ANDROID_SDK_ROOT}"/> | 28 <property name="sdk.dir" location="${ANDROID_SDK_ROOT}"/> |
30 <property name="target" value="android-${ANDROID_SDK_VERSION}"/> | 29 <property name="target" value="android-${ANDROID_SDK_VERSION}"/> |
31 <property name="android.tools.dir" location="${sdk.dir}/tools" /> | 30 <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 | 31 |
39 | 32 |
40 <!-- jar file from where the tasks are loaded --> | 33 <!-- jar file from where the tasks are loaded --> |
41 <path id="android.antlibs"> | 34 <path id="android.antlibs"> |
42 <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" /> | 35 <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" /> |
43 </path> | 36 </path> |
44 | 37 |
45 <!-- Custom tasks --> | 38 <!-- Custom tasks --> |
46 <taskdef resource="anttasks.properties" classpathref="android.antlibs" /> | 39 <taskdef resource="anttasks.properties" classpathref="android.antlibs" /> |
47 | 40 |
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 --> | 41 <!-- Classpath for javac --> |
55 <path id="javac.custom.classpath"> | 42 <path id="javac.custom.classpath"> |
56 <filelist files="${INPUT_JARS_PATHS}"/> | 43 <filelist files="${INPUT_JARS_PATHS}"/> |
57 </path> | 44 </path> |
58 | 45 |
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"> | 46 <condition property="project.is.testapp" value="true" else="false"> |
81 <equals arg1="${IS_TEST_APK}" arg2="1" /> | 47 <equals arg1="${IS_TEST_APK}" arg2="1" /> |
82 </condition> | 48 </condition> |
83 | 49 |
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}" /> | 50 <property name="proguard.enabled" value="${PROGUARD_ENABLED}" /> |
139 <property name="proguard.config" value="${PROGUARD_FLAGS}" /> | 51 <property name="proguard.config" value="${PROGUARD_FLAGS}" /> |
140 | 52 |
141 <!-- Obfuscate target | 53 <!-- Obfuscate target |
142 This is only active in release builds when proguard.config is defined | 54 This is only active in release builds when proguard.config is defined |
143 in default.properties. | 55 in default.properties. |
144 | 56 |
145 --> | 57 --> |
146 <!-- | 58 <!-- |
147 Override obfuscate target to pass javac.custom.classpath to Proguard. SDK to
ols do not provide | 59 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. | 60 any way to pass custom class paths to Proguard. |
149 --> | 61 --> |
150 <target name="-obfuscate" depends="-compile"> | 62 <target name="-obfuscate"> |
| 63 <if condition="${project.is.testapp}"> |
| 64 <then> |
| 65 <!-- get the project manifest package --> |
| 66 <xpath input="${out.manifest.abs.file}" |
| 67 expression="/manifest/@package" output="project.app.package" /> |
| 68 <property name="create.test.jar.file" |
| 69 location="${CREATE_TEST_JAR_PATH}" /> |
| 70 <script language="javascript" src="${create.test.jar.file}"/> |
| 71 </then> |
| 72 </if> |
151 <if condition="${proguard.enabled}"> | 73 <if condition="${proguard.enabled}"> |
152 <then> | 74 <then> |
153 <path id="out.dex.jar.input.ref" /> | |
154 <property name="obfuscate.absolute.dir" location="${out.absolute.dir}/pr
oguard"/> | 75 <property name="obfuscate.absolute.dir" location="${out.absolute.dir}/pr
oguard"/> |
155 <property name="preobfuscate.jar.file" value="${obfuscate.absolute.dir}/
original.jar"/> | 76 <property name="preobfuscate.jar.file" value="${obfuscate.absolute.dir}/
original.jar"/> |
156 <property name="obfuscated.jar.file" value="${obfuscate.absolute.dir}/ob
fuscated.jar"/> | 77 <property name="obfuscated.jar.file" value="${OBFUSCATED_JAR_PATH}"/> |
157 <!-- input for dex will be proguard's output --> | 78 <property name="obfuscated.jar.abs.file" location="${obfuscated.jar.file
}"/> |
158 <property name="out.dex.input.absolute.dir" value="${obfuscated.jar.file
}"/> | |
159 | 79 |
160 <!-- Add Proguard Tasks --> | 80 <!-- Add Proguard Tasks --> |
161 <property name="proguard.jar" location="${android.tools.dir}/proguard/li
b/proguard.jar"/> | 81 <property name="proguard.jar" location="${android.tools.dir}/proguard/li
b/proguard.jar"/> |
162 <taskdef name="proguard" classname="proguard.ant.ProGuardTask" classpath
="${proguard.jar}"/> | 82 <taskdef name="proguard" classname="proguard.ant.ProGuardTask" classpath
="${proguard.jar}"/> |
163 | 83 |
164 <!-- Set the android classpath Path object into a single property. It'll
be | 84 <!-- Set the android classpath Path object into a single property. It'll
be |
165 all the jar files separated by a platform path-separator. | 85 all the jar files separated by a platform path-separator. |
166 Each path must be quoted if it contains spaces. | 86 Each path must be quoted if it contains spaces. |
167 --> | 87 --> |
168 <pathconvert property="project.target.classpath.value" refid="project.ta
rget.class.path"> | 88 <pathconvert property="project.target.classpath.value" refid="project.ta
rget.class.path"> |
(...skipping 29 matching lines...) Expand all Loading... |
198 are added under the <proguard> call below. | 118 are added under the <proguard> call below. |
199 --> | 119 --> |
200 <path id="proguard.configpath"> | 120 <path id="proguard.configpath"> |
201 <pathelement path="${proguard.config}"/> | 121 <pathelement path="${proguard.config}"/> |
202 </path> | 122 </path> |
203 <pathconvert pathsep='" -include "' property="proguard.configcmd" | 123 <pathconvert pathsep='" -include "' property="proguard.configcmd" |
204 refid="proguard.configpath"/> | 124 refid="proguard.configpath"/> |
205 | 125 |
206 <mkdir dir="${obfuscate.absolute.dir}"/> | 126 <mkdir dir="${obfuscate.absolute.dir}"/> |
207 <delete file="${preobfuscate.jar.file}"/> | 127 <delete file="${preobfuscate.jar.file}"/> |
208 <delete file="${obfuscated.jar.file}"/> | 128 <delete file="${obfuscated.jar.abs.file}"/> |
209 <jar basedir="${out.classes.absolute.dir}" | 129 <jar basedir="${out.classes.absolute.dir}" |
210 destfile="${preobfuscate.jar.file}"/> | 130 destfile="${preobfuscate.jar.file}"/> |
211 <proguard> | 131 <proguard> |
212 -include "${proguard.configcmd}" | 132 -include "${proguard.configcmd}" |
213 -include "${out.absolute.dir}/proguard.txt" | 133 -include "${out.absolute.dir}/proguard.txt" |
214 -injars ${project.all.classes.value} | 134 -injars ${project.all.classes.value} |
215 -outjars "${obfuscated.jar.file}" | 135 -outjars "${obfuscated.jar.abs.file}" |
216 -libraryjars ${project.target.classpath.value} | 136 -libraryjars ${project.target.classpath.value} |
217 -dump "${obfuscate.absolute.dir}/dump.txt" | 137 -dump "${obfuscate.absolute.dir}/dump.txt" |
218 -printseeds "${obfuscate.absolute.dir}/seeds.txt" | 138 -printseeds "${obfuscate.absolute.dir}/seeds.txt" |
219 -printusage "${obfuscate.absolute.dir}/usage.txt" | 139 -printusage "${obfuscate.absolute.dir}/usage.txt" |
220 -printmapping "${obfuscate.absolute.dir}/mapping.txt" | 140 -printmapping "${obfuscate.absolute.dir}/mapping.txt" |
221 </proguard> | 141 </proguard> |
222 </then> | 142 </then> |
223 </if> | 143 </if> |
224 </target> | 144 <touch file="${STAMP}" /> |
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> | 145 </target> |
247 </project> | 146 </project> |
OLD | NEW |