1 <?xml version="1.0" encoding="UTF-8"?>
3 Copyright (C) 2005-2008 The Android Open Source Project
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
9 http://www.apache.org/licenses/LICENSE-2.0
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.
18 <project default="-package-resources">
19 <property name="out.dir" location="${OUT_DIR}" />
20 <property name="out.absolute.dir" location="${out.dir}" />
21 <property name="out.res.absolute.dir" location="${out.dir}/res" />
22 <property name="out.manifest.abs.file" location="${out.dir}/AndroidManifest.xml" />
24 <!-- tools location -->
25 <property name="sdk.dir" location="${ANDROID_SDK_ROOT}"/>
26 <property name="project.target.android.jar" location="${ANDROID_SDK_JAR}" />
27 <property name="android.sdk.tools.dir" location="${ANDROID_SDK_TOOLS}" />
29 <!-- jar file from where the tasks are loaded -->
30 <path id="android.antlibs">
31 <pathelement path="${sdk.dir}/tools/lib/ant-tasks.jar" />
35 <taskdef resource="anttasks.properties" classpathref="android.antlibs" />
37 <condition property="build.target" value="release" else="debug">
38 <equals arg1="${CONFIGURATION_NAME}" arg2="Release" />
40 <condition property="build.is.packaging.debug" value="true" else="false">
41 <equals arg1="${build.target}" arg2="debug" />
44 <property name="resource.dir" value="${RESOURCE_DIR}"/>
45 <property name="resource.absolute.dir" location="${resource.dir}"/>
47 <property name="asset.dir" value="${ASSET_DIR}" />
48 <property name="asset.absolute.dir" location="${asset.dir}" />
50 <property name="aapt" location="${android.sdk.tools.dir}/aapt" />
52 <property name="version.code" value="${APP_MANIFEST_VERSION_CODE}"/>
53 <property name="version.name" value="${APP_MANIFEST_VERSION_NAME}"/>
55 <property name="aapt.resource.filter" value="" />
56 <!-- 'aapt.ignore.assets' is the list of file patterns to ignore under /res and /assets.
57 Default is "!.svn:!.git:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"
59 Overall patterns syntax is:
60 [!][<dir>|<file>][*suffix-match|prefix-match*|full-match]:more:patterns...
62 - The first character flag ! avoids printing a warning.
63 - Pattern can have the flag "<dir>" to match only directories
64 or "<file>" to match only files. Default is to match both.
65 - Match is not case-sensitive.
67 <property name="aapt.ignore.assets" value="" />
70 Include additional resource folders in the apk, e.g. content/.../res. We
71 list the res folders in project.library.res.folder.path and the
72 corresponding java packages in project.library.packages, which must be
73 semicolon-delimited while ADDITIONAL_RES_PACKAGES is space-delimited, hence
74 the replacestring filterchain task.
76 <path id="project.library.res.folder.path">
77 <filelist files="${ADDITIONAL_RES_DIRS}"/>
79 <path id="project.library.bin.r.file.path">
80 <filelist files="${ADDITIONAL_R_TEXT_FILES}"/>
83 <loadresource property="project.library.packages">
84 <propertyresource name="ADDITIONAL_RES_PACKAGES"/>
86 <replacestring from=" " to=";"/>
89 <!-- Set to empty if not set by the loadresource above -->
90 <property name="project.library.packages" value=""/>
92 <property name="build.packaging.nocrunch" value="true" />
94 <!-- Intermediate files -->
95 <property name="resource.package.file.name" value="${APK_NAME}.ap_" />
97 <target name="-crunch">
98 <!-- Updates the pre-processed PNG cache -->
99 <exec executable="${aapt}" taskName="crunch">
100 <arg value="crunch" />
103 <arg path="${resource.absolute.dir}" />
105 <arg path="${out.res.absolute.dir}" />
109 <target name="-package-resources" depends="-crunch">
113 versioncode="${version.code}"
114 versionname="${version.name}"
115 debug="${build.is.packaging.debug}"
116 manifest="${out.manifest.abs.file}"
117 assets="${asset.absolute.dir}"
118 androidjar="${project.target.android.jar}"
119 apkfolder="${out.absolute.dir}"
120 nocrunch="${build.packaging.nocrunch}"
121 resourcefilename="${resource.package.file.name}"
122 resourcefilter="${aapt.resource.filter}"
123 libraryResFolderPathRefid="project.library.res.folder.path"
124 libraryPackagesRefid="project.library.packages"
125 libraryRFileRefid="project.library.bin.r.file.path"
127 buildType="${build.target}"
128 ignoreAssets="${aapt.ignore.assets}">
129 <res path="${out.res.absolute.dir}" />
130 <res path="${resource.absolute.dir}" />
131 <!-- <nocompress /> forces no compression on any files in assets or res/raw -->
132 <!-- <nocompress extension="xml" /> forces no compression on specific file extensions in assets and res/raw -->
135 <touch file="${STAMP}" />