OsmAnd/OsmAnd/build.xml
2014-07-31 12:30:17 +02:00

293 lines
11 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<project name="OsmAnd" default="help">
<property file="local.properties" />
<property file="ant.properties" />
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
unless="sdk.dir" />
<property name="use.dir" value="../OsmAnd-java/src" />
<property name="use.absolute.dir" location="${use.dir}" />
<property name="src.absolute.dir" location="src" />
<property name="base.dir" location="." />
<target name="copy_resources">
<copy todir="assets">
<fileset dir="../../resources/">
<include name="specialphrases/**" />
<include name="voice/**/*.p" />
</fileset>
</copy>
<copy todir="res/">
<fileset dir="../../resources/rendering_styles/style-icons/" >
<include name="**/*" />
</fileset>
</copy>
<copy todir="${src.absolute.dir}/net/osmand/router/">
<fileset dir="../../resources/routing/">
<include name="*.xml" />
</fileset>
</copy>
<sync todir="assets/help/">
<fileset dir="../../help/">
<include name="*.html" />
<include name="images/**/*.png" />
</fileset>
</sync>
<copy todir="assets/help">
<fileset dir="assets/">
<include name="style.css" />
</fileset>
</copy>
<copy todir="${src.absolute.dir}/net/osmand/render/">
<fileset dir="../../resources/rendering_styles/">
<include name="*.xml" />
</fileset>
</copy>
<copy todir="${src.absolute.dir}/net/osmand/osm/">
<fileset dir="../../resources/obf_creation/">
<include name="rendering_types.xml" />
</fileset>
</copy>
<copy todir="${src.absolute.dir}/net/osmand/map/">
<fileset dir="../../resources/countries-info/">
<include name="regions.ocbf" />
</fileset>
</copy>
</target>
<target name="generate-resources" depends="">
</target>
<!-- Extra target -->
<target name="-pre-build" depends="copy_resources,fix_apostrophe_issues">
<if>
<condition>
<isset property="versionFeatures" />
</condition>
<then>
<replaceregexp file="res/values/no_translate.xml" match='versionFeatures"&gt;(.*)&lt;' replace='versionFeatures"&gt;${versionFeatures}&lt;' byline="true" />
</then>
</if>
<if>
<condition>
<isset property="net.osmand.sherpafy" />
</condition>
<then>
<property name="package.name" value="net.osmand.sherpafy" />
<property name="app.name" value="Sherpafy" />
<replaceregexp file="AndroidManifest.xml" match='"@drawable/([^\s]*)"' replace='"@drawable/icon_sherpafy"' byline="true" />
</then>
</if>
<if>
<condition>
<isset property="net.osmand" />
</condition>
<then>
<property name="package.name" value="net.osmand" />
<property name="app.name" value="OsmAnd" />
<replaceregexp file="AndroidManifest.xml" match='"@drawable/([^\s]*)"' replace='"@drawable/icon_free"' byline="true" />
</then>
</if>
<if>
<condition>
<isset property="net.osmand.plus" />
</condition>
<then>
<property name="package.name" value="net.osmand.plus" />
<property name="app.name" value="OsmAnd+" />
<replaceregexp file="AndroidManifest.xml" match='"@drawable/([^\s]*)"' replace='"@drawable/icon"' byline="true" />
</then>
</if>
<if>
<condition>
<isset property="package.name" />
</condition>
<then>
<replaceregexp file="AndroidManifest.xml" match='package="(.*)"' replace='package="${package.name}"' byline="true" />
<replaceregexp file="AndroidManifest.xml" match='android:process="(.*)"' replace='android:process="${package.name}"' byline="true" />
<replaceregexp file="res/values/no_translate.xml" match='"app_name"&gt;(.*)&lt;' replace='"app_name"&gt;${app.name}&lt;' byline="true" />
<replaceregexp file="res/layout/search_address.xml" match='xmlns:custom="http://schemas.android.com/apk/res/(.*)"'
replace='xmlns:custom="http://schemas.android.com/apk/res/${package.name}"' byline="true" />
<replaceregexp file="res/layout/navigate_point.xml" match='xmlns:custom="http://schemas.android.com/apk/res/(.*)"'
replace='xmlns:custom="http://schemas.android.com/apk/res/${package.name}"' byline="true" />
</then>
</if>
<if>
<condition>
<isset property="build.version.code" />
</condition>
<then>
<replaceregexp file="AndroidManifest.xml" match='android:versionCode="(.*)"' replace='android:versionCode="${build.version.code}"' byline="true" />
<replaceregexp file="AndroidManifest.xml" match='android:debuggable="true"' replace='android:debuggable="false"' byline="true" />
</then>
</if>
<if>
<condition>
<isset property="build.version" />
</condition>
<then>
<replaceregexp file="res/values/no_translate.xml" match='"app_version"&gt;(.*)&lt;' replace='"app_version"&gt;${build.version}&lt;' byline="true" />
</then>
</if>
</target>
<target name="copy_sherpafy">
<copy todir="gen/net/osmand/plus">
<fileset dir="gen/net/osmand/sherpafy">
<include name="R.java" />
</fileset>
</copy>
<replaceregexp file="gen/net/osmand/plus/R.java" match='package (.*);' replace='package net.osmand.plus;' byline="true" />
</target>
<!-- Compiles this project's .java files into .class files. -->
<target name="-compile" depends="-build-setup, -pre-build, -code-gen, -pre-compile">
<!-- osmchange : Osmand plus support -->
<mkdir dir="${gen.absolute.dir}/net/osmand/plus" />
<if>
<condition>
<isset property="net.osmand.sherpafy" />
</condition>
<then>
<copy todir="${gen.absolute.dir}/net/osmand/plus">
<fileset dir="${gen.absolute.dir}/net/osmand/sherpafy">
<include name="R.java" />
</fileset>
</copy>
</then>
</if>
<if>
<condition>
<isset property="net.osmand" />
</condition>
<then>
<copy todir="${gen.absolute.dir}/net/osmand/plus">
<fileset dir="${gen.absolute.dir}/net/osmand">
<include name="R.java" />
</fileset>
</copy>
</then>
</if>
<replaceregexp file="${gen.absolute.dir}/net/osmand/plus/R.java" match='package (.*);' replace='package net.osmand.plus;' byline="true" />
<!-- osmchange : Osmand plus support -->
<do-only-if-manifest-hasCode elseText="hasCode = false. Skipping...">
<!-- merge the project's own classpath and the tested project's classpath -->
<path id="project.javac.classpath">
<path refid="project.all.jars.path" />
<path refid="tested.project.classpath" />
</path>
<javac encoding="${java.encoding}" source="${java.source}" target="${java.target}" debug="true" extdirs="" includeantruntime="false" destdir="${out.classes.absolute.dir}" bootclasspathref="project.target.class.path" verbose="${verbose}" classpathref="project.javac.classpath" fork="${need.javac.fork}">
<src path="${source.absolute.dir}" />
<src path="${gen.absolute.dir}" />
<compilerarg line="${java.compilerargs}" />
<!-- osmchange -->
<src path="${use.absolute.dir}" />
<exclude name="**/PlatformUtil.java" />
<!-- osmchange -->
</javac>
<!-- if the project is instrumented, intrument the classes -->
<if condition="${build.is.instrumented}">
<then>
<echo level="info">Instrumenting classes from ${out.absolute.dir}/classes...</echo>
<!-- build the filter to remove R, Manifest, BuildConfig -->
<getemmafilter appPackage="${project.app.package}" libraryPackagesRefId="project.library.packages" filterOut="emma.default.filter" />
<!-- define where the .em file is going. This may have been
setup already if this is a library -->
<property name="emma.coverage.absolute.file" location="${out.absolute.dir}/coverage.em" />
<!-- It only instruments class files, not any external libs -->
<emma enabled="true">
<instr verbosity="${verbosity}" mode="overwrite" instrpath="${out.absolute.dir}/classes" outdir="${out.absolute.dir}/classes" metadatafile="${emma.coverage.absolute.file}">
<filter excludes="${emma.default.filter}" />
<filter value="${emma.filter}" />
</instr>
</emma>
</then>
</if>
<!-- if the project is a library then we generate a jar file -->
<if condition="${project.is.library}">
<then>
<echo level="info">Creating library output jar file...</echo>
<property name="out.library.jar.file" location="${out.absolute.dir}/classes.jar" />
<if>
<condition>
<length string="${android.package.excludes}" trim="true" when="greater" length="0" />
</condition>
<then>
<echo level="info">Custom jar packaging exclusion: ${android.package.excludes}</echo>
</then>
</if>
<propertybyreplace name="project.app.package.path" input="${project.app.package}" replace="." with="/" />
<jar destfile="${out.library.jar.file}">
<fileset dir="${out.classes.absolute.dir}" includes="**/*.class" excludes="${project.app.package.path}/R.class ${project.app.package.path}/R$*.class ${project.app.package.path}/Manifest.class ${project.app.package.path}/Manifest$*.class ${project.app.package.path}/BuildConfig.class" />
<fileset dir="${source.absolute.dir}" excludes="**/*.java ${android.package.excludes}" />
</jar>
</then>
</if>
</do-only-if-manifest-hasCode>
</target>
<path id="lib.path">
<fileset dir="ant-lib" includes="*.jar" />
</path>
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
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 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
<taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask" classpathref="lib.path" />
<target name="cpd" description="Search for cut-and-pasted code">
<property name="cpd.report.xml" location="cpd.xml" />
<cpd minimumTokenCount="100" format="xml" outputFile="${cpd.report.xml}"
ignoreLiterals="true" ignoreIdentifiers="true">
<fileset dir="${source.absolute.dir}" includes="**/*.java" />
</cpd>
</target>
<target name="fix_apostrophe_issues">
<replace token="version='1.0'" value="version=&quot;1.0&quot;">
<fileset dir="res" includes="**/strings.xml" />
</replace>
<replace token="encoding='utf-8'" value="encoding=&quot;utf-8&quot;">
<fileset dir="res" includes="**/strings.xml" />
</replace>
<replaceregexp match="([^\\])'" replace="\1\\\\'" flags="-g" byline="off">
<fileset dir="res" includes="**/strings.xml" />
</replaceregexp>
</target>
</project>