Data Storm Code
Status: Beta
Brought to you by:
kbg
added | /trunk/build.xml |
--- a +++ b/trunk/build.xml @@ -0,0 +1,348 @@ +<project name="Data Storm" default="-compile" basedir="."> + <!-- The general idea is to copy the files needed to a temp directory and compile in this one. + This way we can easily select the files of interest, instrument code as needed, etc. --> + <property name="distro.name" value="DataStorm" /> + <property name="distro.version" value="1.0.00beta" /> + <property name="distro.dir" value="distro" /> + + <property name="dir.src" value="src/" /> + <property name="dir.tmp_src" value="tmp_src/" /> + <property name="dir.test_src" value="test/" /> + <property name="dir.build" value="build/" /> + <property name="dir.lib" value="lib/" /> + <property name="dir.javadoc" value="web/javadoc/" /> + <property name="compile.src_version" value="4" /> + + <path id="classpath"> + <fileset dir="${dir.lib}"> + <include name="**/*.jar"/> + </fileset> + </path> + + + <target name="-init"> + <tstamp> + <format property="TODAY" pattern="yyyy-MM-dd HH:mm:ss" /> + </tstamp> + <buildnumber file="build.num"/> + + <echo message="${TODAY} build ${build.number}"/> + <mkdir dir="${distro.dir}"/> + + <delete dir="${dir.build}"/> + <mkdir dir="${dir.build}"/> + <delete dir="${dir.tmp_src}"/> + <mkdir dir="${dir.tmp_src}"/> + </target> + + + <target name="-init_distro" depends="-init"> + <!-- copy all source files --> + <copy todir="${dir.tmp_src}" verbose="true"> + <fileset dir="${dir.src}"> + <include name="**/*"/> + </fileset> + </copy> + <copy todir="${dir.build}" > + <fileset dir="img/"> + <include name="*.*"/> + </fileset> + </copy> + + <!-- compiler options --> + <property name="compile.optimize" value="true" /> + <property name="compile.debug" value="false" /> + </target> + + <target name="-init_test" depends="-init"> + <!-- copy all source files --> + <copy todir="${dir.tmp_src}"> + <fileset dir="src"> + <include name="**/*"/> + </fileset> + </copy> + + <!-- compiler options --> + <property name="compile.optimize" value="false" /> + <property name="compile.debug" value="true" /> + </target> + + + <target name="-compile"> + <echo message="-compile"/> + <echo message="${compile.src_version}"/> + <echo message="compile.optimize" /> + <echo message="compile.debug" /> + <javac verbose="false" + fork="true" + srcdir="${dir.tmp_src}" + destdir="${dir.build}" + classpathref="classpath" + /> + </target> + + + <target name="-javadoc" depends="-compile"> + <delete dir="${dir.javadoc}"/> + <mkdir dir="${dir.javadoc}"/> + + <javadoc + access="public" + destdir="${dir.javadoc}" + author="true" + version="true" + use="true" + windowtitle="SQLOrm" + classpathref="classpath" + > + + <fileset dir="${dir.tmp_src}" defaultexcludes="true"> + <include name="**/*.java"/> + </fileset> + + <link href="http://java.sun.com/j2se/1.5.0/docs/api/"/> + </javadoc> + </target> + + + + <target name="-compile_tests"> + <description>copy only the test files after src files have been compiled and instrumented</description> + <!-- copy also test code --> + <copy todir="${dir.tmp_src}" verbose="false"> + <fileset dir="${dir.test_src}"> + <include name="**/*"/> + </fileset> + </copy> + + <antcall target="-compile"/> + + </target> + + + <target name="testcoverage" depends="-init_test" description="Make the test coverage"> + <property name="dir.coveragereport" value="${basedir}/web/emmareports/" /> <!-- directory which emma coverage reports will be written to --> + <mkdir dir="${dir.coveragereport}"/> + <delete file="${dir.coveragereport}/coverage.emma" /> + <delete file="${dir.coveragereport}/metadata.emma" /> + <property name="emma.dir" value="${dir.lib}" /> <!-- directory that contains emma.jar and emma_ant.jar --> + + <!-- Set emma.lib to refer to the list of EMMA jar files --> + <path id="emma.lib" > + <fileset dir="${emma.dir}"> + <include name="**/*.jar"/> + </fileset> + </path> + + <!-- Load <emma> and <emmajava> custom tasks so that they can be used in ANT --> + <taskdef resource="emma_ant.properties" classpathref="emma.lib" /> + <property name="emma.enabled" value="true" /> + + + <!-- this property, if overriden via -Demma.filter=<list of filter specs> + on ANT's command line, will set the coverage filter; by default, + all classes found in 'emma.coverage.classes' pathref will be instrumented: + --> + <!-- must use filtering --> + <property name="emma.filter" value="org.*" /> + + <!-- compile files --> + <antcall target="-compile"/> + + + <!-- Define which classes will be reported in the coverage reports (by default, we will include all classes and assume --> + <!-- that your project's output folder is target/classes --> + <path id="emma.coverage.classes" > + <pathelement location="${dir.build}" /> + </path> + + <!-- EMMA INSTRUMENTATION --> + <!-- Instrument the classes, this takes the normal classes, and makes instrumented classes instead --> + <emma enabled="${emma.enabled}" > + <instr instrpathref="emma.coverage.classes" + metadatafile="${dir.coveragereport}/metadata.emma" + merge="true" + mode="overwrite" verbosity="verbose" + > + <!-- exclude classes with a "Test" in the name: --> + <filter excludes="*Test" /> + <filter value="${emma.filter}" /> + </instr> + </emma> + + <!-- before test run, copy test files and compile them --> + <antcall target="-compile_tests"/> + + <!-- run test --> + <junit haltonfailure="true" printsummary="true" fork="true" forkmode="once"> + <batchtest> + <fileset dir="${dir.build}" includes="**/*Test.class"/> + </batchtest> + <formatter type="brief" usefile="false" /> + <classpath> + <path refid="classpath" /> + <pathelement location="${dir.build}" /> + </classpath> + + <jvmarg value="-Demma.coverage.out.file=${dir.coveragereport}coverage.emma" /> + <jvmarg value="-Demma.coverage.out.merge=false" /> + </junit> + + + <!-- generate test coverage report --> + <!-- if enabled, generate coverage report(s): --> + <emma enabled="${emma.enabled}" verbosity="verbose"> + <report + sort="+name,+block,+method,+class" + metrics="method:80,block:80,line:80,class:100" + > + <sourcepath > + <dirset dir="${dir.tmp_src}" > + </dirset> + </sourcepath> + + <!-- collect all EMMA data dumps (metadata and runtime) + [this can be done via nested <fileset> fileset elements + or <file> elements pointing to a single file]: + --> + <fileset dir="${dir.coveragereport}" > + <include name="*.emma" /> + </fileset> + + <!-- for every type of report desired, configure a nested + element; various report parameters + can be inherited from the parent <report> + and individually overridden for each report type: + --> + <html outfile="${dir.coveragereport}/index.html" + depth="method" + columns="name,class,method,block,line" + /> + </report> + </emma> + + <antcall target="-post_clean"/> + </target> + + + + + + + + <target name="distro" depends="-init_distro, generateWeb" description="creates a distribution jar file"> + <antcall target="-javadoc"/> + + <delete file="${distro.dir}/${distro.name}-${distro.version}.zip" failonerror="false" /> + + <!-- make jar --> + <jar destfile="${distro.dir}/${distro.name}-${distro.version}.jar" + basedir="${dir.build}" + includes="**/*.class, *.png, *.gif" + update="true" + duplicate="fail" + > + <manifest> + <attribute name="Built-By" value="Kasper B. Graversen"/> + <attribute name="Implementation-Version" value="${distro.version}-build${build.number}"/> + <attribute name="Built-Date" value="${TODAY}"/> + </manifest> + </jar> + + <!-- zip source --> + <zip basedir="." destfile="${distro.dir}/${distro.name}-${distro.version}-source.zip" includes="src/**/*.*,test/**/*.*" compress="true"> + <zipfileset dir="." includes="LICENSE.txt"/> + </zip> + + + <!-- zip javadoc --> + <zip basedir="web/" destfile="${distro.dir}/${distro.name}-${distro.version}-javadoc.zip" includes="javadoc/**/*.*" compress="true"> + <zipfileset dir="." includes="LICENSE.txt"/> + </zip> + + <!-- make jar with src --> + <jar destfile="${distro.dir}/${distro.name}-with_src-${distro.version}.jar" + basedir="${dir.build}" + includes="**/*.class, *.png, *.gif" + update="true" + duplicate="fail" + > + <fileset dir="${dir.src}" > + <include name="**/*.java"/> + </fileset> + + <manifest> + <attribute name="Built-By" value="Kasper B. Graversen"/> + <attribute name="Implementation-Version" value="${distro.version}-build${build.number}"/> + <attribute name="Built-Date" value="${TODAY}"/> + </manifest> + </jar> + + <!-- zip javadoc+jar+src+jar_with_src --> + <zip basedir="${distro.dir}" destfile="${distro.dir}/${distro.name}-${distro.version}.zip" compress="true" excludes="*.*"> + <zipfileset dir="${distro.dir}" file="${distro.dir}/${distro.name}-${distro.version}.jar"/> + <zipfileset dir="${distro.dir}" file="${distro.dir}/${distro.name}-with_src-${distro.version}.jar"/> + <zipfileset dir="${distro.dir}" file="${distro.dir}/${distro.name}-${distro.version}-javadoc.zip"/> + <zipfileset dir="${distro.dir}" file="${distro.dir}/${distro.name}-${distro.version}-source.zip"/> + <zipfileset dir="." includes="LICENSE.txt"/> + </zip> + + <antcall target="-post_clean" /> + </target> + + + + <!-- clean up after build --> + <target name="-post_clean"> + <delete file="${distro.dir}/${distro.name}-${distro.version}-javadoc.zip" failonerror="true" /> + <delete file="${distro.dir}/${distro.name}-${distro.version}-source.zip" failonerror="true" /> + <delete file="${distro.dir}/${distro.name}-${distro.version}.jar" failonerror="true"/> + <delete file="${distro.dir}/${distro.name}-with_src-${distro.version}.jar" failonerror="true"/> + <delete dir="${dir.build}"/> + <delete dir="${dir.tmp_src}"/> + </target> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <!-- + - + - Webstuff + --> + <property name="dir.web.src" value="src_web/" /> <!-- source html --> + <property name="dir.web.build" value="web/" /> <!-- where the generated html goes --> + + <target name="generateWeb" description="copy files to another dir in order not to mess up the originals"> + <mkdir dir="${dir.web.build}" /> + <copy verbose="false" failonerror="true" todir="${dir.web.build}" overwrite="true"> + <fileset dir="${dir.web.src}" includes="**/*" excludes="**/*.properties"/> + </copy> + + <!-- replace them files --> + <replace replacefilterfile="${dir.web.src}web.properties" dir="${dir.web.build}" /> + </target> +</project> \ No newline at end of file