Advertisement
Guest User

build.xml

a guest
Mar 15th, 2013
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 10.69 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project name="OsmAnd" default="help">
  3.  
  4.     <property file="local.properties" />
  5.     <property file="ant.properties" />
  6.     <loadproperties srcFile="project.properties" />
  7.  
  8.     <!-- quick check on sdk.dir -->
  9.     <fail
  10.            message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
  11.            unless="sdk.dir"
  12.    />
  13.  
  14.     <property name="use.dir" value="../../jni/java" />
  15.     <property name="use.absolute.dir" location="${use.dir}" />
  16.     <property name="raw.absolute.dir" location="raw" />
  17.     <property name="base.dir" location="." />
  18.  
  19.  
  20.     <!-- Puts the project's resources into the output package file
  21.         This actually can create multiple resource package in case
  22.         Some custom apk with specific configuration have been
  23.         declared in default.properties.
  24.         -->
  25.     <target name="-package-resources" depends="-crunch">
  26.         <!-- only package resources if *not* a library project -->
  27.         <do-only-if-not-library elseText="Library project: do not package resources...">
  28.             <aapt executable="${aapt}" command="package" versioncode="${version.code}" versionname="${version.name}" debug="${build.is.packaging.debug}" manifest="${out.manifest.abs.file}" assets="${asset.absolute.dir}" androidjar="${project.target.android.jar}" apkfolder="${out.absolute.dir}" nocrunch="${build.packaging.nocrunch}" resourcefilename="${resource.package.file.name}" resourcefilter="${aapt.resource.filter}" libraryResFolderPathRefid="project.library.res.folder.path" libraryPackagesRefid="project.library.packages" previousBuildType="${build.last.target}" buildType="${build.target}" ignoreAssets="${aapt.ignore.assets}">
  29.                 <res path="${out.res.absolute.dir}" />
  30.                 <res path="${resource.absolute.dir}" />
  31.                 <!-- <nocompress /> forces no compression on any files in assets or res/raw -->
  32.                 <!-- <nocompress extension="xml" /> forces no compression on specific file extensions in assets and res/raw -->
  33.             </aapt>
  34.         </do-only-if-not-library>
  35.  
  36.         <!-- osmchange -->
  37.         <echo>Packaging aditional OsmAnd resources and assets... to ${out.packaged.file} from ${raw.absolute.dir}</echo>
  38.         <exec executable="${aapt}">
  39.             <!-- failonerror="true"> -->
  40.             <arg value="package" />
  41.             <arg value="-u" />
  42.             <arg value="-F" />
  43.             <arg value="${out.absolute.dir}/${resource.package.file.name}" />
  44.             <arg value="${raw.absolute.dir}" />
  45.         </exec>
  46.         <!-- osmchange -->
  47.     </target>
  48.  
  49.     <!-- Extra target -->
  50.     <target name="-pre-build" depends="fix_apostrophe_issues">
  51.         <delete dir="${raw.absolute.dir}" verbose="${verbose}" />
  52.         <mkdir dir="${raw.absolute.dir}/classes" />
  53.         <copy todir="${raw.absolute.dir}">
  54.             <fileset dir="${use.absolute.dir}">
  55.                 <exclude name="**/*.java" />
  56.             </fileset>
  57.         </copy>
  58.         <if>
  59.             <condition>
  60.                 <isset property="versionFeatures" />
  61.             </condition>
  62.             <then>
  63.                 <replaceregexp file="res/values/no_translate.xml" match='versionFeatures"&gt;(.*)&lt;' replace='versionFeatures"&gt;${versionFeatures}&lt;' byline="true" />
  64.             </then>
  65.         </if>
  66.         <if>
  67.             <condition>
  68.                 <isset property="net.osmand" />
  69.             </condition>
  70.             <then>
  71.                 <replaceregexp file="AndroidManifest.xml" match='"@drawable/icon"' replace='"@drawable/icon_free"' byline="true" />
  72.                 <replaceregexp file="AndroidManifest.xml" match='package="net.osmand.plus"' replace='package="net.osmand"' byline="true" />
  73.                 <replaceregexp file="AndroidManifest.xml" match='android:process="net.osmand.plus"' replace='android:process="net.osmand"' byline="true" />
  74.                 <replaceregexp file="res/values/no_translate.xml" match='"app_name"&gt;(.*)&lt;' replace='"app_name"&gt;OsmAnd&lt;' byline="true" />
  75.                 <replaceregexp file="res/layout/search_address.xml" match='net.osmand.plus' replace='net.osmand' byline="true" />
  76.                 <replaceregexp file="res/layout/navigate_point.xml" match='net.osmand.plus' replace='net.osmand' byline="true" />
  77.             </then>
  78.             <else>
  79.                 <replaceregexp file="AndroidManifest.xml" match='"@drawable/icon_free"' replace='"@drawable/icon"' byline="true" />
  80.                 <replaceregexp file="AndroidManifest.xml" match='package="net.osmand"' replace='package="net.osmand.plus"' byline="true" />
  81.                 <replaceregexp file="AndroidManifest.xml" match='android:process="net.osmand"' replace='android:process="net.osmand.plus"' byline="true" />
  82.             </else>
  83.         </if>
  84.         <if>
  85.             <condition>
  86.                 <isset property="net.osmand.plus" />
  87.             </condition>
  88.             <then>
  89.                 <replaceregexp file="res/values/no_translate.xml" match='"app_name"&gt;(.*)&lt;' replace='"app_name"&gt;OsmAnd+&lt;' byline="true" />
  90.             </then>
  91.         </if>
  92.         <if>
  93.             <condition>
  94.                 <isset property="build.version.code" />
  95.             </condition>
  96.             <then>
  97.                 <replaceregexp file="AndroidManifest.xml" match='android:versionCode="(.*)"' replace='android:versionCode="${build.version.code}"' byline="true" />
  98.             </then>
  99.         </if>
  100.         <if>
  101.             <condition>
  102.                 <isset property="build.version" />
  103.             </condition>
  104.             <then>
  105.                 <replaceregexp file="res/values/no_translate.xml" match='"app_version"&gt;(.*)&lt;' replace='"app_version"&gt;${build.version}&lt;' byline="true" />
  106.             </then>
  107.         </if>
  108.  
  109.     </target>
  110.  
  111.     <!-- Compiles this project's .java files into .class files. -->
  112.     <target name="-compile" depends="-build-setup, -pre-build, -code-gen, -pre-compile">
  113.         <!-- osmchange : Osmand plus support -->
  114.         <mkdir dir="${gen.absolute.dir}/net/osmand/plus"/>
  115.         <copy todir="${gen.absolute.dir}/net/osmand/plus">
  116.             <fileset dir="${gen.absolute.dir}/net/osmand">
  117.                 <include name="R.java" />
  118.             </fileset>
  119.         </copy>
  120.         <replaceregexp file="${gen.absolute.dir}/net/osmand/plus/R.java" match='package net.osmand;' replace='package net.osmand.plus;' byline="true" />
  121.         <!-- osmchange : Osmand plus support -->
  122.  
  123.         <do-only-if-manifest-hasCode elseText="hasCode = false. Skipping...">
  124.             <!-- merge the project's own classpath and the tested project's classpath -->
  125.             <path id="project.javac.classpath">
  126.                 <path refid="project.all.jars.path" />
  127.                 <path refid="tested.project.classpath" />
  128.             </path>
  129.             <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}">
  130.                 <src path="${source.absolute.dir}" />
  131.                 <src path="${gen.absolute.dir}" />
  132.                 <compilerarg line="${java.compilerargs}" />
  133.                 <!-- osmchange -->
  134.                 <src path="${use.absolute.dir}" />
  135.                 <exclude name="**/PlatformUtil.java" />
  136.                 <!-- osmchange -->
  137.             </javac>
  138.  
  139.             <!-- if the project is instrumented, intrument the classes -->
  140.             <if condition="${build.is.instrumented}">
  141.                 <then>
  142.                     <echo level="info">Instrumenting classes from ${out.absolute.dir}/classes...</echo>
  143.  
  144.                     <!-- build the filter to remove R, Manifest, BuildConfig -->
  145.                     <getemmafilter appPackage="${project.app.package}" libraryPackagesRefId="project.library.packages" filterOut="emma.default.filter" />
  146.  
  147.                     <!-- define where the .em file is going. This may have been
  148.                                  setup already if this is a library -->
  149.                     <property name="emma.coverage.absolute.file" location="${out.absolute.dir}/coverage.em" />
  150.  
  151.                     <!-- It only instruments class files, not any external libs -->
  152.                     <emma enabled="true">
  153.                         <instr verbosity="${verbosity}" mode="overwrite" instrpath="${out.absolute.dir}/classes" outdir="${out.absolute.dir}/classes" metadatafile="${emma.coverage.absolute.file}">
  154.                             <filter excludes="${emma.default.filter}" />
  155.                             <filter value="${emma.filter}" />
  156.                         </instr>
  157.                     </emma>
  158.                 </then>
  159.             </if>
  160.  
  161.             <!-- if the project is a library then we generate a jar file -->
  162.             <if condition="${project.is.library}">
  163.                 <then>
  164.                     <echo level="info">Creating library output jar file...</echo>
  165.                     <property name="out.library.jar.file" location="${out.absolute.dir}/classes.jar" />
  166.                     <if>
  167.                         <condition>
  168.                             <length string="${android.package.excludes}" trim="true" when="greater" length="0" />
  169.                         </condition>
  170.                         <then>
  171.                             <echo level="info">Custom jar packaging exclusion: ${android.package.excludes}</echo>
  172.                         </then>
  173.                     </if>
  174.  
  175.                     <propertybyreplace name="project.app.package.path" input="${project.app.package}" replace="." with="/" />
  176.  
  177.                     <jar destfile="${out.library.jar.file}">
  178.                         <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" />
  179.                         <fileset dir="${source.absolute.dir}" excludes="**/*.java ${android.package.excludes}" />
  180.                     </jar>
  181.                 </then>
  182.             </if>
  183.  
  184.         </do-only-if-manifest-hasCode>
  185.     </target>
  186.  
  187.     <path id="lib.path">
  188.         <fileset dir="ant-lib" includes="*.jar" />
  189.     </path>
  190.  
  191.     <!-- Import the actual build file.
  192.  
  193.         To customize existing targets, there are two options:
  194.         - Customize only one target:
  195.             - copy/paste the target into this file, *before* the
  196.               <import> task.
  197.             - customize it to your needs.
  198.         - Customize the whole content of build.xml
  199.             - copy/paste the content of the rules files (minus the top node)
  200.               into this file, replacing the <import> task.
  201.             - customize to your needs.
  202.  
  203.         ***********************
  204.         ****** IMPORTANT ******
  205.         ***********************
  206.         In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
  207.         in order to avoid having your file be overridden by tools such as "android update project"
  208.    -->
  209.     <!-- version-tag: custom -->
  210.     <import file="${sdk.dir}/tools/ant/build.xml" />
  211.  
  212.     <taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask" classpathref="lib.path" />
  213.  
  214.     <target name="cpd" description="Search for cut-and-pasted code">
  215.         <property name="cpd.report.xml" location="cpd.xml"/>
  216.         <cpd minimumTokenCount="100" format="xml" outputFile="${cpd.report.xml}"
  217.            ignoreLiterals="true" ignoreIdentifiers="true">
  218.             <fileset dir="${source.absolute.dir}" includes="**/*.java"/>
  219.         </cpd>
  220.     </target>
  221.    
  222.     <target name="fix_apostrophe_issues">
  223.         <replace token="version='1.0'" value="version=&quot;1.0&quot;">
  224.             <fileset dir="res" includes="**/strings.xml"/>
  225.         </replace>
  226.         <replace token="encoding='utf-8'" value="encoding=&quot;utf-8&quot;">
  227.             <fileset dir="res" includes="**/strings.xml"/>
  228.         </replace>
  229.        
  230.         <replaceregexp  match="([^\\])'" replace="\1\\\\'" flags="-g" byline="off">
  231.             <fileset dir="res" includes="**/strings.xml"/>
  232.         </replaceregexp>
  233.     </target>
  234.  
  235. </project>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement