| 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/ant-tasks.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 <loadresource property="project.app.packagepath"> | |
| 126 <propertyresource name="project.app.package"/> | |
| 127 <filterchain> | |
| 128 <replacestring from="." to="/"/> | |
| 129 </filterchain> | |
| 130 </loadresource> | |
| 131 <property name="create.test.jar.exclusions" | |
| 132 value="${project.app.packagepath}/R.class ${project.app.packag
epath}/R$*.class ${project.app.packagepath}/Manifest.class ${project.app.package
path}/Manifest$*.class ${project.app.packagepath}/BuildConfig.class"/> | |
| 133 <jar destfile="${TEST_JAR_PATH}" | |
| 134 excludes="${create.test.jar.exclusions}" | |
| 135 duplicate="preserve" | |
| 136 > | |
| 137 <restrict> | |
| 138 <name name="**/*.class"/> | |
| 139 <archives> | |
| 140 <zips> | |
| 141 <path refid="javac.custom.classpath"/> | |
| 142 </zips> | |
| 143 </archives> | |
| 144 </restrict> | |
| 145 <fileset dir="${out.dir}/classes"/> | |
| 146 </jar> | |
| 147 </then> | |
| 148 </if> | |
| 149 | |
| 150 <!-- Package all the compiled .class files into a .jar. --> | |
| 151 <jar | |
| 152 jarfile="${JAR_PATH}" | |
| 153 basedir="${out.classes.absolute.dir}" | |
| 154 /> | |
| 155 </target> | |
| 156 | |
| 157 <property name="proguard.enabled" value="${PROGUARD_ENABLED}" /> | |
| 158 <property name="proguard.config" value="${PROGUARD_FLAGS}" /> | |
| 159 | |
| 160 <!-- Obfuscate target | |
| 161 This is only active in release builds when proguard.config is defined | |
| 162 in default.properties. | |
| 163 | |
| 164 --> | |
| 165 <!-- | |
| 166 Override obfuscate target to pass javac.custom.classpath to Proguard. SDK to
ols do not provide | |
| 167 any way to pass custom class paths to Proguard. | |
| 168 --> | |
| 169 <target name="-obfuscate" depends="-compile"> | |
| 170 <if condition="${proguard.enabled}"> | |
| 171 <then> | |
| 172 <path id="out.dex.jar.input.ref" /> | |
| 173 <property name="obfuscate.absolute.dir" location="${out.absolute.dir}/pr
oguard"/> | |
| 174 <property name="preobfuscate.jar.file" value="${obfuscate.absolute.dir}/
original.jar"/> | |
| 175 <property name="obfuscated.jar.file" value="${obfuscate.absolute.dir}/ob
fuscated.jar"/> | |
| 176 <!-- input for dex will be proguard's output --> | |
| 177 <property name="out.dex.input.absolute.dir" value="${obfuscated.jar.file
}"/> | |
| 178 | |
| 179 <!-- Add Proguard Tasks --> | |
| 180 <property name="proguard.jar" location="${android.tools.dir}/proguard/li
b/proguard.jar"/> | |
| 181 <taskdef name="proguard" classname="proguard.ant.ProGuardTask" classpath
="${proguard.jar}"/> | |
| 182 | |
| 183 <!-- Set the android classpath 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.target.classpath.value" refid="project.ta
rget.class.path"> | |
| 188 <firstmatchmapper> | |
| 189 <regexpmapper from='^([^ ]*)( .*)$$' to='"\1\2"'/> | |
| 190 <identitymapper/> | |
| 191 </firstmatchmapper> | |
| 192 </pathconvert> | |
| 193 | |
| 194 <!-- Build a path object with all the jar files that must be obfuscated. | |
| 195 This include the project compiled source code and any 3rd party jar | |
| 196 files. --> | |
| 197 <path id="project.all.classes.path"> | |
| 198 <pathelement location="${preobfuscate.jar.file}"/> | |
| 199 <!-- Pass javac.custom.classpath for apks. --> | |
| 200 <path refid="javac.custom.classpath"/> | |
| 201 </path> | |
| 202 <!-- Set the project jar files Path object into a single property. It'll
be | |
| 203 all the jar files separated by a platform path-separator. | |
| 204 Each path must be quoted if it contains spaces. | |
| 205 --> | |
| 206 <pathconvert property="project.all.classes.value" refid="project.all.cla
sses.path"> | |
| 207 <firstmatchmapper> | |
| 208 <regexpmapper from='^([^ ]*)( .*)$$' to='"\1\2"'/> | |
| 209 <identitymapper/> | |
| 210 </firstmatchmapper> | |
| 211 </pathconvert> | |
| 212 | |
| 213 <!-- Turn the path property ${proguard.config} from an A:B:C property | |
| 214 into a series of includes: -include A -include B -include C | |
| 215 suitable for processing by the ProGuard task. Note - this does | |
| 216 not include the leading '-include "' or the closing '"'; those | |
| 217 are added under the <proguard> call below. | |
| 218 --> | |
| 219 <path id="proguard.configpath"> | |
| 220 <pathelement path="${proguard.config}"/> | |
| 221 </path> | |
| 222 <pathconvert pathsep='" -include "' property="proguard.configcmd" | |
| 223 refid="proguard.configpath"/> | |
| 224 | |
| 225 <mkdir dir="${obfuscate.absolute.dir}"/> | |
| 226 <delete file="${preobfuscate.jar.file}"/> | |
| 227 <delete file="${obfuscated.jar.file}"/> | |
| 228 <jar basedir="${out.classes.absolute.dir}" | |
| 229 destfile="${preobfuscate.jar.file}"/> | |
| 230 <proguard> | |
| 231 -include "${proguard.configcmd}" | |
| 232 -include "${out.absolute.dir}/proguard.txt" | |
| 233 -injars ${project.all.classes.value} | |
| 234 -outjars "${obfuscated.jar.file}" | |
| 235 -libraryjars ${project.target.classpath.value} | |
| 236 -dump "${obfuscate.absolute.dir}/dump.txt" | |
| 237 -printseeds "${obfuscate.absolute.dir}/seeds.txt" | |
| 238 -printusage "${obfuscate.absolute.dir}/usage.txt" | |
| 239 -printmapping "${obfuscate.absolute.dir}/mapping.txt" | |
| 240 </proguard> | |
| 241 </then> | |
| 242 </if> | |
| 243 </target> | |
| 244 | |
| 245 <property name="dex.file.name" value="classes.dex" /> | |
| 246 <property name="intermediate.dex.file" location="${out.absolute.dir}/${dex.fil
e.name}" /> | |
| 247 | |
| 248 <!-- Converts this project's .class files into .dex files --> | |
| 249 <target name="-dex" depends="-obfuscate"> | |
| 250 <!-- sets the primary input for dex. If a pre-dex task sets it to | |
| 251 something else this has no effect --> | |
| 252 <property name="out.dex.input.absolute.dir" value="${out.classes.absolute.
dir}" /> | |
| 253 <property name="dex.force.jumbo" value="false" /> | |
| 254 | |
| 255 <dex executable="${dx}" | |
| 256 output="${intermediate.dex.file}" | |
| 257 dexedlibs="${out.dexed.absolute.dir}" | |
| 258 nolocals="false" | |
| 259 forceJumbo="${dex.force.jumbo}" | |
| 260 verbose="${verbose}"> | |
| 261 <path path="${out.dex.input.absolute.dir}"/> | |
| 262 <path refid="out.dex.jar.input.ref" /> | |
| 263 </dex> | |
| 264 <touch file="${STAMP}" /> | |
| 265 </target> | |
| 266 </project> | |
| OLD | NEW |