android-project/build.xml
changeset 6631 47ab7ba21530
parent 4965 91d0085b7560
     1.1 --- a/android-project/build.xml	Fri Nov 02 02:22:32 2012 -0700
     1.2 +++ b/android-project/build.xml	Fri Nov 02 02:37:49 2012 -0700
     1.3 @@ -1,67 +1,93 @@
     1.4  <?xml version="1.0" encoding="UTF-8"?>
     1.5 -<project name="SDLApp" default="help">
     1.6 +<!-- This should be changed to the name of your project -->
     1.7 +<project name="SDLActivity" default="help">
     1.8  
     1.9      <!-- The local.properties file is created and updated by the 'android' tool.
    1.10 -         It contains the path to the SDK. It should *NOT* be checked in in Version
    1.11 -         Control Systems. -->
    1.12 +         It contains the path to the SDK. It should *NOT* be checked into
    1.13 +         Version Control Systems. -->
    1.14      <property file="local.properties" />
    1.15  
    1.16 -    <!-- The build.properties file can be created by you and is never touched
    1.17 -         by the 'android' tool. This is the place to change some of the default property values
    1.18 -         used by the Ant rules.
    1.19 +    <!-- The ant.properties file can be created by you. It is only edited by the
    1.20 +         'android' tool to add properties to it.
    1.21 +         This is the place to change some Ant specific build properties.
    1.22           Here are some properties you may want to change/update:
    1.23  
    1.24 -         application.package
    1.25 -             the name of your application package as defined in the manifest. Used by the
    1.26 -             'uninstall' rule.
    1.27           source.dir
    1.28 -             the name of the source directory. Default is 'src'.
    1.29 +             The name of the source directory. Default is 'src'.
    1.30           out.dir
    1.31 -             the name of the output directory. Default is 'bin'.
    1.32 +             The name of the output directory. Default is 'bin'.
    1.33  
    1.34 -         Properties related to the SDK location or the project target should be updated
    1.35 -          using the 'android' tool with the 'update' action.
    1.36 +         For other overridable properties, look at the beginning of the rules
    1.37 +         files in the SDK, at tools/ant/build.xml
    1.38  
    1.39 -         This file is an integral part of the build system for your application and
    1.40 -         should be checked in in Version Control Systems.
    1.41 +         Properties related to the SDK location or the project target should
    1.42 +         be updated using the 'android' tool with the 'update' action.
    1.43 +
    1.44 +         This file is an integral part of the build system for your
    1.45 +         application and should be checked into Version Control Systems.
    1.46  
    1.47           -->
    1.48 -    <property file="build.properties" />
    1.49 +    <property file="ant.properties" />
    1.50  
    1.51 -    <!-- The default.properties file is created and updated by the 'android' tool, as well
    1.52 -         as ADT.
    1.53 -         This file is an integral part of the build system for your application and
    1.54 -         should be checked in in Version Control Systems. -->
    1.55 -    <property file="default.properties" />
    1.56 +    <!-- if sdk.dir was not set from one of the property file, then
    1.57 +         get it from the ANDROID_HOME env var.
    1.58 +         This must be done before we load project.properties since
    1.59 +         the proguard config can use sdk.dir -->
    1.60 +    <property environment="env" />
    1.61 +    <condition property="sdk.dir" value="${env.ANDROID_HOME}">
    1.62 +        <isset property="env.ANDROID_HOME" />
    1.63 +    </condition>
    1.64  
    1.65 -    <!-- Custom Android task to deal with the project target, and import the proper rules.
    1.66 -         This requires ant 1.6.0 or above. -->
    1.67 -    <path id="android.antlibs">
    1.68 -        <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
    1.69 -        <pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
    1.70 -        <pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
    1.71 -        <pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" />
    1.72 -        <pathelement path="${sdk.dir}/tools/lib/jarutils.jar" />
    1.73 -    </path>
    1.74 +    <!-- The project.properties file is created and updated by the 'android'
    1.75 +         tool, as well as ADT.
    1.76  
    1.77 -    <taskdef name="setup"
    1.78 -        classname="com.android.ant.SetupTask"
    1.79 -        classpathref="android.antlibs" />
    1.80 +         This contains project specific properties such as project target, and library
    1.81 +         dependencies. Lower level build properties are stored in ant.properties
    1.82 +         (or in .classpath for Eclipse projects).
    1.83  
    1.84 -    <!-- Execute the Android Setup task that will setup some properties specific to the target,
    1.85 -         and import the build rules files.
    1.86 +         This file is an integral part of the build system for your
    1.87 +         application and should be checked into Version Control Systems. -->
    1.88 +    <loadproperties srcFile="project.properties" />
    1.89  
    1.90 -         The rules file is imported from
    1.91 -            <SDK>/platforms/<target_platform>/templates/android_rules.xml
    1.92 +    <!-- quick check on sdk.dir -->
    1.93 +    <fail
    1.94 +            message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
    1.95 +            unless="sdk.dir"
    1.96 +    />
    1.97  
    1.98 -         To customize some build steps for your project:
    1.99 -         - copy the content of the main node <project> from android_rules.xml
   1.100 -         - paste it in this build.xml below the <setup /> task.
   1.101 -         - disable the import by changing the setup task below to <setup import="false" />
   1.102 +    <!--
   1.103 +        Import per project custom build rules if present at the root of the project.
   1.104 +        This is the place to put custom intermediary targets such as:
   1.105 +            -pre-build
   1.106 +            -pre-compile
   1.107 +            -post-compile (This is typically used for code obfuscation.
   1.108 +                           Compiled code location: ${out.classes.absolute.dir}
   1.109 +                           If this is not done in place, override ${out.dex.input.absolute.dir})
   1.110 +            -post-package
   1.111 +            -post-build
   1.112 +            -pre-clean
   1.113 +    -->
   1.114 +    <import file="custom_rules.xml" optional="true" />
   1.115  
   1.116 -         This will ensure that the properties are setup correctly but that your customized
   1.117 -         build steps are used.
   1.118 +    <!-- Import the actual build file.
   1.119 +
   1.120 +         To customize existing targets, there are two options:
   1.121 +         - Customize only one target:
   1.122 +             - copy/paste the target into this file, *before* the
   1.123 +               <import> task.
   1.124 +             - customize it to your needs.
   1.125 +         - Customize the whole content of build.xml
   1.126 +             - copy/paste the content of the rules files (minus the top node)
   1.127 +               into this file, replacing the <import> task.
   1.128 +             - customize to your needs.
   1.129 +
   1.130 +         ***********************
   1.131 +         ****** IMPORTANT ******
   1.132 +         ***********************
   1.133 +         In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
   1.134 +         in order to avoid having your file be overridden by tools such as "android update project"
   1.135      -->
   1.136 -    <setup />
   1.137 +    <!-- version-tag: 1 -->
   1.138 +    <import file="${sdk.dir}/tools/ant/build.xml" />
   1.139  
   1.140  </project>