frameworkplugins/com.nokia.s60tools.util/ccbuild.xml
author dpodwall
Tue, 12 Jan 2010 13:17:53 -0600
changeset 0 61163b28edca
permissions -rw-r--r--
initial EPL conversion

<?xml version="1.0" encoding="UTF-8"?>
<project name="com.nokia.s60tools.util" default="cc" basedir=".">

	<target name="cc" depends="build, instr, analyze, test" description="Build, instrument, run unit tests and analyze code"/>

	<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="feature.name" value="Framework"/>
	
	<!-- Folder definitions -->
	<property name="carbide.sym.folder" location="c:/Carbide_SymSee/plugins"/>
	<property name="carbide.idl.folder" location="c:/Carbide_IDL/plugins"/>
	<property name="carbide.adt.folder" location="c:/Carbide_ADT/plugins"/>
	
	<property name="test.folder" location="../com.nokia.s60tools.util.tests"/>
	
	<property name="binaries.folder" location="../${feature.name}.binaries"/>
	<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.idl.folder}" 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="${reports.folder}"/>
		<mkdir dir="${reports.folder}"/>
		
		<delete dir="${instr.folder}"/>
		<mkdir dir="${instr.folder}"/>
		
		<delete dir="../plugins"/>
		<mkdir dir="../plugins"/>
		
		<delete dir="${build.result.folder}/com"/>
		
		<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="" 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="" failonerror="true" overwrite="false">
			<fileset dir="src/" excludes="**/*.java, **/package.htm*" />
		</copy>

		<zip destfile="../plugins/${jar.filename}">
				<fileset dir="${build.result.folder}">
							<include name="com/**"/>
					    <include name="META-INF/**"/>
					    <include name="about.html"/>
				</fileset>
		</zip>
	
		<!-- Create build result folder -->
		<mkdir dir="${build.result.folder}"/>

	</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>
			<ruleset>unusedcode</ruleset>
			<ruleset>junit</ruleset>
			
			
			<!-- XML output -->
			<formatter type="xml" toFile="${reports.folder}/report.pmd.xml"/>
			
			<!-- Files to analyze -->
			<fileset dir="src/">
				<include name="**/*.java"/>
			</fileset>
			<fileset dir="${test.folder}/src/">
				<include name="**/*.java"/>
			</fileset>
		</pmd>
	</target>
	
	<!-- Instrumentation target, depends on JAR -->
	<target name="instr" depends="build">
		<!-- Instrument the source code -->
		<emma>
			<instr instrpath="../plugins/${jar.filename}" destdir="${instr.folder}" metadatafile="${reports.emma}/metadata.emma" merge="true"/>
		</emma>
	</target>
		
	
	<!-- Test target, depends on instrumentation and analyze -->
	<target name="test" depends="instr" description="Run unit tests">
    	<!-- Test classpath -->
    	<path id="test_classpath">
			<!-- Test classes -->
			<pathelement location="${test.folder}/src"/>
			
			<!-- Instrumented class files -->
		   	<pathelement location="${instr.folder}"/>
		   	
		   	<!-- EMMA -->
		   	<pathelement path="${ant.home}/lib/emma.jar"/>
		   	
		   	<fileset dir="${carbide.adt.folder}" includes="**/*.jar" />
		</path>
  
  <!-- Compile the tests -->
     	<javac srcdir="${test.folder}" verbose="${javacVerbose}">
      		<classpath refid="test_classpath"/>
	    </javac>

		<!-- Run JUnit -->
	    <junit printsummary="yes" fork="yes" haltonfailure="no">
	      	<classpath refid="test_classpath" />
	      	
	      	<!-- Plain format and XML -->
	      	<formatter type="plain" />
	      	<formatter type="xml" />
			
			<!-- Instrumentation arguments to JVM -->
			<jvmarg value="-Demma.coverage.out.file=${reports.emma}/coverage.emma" />
	    <jvmarg value="-Demma.coverage.out.merge=true" />
	    <jvmarg value="-D_S60TOOLS_WS_PATH=C:\hudson\jobs\Framework_Util\workspace" />
	    

			<!-- Test classes -->
	      	<test name="com.nokia.s60tools.util.tests.AllPureJUnitTests" todir="${reports.folder}"/> 	
	    </junit>
	    
	    <!-- Create EMMA report -->
	    <emma>
	    	<report sourcepath="src/" >
            	<fileset dir="${reports.emma}" >
                	<include name="*.emma" />
            	</fileset>
            	<xml outfile="${reports.emma}/coverage.xml" />
        	</report>
	    </emma>
	</target>

	
	
</project>