<?xml version="1.0" encoding="UTF-8"?>
<project name="com.nokia.s60tools.metadataeditor" default="cc" basedir=".">
<property name="basews" value="${ws}"/>
<property name="baseos" value="${os}"/>
<property name="basearch" value="${arch}"/>
<property name="basenl" value="${nl}"/>
<!-- Compiler settings -->
<property name="javacFailOnError" value="true"/>
<property name="javacDebugInfo" value="on"/>
<property name="javacVerbose" value="false"/>
<property name="logExtension" value=".log"/>
<property name="compilerArg" value=""/>
<property name="javacSource" value="5"/>
<property name="javacTarget" value="5"/>
<property name="bootclasspath" refid="path_bootclasspath"/>
<property name="bundleJavacSource" value="${javacSource}"/>
<property name="bundleJavacTarget" value="${javacTarget}"/>
<property name="bundleBootClasspath" value="${bootclasspath}"/>
<property name="help.project.name" value="${ant.project.name}.doc.user"/>
<property name="feature.project.folder" location="../com.nokia.carbide.extensions.metadataeditor"/>
<property name="feature.name" value="MetadataEditor"/>
<property name="jar.filename" value="${ant.project.name}.jar"/>
<property name="help.jar.filename" value="${help.project.name}.jar"/>
<!-- Folder definitions -->
<property name="carbide.plugins" location="c:/Carbide_internal/plugins"/>
<property name="test.folder" location="../com.nokia.s60tools.metadataeditor.tests"/>
<property name="dist.folder" location="c:/Carbide_internal/plugins"/>
<property name="reports.folder" location="reports"/>
<property name="reports.emma" location="${reports.folder}/emma"/>
<property name="instr.folder" location="instr"/>
<!-- EMMA configuration -->
<path id="emma.lib" >
<pathelement location="${ant.home}/lib/emma.jar" />
<pathelement location="${ant.home}/lib/emma_ant.jar" />
</path>
<taskdef resource="emma_ant.properties" classpathref="emma.lib" />
<!-- PMD configuration -->
<path id="pmd.lib" >
<pathelement location="${ant.home}/lib/pmd-4.2.jar" />
<pathelement location="${ant.home}/lib/asm-3.1.jar" />
<pathelement location="${ant.home}/lib/jaxen-1.1.1.jar" />
</path>
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd.lib" />
<path id="path_bootclasspath">
<fileset dir="${java.home}/lib">
<include name="*.jar"/>
</fileset>
</path>
<path id="build_classpath">
<path refid="carbide_classpath"/>
</path>
<path id="carbide_classpath">
<fileset dir="${carbide.plugins}" includes="**/*.jar" />
</path>
<target name="properties" if="eclipse.running">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
</target>
<!-- Initialization -->
<target name="init" depends="properties">
<condition property="pluginTemp" value="${buildTempFolder}/plugins">
<isset property="buildTempFolder"/>
</condition>
<property name="pluginTemp" value="${basedir}"/>
<condition property="build.result.folder" value="${pluginTemp}/${ant.project.name}">
<isset property="buildTempFolder"/>
</condition>
<property name="build.result.folder" value="${basedir}"/>
<property name="temp.folder" value="${basedir}/temp.folder"/>
<property name="plugin.destination" value="${basedir}"/>
<property name="jar.filename" value="${ant.project.name}.jar"/>
<delete dir="${temp.folder}"/>
<mkdir dir="${temp.folder}"/>
<delete dir="${temp.folder}/bin"/>
<mkdir dir="${temp.folder}/bin"/>
<delete dir="${reports.folder}"/>
<mkdir dir="${reports.folder}"/>
<exec executable="svn" dir="../.">
<arg line="up"/>
</exec>
</target>
<!-- Build target -->
<target name="build" depends="init" description="Build the source">
<!-- Build the source -->
<javac destdir="${temp.folder}/bin" failonerror="${javacFailOnError}" verbose="${javacVerbose}" debug="${javacDebugInfo}" includeAntRuntime="no" bootclasspath="${bundleBootClasspath}" source="${bundleJavacSource}" target="${bundleJavacTarget}">
<compilerarg line="${compilerArg}" compiler="${build.compiler}"/>
<classpath refid="build_classpath" />
<src path="src/" />
<compilerarg value="@${basedir}/javaCompiler...args" compiler="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<compilerarg line="-log '${temp.folder}/bin${logExtension}'" compiler="org.eclipse.jdt.core.JDTCompilerAdapter"/>
</javac>
<!-- Copy necessary resources -->
<copy todir="${temp.folder}/bin" failonerror="true" overwrite="false">
<fileset dir="src/" excludes="**/*.java, **/package.htm*" />
</copy>
<!-- Create build result folder -->
<mkdir dir="${build.result.folder}"/>
<!-- Copy classes from the temporary folder to bin -->
<copy todir="${build.result.folder}" failonerror="true" overwrite="false">
<fileset dir="${temp.folder}/bin" />
</copy>
<!-- Delete temporary folder -->
<delete dir="${temp.folder}/bin"/>
</target>
<!-- Clean target -->
<target name="clean" description="Clean" depends="clean-test">
<delete dir="${build.result.folder}" />
<delete>
<fileset dir="${dist.folder}" includes="*.jar"/>
</delete>
</target>
<!-- Analyze target -->
<target name="analyze">
<!-- PMD -->
<pmd>
<!-- Rules -->
<ruleset>basic</ruleset>
<ruleset>codesize</ruleset>
<ruleset>coupling</ruleset>
<ruleset>design</ruleset>
<ruleset>strictexception</ruleset>
<ruleset>strings</ruleset>
<ruleset>sunsecure</ruleset>
<!-- XML output -->
<formatter type="xml" toFile="${reports.folder}/report.pmd.xml"/>
<!-- Files to analyze -->
<fileset dir="src/">
<include name="**/*.java"/>
</fileset>
</pmd>
</target>
<!-- Instrumentation target, depends on JAR -->
<target name="instr" depends="jar">
<!-- Instrument the source code -->
<emma>
<instr instrpath="${dist.folder}/${jar.filename}" destdir="${instr.folder}" metadatafile="${reports.emma}/metadata.emma" merge="true"/>
</emma>
</target>
<!-- JAR target -->
<target name="jar" depends="build" description="Create JAR">
<delete dir="binaries"/>
<mkdir dir="binaries"/>
<copy todir="binaries" failonerror="true" overwrite="false">
<fileset dir="${build.result.folder}" />
</copy>
<!-- Delete temporary folder -->
<delete dir="binaries/src"/>
<delete dir="binaries/reports"/>
<delete dir="binaries/instr"/>
<delete dir="binaries/temp.folder"/>
<delete dir="binaries/bin"/>
<!--<delete dir="binaries/bin"/>-->
<delete file="binaries/ccbuild.xml"/>
<delete file="binaries/ccbuild3.xml"/>
<delete file="binaries/ReleaseNotes.txt"/>
<delete file="binaries/.classpath"/>
<delete file="binaries/build.properties"/>
<delete file="binaries/ccbuild.xml.bak"/>
<delete file="binaries/.project"/>
<!-- Create JAR -->
<zip destfile="${dist.folder}/${jar.filename}" basedir="binaries" />
</target>
<!-- Clean tests target -->
<target name="clean-test" description="Clean test">
<delete>
<fileset dir="${test.folder}" includes="**/*.class" />
</delete>
<delete dir="${instr.folder}"/>
<delete dir="${reports.folder}"/>
</target>
<!-- Feature target -->
<target name="feature" depends="jar" description="Create feature">
<property name="feature.folder" location="${dist.folder}/feature"/>
<mkdir dir="${feature.folder}"/>
<mkdir dir="${feature.folder}/plugins"/>
<mkdir dir="${feature.folder}/features"/>
<!-- Create help JAR -->
<jar destfile="${carbide.plugins}/${help.jar.filename}" basedir="../${help.project.name}" excludes="src/,.*"/>
<!-- Copy feature stuff to the temp folder -->
<copy todir="${feature.folder}/features" file="${feature.project.folder}/feature.xml"/>
<copy todir="${feature.folder}/features" file="${feature.project.folder}/license.txt"/>
<!-- Copy the actual plug-in to the temp folder -->
<copy todir="${feature.folder}/plugins" file="${dist.folder}/${jar.filename}"/>
<!-- Create the feature zip -->
<zip destfile="${dist.folder}/${feature.name}.zip" basedir="${feature.folder}"/>
<deltree dir="${feature.folder}"/>
<!-- Nightly build -->
<tstamp>
<format property="timestamp" pattern="dd-MM-yyyy" />
</tstamp>
<copy tofile="../../nightly_builds/${feature.name}/${feature.name}-${timestamp}.zip" file="${dist.folder}/${feature.name}.zip"/>
</target>
<target name="cc" depends="jar, analyze, feature" description="Build, instrument, run unit tests and analyze code"/>
</project>