build: move custom rules to custom_rules.xml

usb
Georg Lukas 2015-08-27 20:31:00 +02:00
rodzic 08312e7a09
commit 0257620f25
2 zmienionych plików z 105 dodań i 92 usunięć

117
build.xml
Wyświetl plik

@ -4,7 +4,7 @@
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<loadproperties srcFile="local.properties" />
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
@ -28,6 +28,15 @@
-->
<property file="ant.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
@ -41,49 +50,23 @@
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project'"
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."
unless="sdk.dir"
/>
<!-- extension targets. Uncomment the ones where you want to do custom work
in between standard targets -->
<property name="mapviewxml" value="res/layout/mapview.xml" />
<target name="-pre-build">
<fail unless="mapsApiKey">You need to add mapsApiKey=... to local.properties</fail>
<copy file="mapview.xml.tpl" tofile="${mapviewxml}" overwrite="true">
<filterchain>
<replacetokens>
<token key="apiKey" value="${mapsApiKey}"/>
</replacetokens>
</filterchain>
</copy>
<tstamp>
<format property="build.date" pattern="yyyy-MM-dd" />
</tstamp>
<exec executable="git" outputproperty="git.revision">
<arg line="describe --tags --dirty=+"/>
</exec>
<copy file="version.xml.tpl" tofile="${resource.absolute.dir}/values/version.xml" overwrite="true">
<filterchain>
<replacetokens>
<token key="build_version" value="${ant.project.name} ${git.revision} ${build.date}"/>
</replacetokens>
</filterchain>
</copy>
</target>
<!--
<target name="-pre-compile">
</target>
/* This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir} */
-->
<target name="-post-compile" depends="scalac, proguard">
</target>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
@ -103,57 +86,7 @@
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: custom -->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
<target name="check-scalalib">
<available file="tools/scala-library.jar" property="have.scalalib"/>
<fail unless="have.scalalib">You have to place scala-compiler.jar and scala-library.jar to tools/</fail>
</target>
<target name="check-scalac">
<available file="tools/scala-compiler.jar" property="have.scalac"/>
<fail unless="have.scalac">You have to place scala-compiler.jar and scala-library.jar to tools/</fail>
</target>
<target name="scalac" depends="-compile, check-scalalib, check-scalac">
<taskdef resource="scala/tools/ant/antlib.xml"
classpath="tools/scala-compiler.jar:tools/scala-library.jar:tools/scala-reflect.jar" />
<scalac force="changed" deprecation="on"
srcdir="${source.absolute.dir}" includes="**/*.scala"
bootclasspathref="project.target.class.path"
destdir="${out.classes.absolute.dir}">
<classpath>
<pathelement location="${out.classes.absolute.dir}"/>
<fileset dir="tools" includes="*.jar"/>
<fileset dir="${jar.libs.dir}" includes="*.jar"/>
</classpath>
</scalac>
</target>
<target name="check-proguard">
<available file="tools/proguard.jar" property="have.proguard"/>
<fail unless="have.proguard">ProGuard is required to build! Copy proguard.jar to tools/</fail>
</target>
<property name="optimized.dir" value="${out.absolute.dir}/optimized" />
<target name="proguard" depends="scalac, check-proguard">
<taskdef resource="proguard/ant/task.properties"
classpath="tools/proguard.jar" />
<mkdir dir="${optimized.dir}" />
<proguard configuration="proguard.cfg">
-injars ${out.classes.absolute.dir}:${jar.libs.dir}:tools/scala-library.jar(!META-INF/MANIFEST.MF,!library.properties)
-outjars ${out.absolute.dir}/classes.min.jar
-libraryjars ${toString:project.target.class.path}
-printusage ${optimized.dir}/proguard.usage
</proguard>
</target>
<target name="-dex" depends="-post-compile">
<echo>Converting compiled files and external libraries into ${intermediate.dex.file}...</echo>
<apply executable="${dx}" failonerror="true" parallel="true">
<arg value="--dex" />
<arg value="--output=${intermediate.dex.file}" />
<fileset dir="${out.absolute.dir}" includes="*.min.jar"/>
</apply>
</target>
</project>

80
custom_rules.xml 100644
Wyświetl plik

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<property name="mapviewxml" value="res/layout/mapview.xml" />
<target name="-pre-build">
<fail unless="mapsApiKey">You need to add mapsApiKey=... to local.properties</fail>
<copy file="mapview.xml.tpl" tofile="${mapviewxml}" overwrite="true">
<filterchain>
<replacetokens>
<token key="apiKey" value="${mapsApiKey}"/>
</replacetokens>
</filterchain>
</copy>
<tstamp>
<format property="build.date" pattern="yyyy-MM-dd" />
</tstamp>
<exec executable="git" outputproperty="git.revision">
<arg line="describe --tags --dirty=+"/>
</exec>
<copy file="version.xml.tpl" tofile="${resource.absolute.dir}/values/version.xml" overwrite="true">
<filterchain>
<replacetokens>
<token key="build_version" value="${ant.project.name} ${git.revision} ${build.date}"/>
</replacetokens>
</filterchain>
</copy>
</target>
<target name="check-scalalib">
<available file="tools/scala-library.jar" property="have.scalalib"/>
<fail unless="have.scalalib">You have to place scala-compiler.jar and scala-library.jar to tools/</fail>
</target>
<target name="check-scalac">
<available file="tools/scala-compiler.jar" property="have.scalac"/>
<fail unless="have.scalac">You have to place scala-compiler.jar and scala-library.jar to tools/</fail>
</target>
<target name="scalac" depends="-compile, check-scalalib, check-scalac">
<taskdef resource="scala/tools/ant/antlib.xml"
classpath="tools/scala-compiler.jar:tools/scala-library.jar:tools/scala-reflect.jar" />
<scalac force="changed" deprecation="on"
srcdir="${source.absolute.dir}" includes="**/*.scala"
bootclasspathref="project.target.class.path"
destdir="${out.classes.absolute.dir}">
<classpath>
<pathelement location="${out.classes.absolute.dir}"/>
<fileset dir="tools" includes="*.jar"/>
<fileset dir="${jar.libs.dir}" includes="*.jar"/>
</classpath>
</scalac>
</target>
<!-- proguard is always enabled in APRSdroid -->
<target name="-post-compile" depends="scalac, proguard" />
<target name="proguard" depends="scalac">
<property name="proguard.jar" location="${android.tools.dir}/proguard/lib/proguard.jar" />
<taskdef name="proguard" classname="proguard.ant.ProGuardTask" classpath="${proguard.jar}" />
<property name="obfuscate.absolute.dir" location="${out.absolute.dir}/proguard" />
<property name="obfuscated.jar.file" value="${obfuscate.absolute.dir}/obfuscated.jar" />
<property name="out.dex.input.absolute.dir" value="${obfuscated.jar.file}" />
<mkdir dir="${obfuscate.absolute.dir}" />
<proguard configuration="proguard.cfg">
-injars ${out.classes.absolute.dir}:${jar.libs.dir}:tools/scala-library.jar(!META-INF/MANIFEST.MF,!library.properties)
-outjars ${obfuscated.jar.file}
-libraryjars ${toString:project.target.class.path}
-dump "${obfuscate.absolute.dir}/dump.txt"
-printseeds "${obfuscate.absolute.dir}/seeds.txt"
-printusage "${obfuscate.absolute.dir}/usage.txt"
-printmapping "${obfuscate.absolute.dir}/mapping.txt"
</proguard>
<path id="out.dex.jar.input.ref" />
</target>
<target name="-obfuscate" depends="proguard" />
</project>