build.xml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project name="yaxim" default="help">
  3. <!-- The local.properties file is created and updated by the 'android' tool.
  4. It contains the path to the SDK. It should *NOT* be checked into
  5. Version Control Systems. -->
  6. <loadproperties srcFile="local.properties" />
  7. <!-- The ant.properties file can be created by you. It is only edited by the
  8. 'android' tool to add properties to it.
  9. This is the place to change some Ant specific build properties.
  10. Here are some properties you may want to change/update:
  11. source.dir
  12. The name of the source directory. Default is 'src'.
  13. out.dir
  14. The name of the output directory. Default is 'bin'.
  15. For other overridable properties, look at the beginning of the rules
  16. files in the SDK, at tools/ant/build.xml
  17. Properties related to the SDK location or the project target should
  18. be updated using the 'android' tool with the 'update' action.
  19. This file is an integral part of the build system for your
  20. application and should be checked into Version Control Systems.
  21. -->
  22. <property file="ant.properties" />
  23. <!-- The project.properties file is created and updated by the 'android'
  24. tool, as well as ADT.
  25. This contains project specific properties such as project target, and library
  26. dependencies. Lower level build properties are stored in ant.properties
  27. (or in .classpath for Eclipse projects).
  28. This file is an integral part of the build system for your
  29. application and should be checked into Version Control Systems. -->
  30. <loadproperties srcFile="project.properties" />
  31. <!-- quick check on sdk.dir -->
  32. <fail
  33. message="sdk.dir is missing. Make sure to generate local.properties using 'android update project'"
  34. unless="sdk.dir"
  35. />
  36. <!-- Custom Android task to deal with the project target, and import the proper rules.
  37. This requires ant 1.6.0 or above. -->
  38. <path id="android.antlibs">
  39. <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
  40. <pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
  41. <pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
  42. <pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" />
  43. <pathelement path="${sdk.dir}/tools/lib/jarutils.jar" />
  44. </path>
  45. <!-- Execute the Android Setup task that will setup some properties specific to the target,
  46. and import the build rules files.
  47. The rules file is imported from
  48. <SDK>/platforms/<target_platform>/templates/android_rules.xml
  49. To customize some build steps for your project:
  50. - copy the content of the main node <project> from android_rules.xml
  51. - paste it in this build.xml below the <setup /> task.
  52. - disable the import by changing the setup task below to <setup import="false" />
  53. This will ensure that the properties are setup correctly but that your customized
  54. build steps are used.
  55. -->
  56. <target name="-pre-build">
  57. <tstamp>
  58. <format property="build.date" pattern="yyyy-MM-dd" />
  59. </tstamp>
  60. <exec executable="git" outputproperty="git.revision">
  61. <arg line="describe --tags --dirty=+"/>
  62. </exec>
  63. <copy file="version.xml.tpl" tofile="${resource.absolute.dir}/values/version.xml" overwrite="true">
  64. <filterchain>
  65. <replacetokens>
  66. <token key="build_revision" value="${git.revision}"/>
  67. <token key="build_date" value="${build.date}"/>
  68. <token key="build_version" value="${ant.project.name} ${git.revision} ${build.date}"/>
  69. </replacetokens>
  70. </filterchain>
  71. </copy>
  72. </target>
  73. <target name="check-proguard">
  74. <available file="tools/proguard.jar" property="have.proguard"/>
  75. </target>
  76. <target name="proguard" depends="check-proguard">
  77. <fail unless="have.proguard">Please download ProGuard from http://sourceforge.net/projects/proguard/files/ and place the JAR into the tools/ directory!</fail>
  78. </target>
  79. <target name="proguard.execute" depends="-compile, -post-compile" if="have.proguard">
  80. <taskdef resource="proguard/ant/task.properties"
  81. classpath="tools/proguard.jar" />
  82. <!-- following lines copied from android-sdk build.xml -->
  83. <path id="project.jars.ref">
  84. <pathelement location="${out.classes.absolute.dir}" />
  85. <path refid="project.all.jars.path" />
  86. </path>
  87. <pathconvert property="project.jars" refid="project.jars.ref">
  88. <firstmatchmapper>
  89. <regexpmapper from='^([^ ]*)( .*)$$' to='"\1\2"'/>
  90. <identitymapper/>
  91. </firstmatchmapper>
  92. </pathconvert>
  93. <proguard configuration="proguard.cfg">
  94. -injars ${project.jars}
  95. -outjars ${out.absolute.dir}/classes.min.jar
  96. -libraryjars ${toString:project.target.class.path}
  97. -printusage ${out.absolute.dir}/proguard.usage
  98. </proguard>
  99. </target>
  100. <!-- Convert this project's .class files into .dex files. -->
  101. <target name="dex.proguard" depends="proguard.execute" if="have.proguard">
  102. <dex executable="${dx}" output="${intermediate.dex.file}"
  103. nolocals="@{nolocals}"
  104. verbose="${verbose}"
  105. previousBuildType="${build.last.target}"
  106. buildType="${build.target}">
  107. <path path="${out.absolute.dir}/classes.min.jar" />
  108. </dex>
  109. </target>
  110. <!-- Convert this project's .class files into .dex files. -->
  111. <target name="dex.vanilla" depends="-compile, -post-compile" unless="have.proguard">
  112. <dex-helper>
  113. </dex-helper>
  114. </target>
  115. <target name="-dex" depends="dex.vanilla, dex.proguard" />
  116. <!-- Import the actual build file.
  117. To customize existing targets, there are two options:
  118. - Customize only one target:
  119. - copy/paste the target into this file, *before* the
  120. <import> task.
  121. - customize it to your needs.
  122. - Customize the whole content of build.xml
  123. - copy/paste the content of the rules files (minus the top node)
  124. into this file, replacing the <import> task.
  125. - customize to your needs.
  126. ***********************
  127. ****** IMPORTANT ******
  128. ***********************
  129. In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
  130. in order to avoid having your file be overridden by tools such as "android update project"
  131. -->
  132. <!-- version-tag: 1 -->
  133. <import file="${sdk.dir}/tools/ant/build.xml" />
  134. </project>