Created
September 3, 2009 18:58
-
-
Save mangar/180459 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project name="MyProject" default="all" basedir="."> | |
<description>export the project in the maven format</description> | |
<tstamp> | |
<format property="nowstamp" pattern="yyyyMMdd" locale="en" /> | |
<!-- <format property="nowstamp" pattern="yyyyMMdd-HHmmss" locale="en" /> --> | |
</tstamp> | |
<!-- set global properties for this build --> | |
<property name="src" location="src" /> | |
<property name="webapp" location="webapp" /> | |
<property name="dest" location="maven-build" /> | |
<property name="temp" location="${dest}/${nowstamp}/temp" /> | |
<property name="temp.src" location="${dest}/${nowstamp}/temp/src" /> | |
<property name="bin" location="${dest}/${nowstamp}/temp/bin" /> | |
<property name="lib" location="${dest}/${nowstamp}/temp/lib" /> | |
<property name="findbugs.report" location="${dest}/${nowstamp}/reports/findbugs" /> | |
<property name="test.report" location="${dest}/${nowstamp}/reports/test" /> | |
<property name="cobertura.report" location="${dest}/${nowstamp}/reports/cobertura" /> | |
<property name="cobertura.instr" location="${dest}/${nowstamp}/temp/bin-instr-cobertura" /> | |
<path id="lib.path"> | |
<fileset dir="${lib}"> | |
<include name="**/*.jar" /> | |
</fileset> | |
</path> | |
<path id="lib.path.test"> | |
<pathelement location="${bin}" /> | |
<path refid="lib.path" /> | |
</path> | |
<path id="bin"> | |
<pathelement path="${bin}" /> | |
</path> | |
<path id="bin.instr"> | |
<pathelement path="${coverage.instr}" /> | |
</path> | |
<target name="init"> | |
<mkdir dir="${dest}/${nowstamp}" /> | |
<!-- copying the source --> | |
<copy todir="${dest}/${nowstamp}/src"> | |
<fileset dir="${src}" /> | |
</copy> | |
<copy todir="${dest}/${nowstamp}/src/main/webapp"> | |
<fileset dir="${webapp}" excludes="**/*.jar" /> | |
</copy> | |
<copy file="pom.xml" todir="${dest}/${nowstamp}" /> | |
<!-- copying the libs.. --> | |
<mkdir dir="${lib}" /> | |
<copy todir="${lib}"> | |
<fileset dir="${webapp}/WEB-INF/lib" /> | |
</copy> | |
<copy todir="${lib}"> | |
<fileset dir="${webapp}/WEB-INF/lib/test" /> | |
</copy> | |
<delete dir="${lib}/test" /> | |
<mkdir dir="${bin}" /> | |
<copy todir="${temp.src}"> | |
<fileset dir="${dest}/${nowstamp}/src/main/java" /> | |
<fileset dir="${dest}/${nowstamp}/src/test/java" /> | |
</copy> | |
</target> | |
<target name="compile" depends="init"> | |
<javac debug="on" debuglevel="lines,source" encoding="8859_1" srcdir="${dest}/${nowstamp}/src/main/java" destdir="${bin}"> | |
<classpath refid="lib.path" /> | |
</javac> | |
<javac debug="on" debuglevel="lines,source" encoding="8859_1" srcdir="${dest}/${nowstamp}/src/test/java" destdir="${bin}"> | |
<classpath refid="lib.path" /> | |
</javac> | |
<path id="run.classpath"> | |
<pathelement location="${bin}" /> | |
</path> | |
</target> | |
<target name="instruments" depends="compile"> | |
<path id="cobertura.classpath"> | |
<path refid="lib.path" /> | |
</path> | |
<taskdef classpathref="cobertura.classpath" resource="tasks.properties" /> | |
<mkdir dir="${cobertura.instr}" /> | |
<delete file="cobertura.ser" /> | |
<cobertura-instrument todir="${cobertura.instr}" datafile="${basedir}/cobertura.ser"> | |
<fileset dir="${bin}"> | |
<include name="**/*.class" /> | |
<exclude name="**/*Test.class" /> | |
</fileset> | |
</cobertura-instrument> | |
<junit printsummary="true" showoutput="true" fork="true" haltonerror="false"> | |
<sysproperty key="net.sourceforge.cobertura.datafile" file="${basedir}/cobertura.ser" /> | |
<classpath location="${cobertura.instr}" /> | |
<classpath refid="lib.path.test" /> | |
<batchtest todir="${test.report}"> | |
<fileset dir="${bin}" includes="**/*Test.class" /> | |
</batchtest> | |
</junit> | |
<cobertura-report format="html" destdir="${cobertura.report}" srcdir="${temp.src}" datafile="${basedir}/cobertura.ser" /> | |
</target> | |
<target name="runtests" depends="compile"> | |
<mkdir dir="${test.report}" /> | |
<!-- run the tests... --> | |
<junit fork="yes" haltonfailure="no"> | |
<batchtest todir="${test.report}"> | |
<fileset dir="${bin}"> | |
<include name="**/*Test.class" /> | |
</fileset> | |
</batchtest> | |
<formatter type="xml" /> | |
<classpath refid="lib.path.test" /> | |
</junit> | |
<junitreport todir="${test.report}"> | |
<fileset dir="${test.report}"> | |
<include name="TEST-*.xml" /> | |
</fileset> | |
<report todir="${test.report}" /> | |
</junitreport> | |
</target> | |
<target name="findbugs" depends="compile"> | |
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"> | |
<classpath> | |
<fileset dir="${lib}"> | |
<include name="**/*.jar" /> | |
</fileset> | |
</classpath> | |
</taskdef> | |
<mkdir dir="${findbugs.report}" /> | |
<findbugs home="${lib}" output="html" failOnError="true" outputFile="${findbugs.report}/findbugs-report.html" jvmArgs="-Xms256m -Xmx800m"> | |
<class location="${bin}" /> | |
<auxClasspath refId="lib.path" /> | |
<sourcePath path="${temp.src}" /> | |
</findbugs> | |
</target> | |
<target name="all" depends="runtests, instruments, findbugs" description="generate the distribution"> | |
<!-- send to repository --> | |
</target> | |
<target name="dist" depends="all" description="generate the distribution"> | |
<delete dir="${temp}" /> | |
<!-- send to repository --> | |
</target> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment