Home | History | Annotate | Download | only in ant
      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="-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" />
     23 
     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}" />
     28 
     29   <!-- jar file from where the tasks are loaded -->
     30   <path id="android.antlibs">
     31     <pathelement path="${sdk.dir}/tools/lib/ant-tasks.jar" />
     32   </path>
     33 
     34   <!-- Custom tasks -->
     35   <taskdef resource="anttasks.properties" classpathref="android.antlibs" />
     36 
     37   <condition property="build.target" value="release" else="debug">
     38     <equals arg1="${CONFIGURATION_NAME}" arg2="Release" />
     39   </condition>
     40   <condition property="build.is.packaging.debug" value="true" else="false">
     41     <equals arg1="${build.target}" arg2="debug" />
     42   </condition>
     43 
     44   <property name="resource.dir" value="${RESOURCE_DIR}"/>
     45   <property name="resource.absolute.dir" location="${resource.dir}"/>
     46 
     47   <property name="asset.dir" value="${ASSET_DIR}" />
     48   <property name="asset.absolute.dir" location="${asset.dir}" />
     49 
     50   <property name="aapt" location="${android.sdk.tools.dir}/aapt" />
     51 
     52   <property name="version.code" value="${APP_MANIFEST_VERSION_CODE}"/>
     53   <property name="version.name" value="${APP_MANIFEST_VERSION_NAME}"/>
     54 
     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:*~"
     58 
     59          Overall patterns syntax is:
     60            [!][<dir>|<file>][*suffix-match|prefix-match*|full-match]:more:patterns...
     61 
     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.
     66   -->
     67   <property name="aapt.ignore.assets" value="" />
     68 
     69   <!--
     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.
     75   -->
     76   <path id="project.library.res.folder.path">
     77     <filelist files="${ADDITIONAL_RES_DIRS}"/>
     78   </path>
     79   <path id="project.library.bin.r.file.path">
     80     <filelist files="${ADDITIONAL_R_TEXT_FILES}"/>
     81   </path>
     82 
     83   <loadresource property="project.library.packages">
     84     <propertyresource name="ADDITIONAL_RES_PACKAGES"/>
     85     <filterchain>
     86       <replacestring from=" " to=";"/>
     87     </filterchain>
     88   </loadresource>
     89   <!-- Set to empty if not set by the loadresource above -->
     90   <property name="project.library.packages" value=""/>
     91 
     92   <property name="build.packaging.nocrunch" value="true" />
     93 
     94   <!-- Intermediate files -->
     95   <property name="resource.package.file.name" value="${APK_NAME}.ap_" />
     96 
     97   <target name="-crunch">
     98     <!-- Updates the pre-processed PNG cache -->
     99     <exec executable="${aapt}" taskName="crunch">
    100       <arg value="crunch" />
    101       <arg value="-v" />
    102       <arg value="-S" />
    103       <arg path="${resource.absolute.dir}" />
    104       <arg value="-C" />
    105       <arg path="${out.res.absolute.dir}" />
    106     </exec>
    107   </target>
    108 
    109   <target name="-package-resources" depends="-crunch">
    110     <aapt
    111         executable="${aapt}"
    112         command="package"
    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"
    126         previousBuildType=""
    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 -->
    133     </aapt>
    134 
    135     <touch file="${STAMP}" />
    136   </target>
    137 </project>
    138