build.xml
changeset 105 c6e4728ac9f7
parent 54 dfbb0fbece57
child 158 8189aa05293e
equal deleted inserted replaced
97:58622a0f9485 105:c6e4728ac9f7
     1 <?xml version="1.0" ?>
     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <project name="Beem" default="debug">
     2 <project name="Beem" default="help">
       
     3 
       
     4     <!-- The local.properties file is created and updated by the 'android' tool.
       
     5          It contain the path to the SDK. It should *NOT* be checked in in Version
       
     6          Control Systems. -->
       
     7     <property file="local.properties"/>
     3 
     8 
     4     <!-- The build.properties file can be created by you and is never touched
     9     <!-- The build.properties file can be created by you and is never touched
     5          by activitycreator. If you want to manually set properties, this is
    10          by the 'android' tool. This is the place to change some of the default property values
     6          the best place to set them. -->
    11          used by the Ant rules.
       
    12          Here are some properties you may want to change/update:
       
    13 
       
    14          application-package
       
    15              the name of your application package as defined in the manifest. Used by the
       
    16              'uninstall' rule.
       
    17          source-folder
       
    18              the name of the source folder. Default is 'src'.
       
    19          out-folder
       
    20              the name of the output folder. Default is 'bin'.
       
    21 
       
    22          Properties related to the SDK location or the project target should be updated
       
    23           using the 'android' tool with the 'update' action.
       
    24 
       
    25          This file is an integral part of the build system for your application and
       
    26          should be checked in in Version Control Systems.
       
    27 
       
    28          -->
     7     <property file="build.properties"/>
    29     <property file="build.properties"/>
     8 
    30 
     9     <!-- The default.properties file is created and updated by activitycreator.
    31     <!-- The default.properties file is created and updated by the 'android' tool, as well
    10          It will set any properties not already defined by build.properties. -->
    32          as ADT. 
       
    33          This file is an integral part of the build system for your application and
       
    34          should be checked in in Version Control Systems. -->
    11     <property file="default.properties"/>
    35     <property file="default.properties"/>
    12 
    36 
    13     <!-- ************************************************************************************* -->
    37     <!-- Custom Android task to deal with the project target, and import the proper rules.
    14     <!-- These settings were written by activitycreator.
    38          This requires ant 1.6.0 or above. -->
    15          Do not change them unless you really know what you are doing. -->
    39     <path id="android.antlibs">
       
    40         <pathelement path="${sdk-location}/tools/lib/anttasks.jar" />
       
    41         <pathelement path="${sdk-location}/tools/lib/sdklib.jar" />
       
    42         <pathelement path="${sdk-location}/tools/lib/androidprefs.jar" />
       
    43         <pathelement path="${sdk-location}/tools/lib/apkbuilder.jar" />
       
    44         <pathelement path="${sdk-location}/tools/lib/jarutils.jar" />
       
    45     </path>
    16 
    46 
    17     <!-- Application Package Name -->
    47     <taskdef name="setup"
    18     <property name="application-package" value="com.beem.project.beem" />
    48         classname="com.android.ant.SetupTask"
       
    49         classpathref="android.antlibs"/>
    19 
    50 
    20     <!-- The intermediates directory, Eclipse uses "bin"
    51     <!-- Execute the Android Setup task that will setup some properties specific to the target,
    21          for its own output, so we do the same. -->
    52          and import the rules files.
    22     <property name="outdir" value="bin" />
    53          To customize the rules, copy/paste them below the task, and disable import by setting
    23     
    54          the import attribute to false:
    24     <!-- ************************************************************************************* -->
    55             <setup import="false" />
    25     <!-- No user servicable parts below. -->
    56          
       
    57          This will ensure that the properties are setup correctly but that your customized
       
    58          targets are used.
       
    59     -->
       
    60     <setup />
       
    61 	
       
    62 	  <target name="clean"
       
    63 		    description="Delete old build and dist directories">
       
    64 		<delete verbose="false" dir="${out-folder}"/>
       
    65 	    </target>
    26 
    66 
    27     <property name="android-tools" value="${sdk-folder}/tools" />
    67 	    <target name="javadoc" depends="aidl"
    28     <property name="android-framework" value="${android-tools}/lib/framework.aidl" />
    68 	    	description="Build the javadoc">
    29 
    69 		<javadoc sourcepath="${source-folder}" destdir="${javadoc-output}">
    30     <!-- Input directories -->
    70 		    <classpath>
    31     <property name="resource-dir" value="res" />
    71 			<fileset dir="${external-libs}" includes="*.jar" />
    32     <property name="asset-dir" value="assets" />
    72 		    </classpath>
    33     <property name="srcdir" value="src" />
    73 		</javadoc>	
    34     <condition property="srcdir-ospath"
    74 	    </target>
    35             value="${basedir}\${srcdir}"
       
    36             else="${basedir}/${srcdir}" >
       
    37         <os family="windows"/>
       
    38     </condition>
       
    39 
       
    40     <!-- folder for the 3rd party java libraries -->
       
    41     <property name="external-libs" value="libs" />
       
    42     <condition property="external-libs-ospath"
       
    43             value="${basedir}\${external-libs}"
       
    44             else="${basedir}/${external-libs}" >
       
    45         <os family="windows"/>
       
    46     </condition>
       
    47 
       
    48     <!-- folder for the native libraries -->
       
    49     <property name="native-libs" value="libs" />
       
    50     <condition property="native-libs-ospath"
       
    51             value="${basedir}\${native-libs}"
       
    52             else="${basedir}/${native-libs}" >
       
    53         <os family="windows"/>
       
    54     </condition>
       
    55 
       
    56     <!-- Output directories -->
       
    57     <property name="outdir-classes" value="${outdir}/classes" />
       
    58     <condition property="outdir-classes-ospath"
       
    59             value="${basedir}\${outdir-classes}"
       
    60             else="${basedir}/${outdir-classes}" >
       
    61         <os family="windows"/>
       
    62     </condition>
       
    63 
       
    64     <!-- Create R.java in the source directory -->
       
    65     <property name="outdir-r" value="src" />
       
    66 
       
    67     <!-- Intermediate files -->
       
    68     <property name="dex-file" value="classes.dex" />
       
    69     <property name="intermediate-dex" value="${outdir}/${dex-file}" />
       
    70     <condition property="intermediate-dex-ospath"
       
    71             value="${basedir}\${intermediate-dex}"
       
    72             else="${basedir}/${intermediate-dex}" >
       
    73         <os family="windows"/>
       
    74     </condition>
       
    75 
       
    76     <!-- The final package file to generate -->
       
    77     <property name="resources-package" value="${outdir}/${ant.project.name}.ap_" />
       
    78     <condition property="resources-package-ospath"
       
    79             value="${basedir}\${resources-package}"
       
    80             else="${basedir}/${resources-package}" >
       
    81         <os family="windows"/>
       
    82     </condition>
       
    83 
       
    84     <property name="out-debug-package" value="${outdir}/${ant.project.name}-debug.apk" />
       
    85     <condition property="out-debug-package-ospath"
       
    86             value="${basedir}\${out-debug-package}"
       
    87             else="${basedir}/${out-debug-package}" >
       
    88         <os family="windows"/>
       
    89     </condition>
       
    90 
       
    91     <property name="out-unsigned-package" value="${outdir}/${ant.project.name}-unsigned.apk" />
       
    92     <condition property="out-unsigned-package-ospath"
       
    93             value="${basedir}\${out-unsigned-package}"
       
    94             else="${basedir}/${out-unsigned-package}" >
       
    95         <os family="windows"/>
       
    96     </condition>
       
    97 
       
    98     <!-- Tools -->
       
    99     <condition property="aapt" value="${android-tools}/aapt.exe" else="${android-tools}/aapt" >
       
   100         <os family="windows"/>
       
   101     </condition>
       
   102     <condition property="aidl" value="${android-tools}/aidl.exe" else="${android-tools}/aidl" >
       
   103         <os family="windows"/>
       
   104     </condition>
       
   105     <condition property="adb" value="${android-tools}/adb.exe" else="${android-tools}/adb" >
       
   106         <os family="windows"/>
       
   107     </condition>
       
   108     <condition property="dx" value="${android-tools}/dx.bat" else="${android-tools}/dx" >
       
   109         <os family="windows"/>
       
   110     </condition>
       
   111     <condition property="apk-builder" value="${android-tools}/apkbuilder.bat" else="${android-tools}/apkbuilder" >
       
   112         <os family="windows"/>
       
   113     </condition>
       
   114 
       
   115     <property name="android-jar" value="${sdk-folder}/android.jar" />
       
   116 
       
   117     <property name="javadoc-output" value="doc/javadoc" />
       
   118 	
       
   119     <!-- Rules -->
       
   120 
       
   121     <!-- Create the output directories if they don't exist yet. -->
       
   122     <target name="dirs">
       
   123         <echo>Creating output directories if needed...</echo>
       
   124         <mkdir dir="${outdir}" />
       
   125         <mkdir dir="${outdir-classes}" />
       
   126     	<mkdir dir="${javadoc-output}" />
       
   127     </target>
       
   128 
       
   129     <!-- Generate the R.java file for this project's resources. -->
       
   130     <target name="resource-src" depends="dirs">
       
   131         <echo>Generating R.java / Manifest.java from the resources...</echo>
       
   132         <exec executable="${aapt}" failonerror="true">
       
   133             <arg value="package" />
       
   134             <arg value="-m" />
       
   135             <arg value="-J" />
       
   136             <arg value="${outdir-r}" />
       
   137             <arg value="-M" />
       
   138             <arg value="AndroidManifest.xml" />
       
   139             <arg value="-S" />
       
   140             <arg value="${resource-dir}" />
       
   141             <arg value="-I" />
       
   142             <arg value="${android-jar}" />
       
   143         </exec>
       
   144     </target>
       
   145 
       
   146     <!-- Generate java classes from .aidl files. -->
       
   147     <target name="aidl" depends="dirs">
       
   148         <echo>Compiling aidl files into Java classes...</echo>
       
   149         <apply executable="${aidl}" failonerror="true">
       
   150             <arg value="-p${android-framework}" />
       
   151             <arg value="-p${basedir}/project.aidl"/>
       
   152             <arg value="-I${srcdir}" />
       
   153             <fileset dir="${srcdir}">
       
   154                 <include name="**/*.aidl"/>
       
   155             </fileset>
       
   156         </apply>
       
   157     	
       
   158     </target>
       
   159 
       
   160     <!-- Compile this project's .java files into .class files. -->
       
   161     <target name="compile" depends="dirs, resource-src, aidl">
       
   162         <javac encoding="ascii" target="1.5" debug="true" extdirs=""
       
   163                 srcdir="."
       
   164                 destdir="${outdir-classes}"
       
   165                 bootclasspath="${android-jar}">
       
   166             <classpath>
       
   167                 <fileset dir="${external-libs}" includes="*.jar"/>
       
   168             </classpath>
       
   169          </javac>
       
   170     </target>
       
   171 
       
   172     <!-- Convert this project's .class files into .dex files. -->
       
   173     <target name="dex" depends="compile">
       
   174         <echo>Converting compiled files and external libraries into ${outdir}/${dex-file}...</echo>
       
   175         <apply executable="${dx}" failonerror="true" parallel="true">
       
   176             <arg value="--dex" />
       
   177             <arg value="--output=${intermediate-dex-ospath}" />
       
   178             <arg path="${outdir-classes-ospath}" />
       
   179             <fileset dir="${external-libs}" includes="*.jar"/>
       
   180         </apply>
       
   181     </target>
       
   182 
       
   183     <!-- Put the project's resources into the output package file. -->
       
   184     <target name="package-res-and-assets">
       
   185         <echo>Packaging resources and assets...</echo>
       
   186         <exec executable="${aapt}" failonerror="true">
       
   187             <arg value="package" />
       
   188             <arg value="-f" />
       
   189             <arg value="-M" />
       
   190             <arg value="AndroidManifest.xml" />
       
   191             <arg value="-S" />
       
   192             <arg value="${resource-dir}" />
       
   193             <arg value="-A" />
       
   194             <arg value="${asset-dir}" />
       
   195             <arg value="-I" />
       
   196             <arg value="${android-jar}" />
       
   197             <arg value="-F" />
       
   198             <arg value="${resources-package}" />
       
   199         </exec>
       
   200     </target>
       
   201 
       
   202     <!-- Same as package-res-and-assets, but without "-A ${asset-dir}" -->
       
   203     <target name="package-res-no-assets">
       
   204         <echo>Packaging resources...</echo>
       
   205         <exec executable="${aapt}" failonerror="true">
       
   206             <arg value="package" />
       
   207             <arg value="-f" />
       
   208             <arg value="-M" />
       
   209             <arg value="AndroidManifest.xml" />
       
   210             <arg value="-S" />
       
   211             <arg value="${resource-dir}" />
       
   212             <!-- No assets directory -->
       
   213             <arg value="-I" />
       
   214             <arg value="${android-jar}" />
       
   215             <arg value="-F" />
       
   216             <arg value="${resources-package}" />
       
   217         </exec>
       
   218     </target>
       
   219 
       
   220     <!-- Invoke the proper target depending on whether or not
       
   221          an assets directory is present. -->
       
   222     <!-- TODO: find a nicer way to include the "-A ${asset-dir}" argument
       
   223          only when the assets dir exists. -->
       
   224     <target name="package-res">
       
   225         <available file="${asset-dir}" type="dir"
       
   226                 property="res-target" value="and-assets" />
       
   227         <property name="res-target" value="no-assets" />
       
   228         <antcall target="package-res-${res-target}" />
       
   229     </target>
       
   230 
       
   231     <!-- Package the application and sign it with a debug key.
       
   232          This is the default target when building. It is used for debug. -->
       
   233     <target name="debug" depends="dex, package-res">
       
   234         <echo>Packaging ${out-debug-package}, and signing it with a debug key...</echo>
       
   235         <exec executable="${apk-builder}" failonerror="true">
       
   236             <arg value="${out-debug-package-ospath}" />
       
   237             <arg value="-z" />
       
   238             <arg value="${resources-package-ospath}" />
       
   239             <arg value="-f" />
       
   240             <arg value="${intermediate-dex-ospath}" />
       
   241             <arg value="-rf" />
       
   242             <arg value="${srcdir-ospath}" />
       
   243             <arg value="-rj" />
       
   244             <arg value="${external-libs-ospath}" />
       
   245             <arg value="-nf" />
       
   246             <arg value="${native-libs-ospath}" />
       
   247         </exec>
       
   248     </target>
       
   249 
       
   250     <!-- Package the application without signing it.
       
   251          This allows for the application to be signed later with an official publishing key. -->
       
   252     <target name="release" depends="dex, package-res"
       
   253     	description="Package the application without signing it.
       
   254         This allows for the application to be signed later with an official publishing key.">
       
   255         <echo>Packaging ${out-unsigned-package} for release...</echo>
       
   256         <exec executable="${apk-builder}" failonerror="true">
       
   257             <arg value="${out-unsigned-package-ospath}" />
       
   258             <arg value="-u" />
       
   259             <arg value="-z" />
       
   260             <arg value="${resources-package-ospath}" />
       
   261             <arg value="-f" />
       
   262             <arg value="${intermediate-dex-ospath}" />
       
   263             <arg value="-rf" />
       
   264             <arg value="${srcdir-ospath}" />
       
   265             <arg value="-rj" />
       
   266             <arg value="${external-libs-ospath}" />
       
   267             <arg value="-nf" />
       
   268             <arg value="${native-libs-ospath}" />
       
   269         </exec>
       
   270         <echo>It will need to be signed with jarsigner before being published.</echo>
       
   271     </target>
       
   272 
       
   273     <!-- Install the package on the default emulator -->
       
   274     <target name="install" depends="debug"
       
   275     	description="Install the package on the default emulator">
       
   276         <echo>Installing ${out-debug-package} onto default emulator...</echo>
       
   277         <exec executable="${adb}" failonerror="true">
       
   278             <arg value="install" />
       
   279             <arg value="${out-debug-package}" />
       
   280         </exec>
       
   281     </target>
       
   282 
       
   283     <target name="reinstall" depends="debug">
       
   284         <echo>Installing ${out-debug-package} onto default emulator...</echo>
       
   285         <exec executable="${adb}" failonerror="true">
       
   286             <arg value="install" />
       
   287             <arg value="-r" />
       
   288             <arg value="${out-debug-package}" />
       
   289         </exec>
       
   290     </target>
       
   291 
       
   292     <!-- Uninstall the package from the default emulator -->
       
   293     <target name="uninstall"
       
   294     	description="Uninstall the package from the default emulator">
       
   295         <echo>Uninstalling ${application-package} from the default emulator...</echo>
       
   296         <exec executable="${adb}" failonerror="true">
       
   297             <arg value="uninstall" />
       
   298             <arg value="${application-package}" />
       
   299 	</exec>
       
   300     </target>
       
   301 
       
   302     <target name="clean"
       
   303 	    description="Delete old build and dist directories">
       
   304 	<delete verbose="false" dir="${outdir}"/>
       
   305     </target>
       
   306 
       
   307     <target name="javadoc" depends="aidl"
       
   308     	description="Build the javadoc">
       
   309 	<javadoc sourcepath="${srcdir}" destdir="${javadoc-output}">
       
   310 	    <classpath>
       
   311 		<fileset dir="${external-libs}" includes="*.jar" />
       
   312 	    </classpath>
       
   313 	</javadoc>	
       
   314     </target>
       
   315 
       
   316 </project>
    75 </project>