Improve build.

This commit is contained in:
Christian P. MOMON 2013-06-25 14:29:44 +02:00
parent 361ca4cbf8
commit 507324c6b4

View file

@ -1,27 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<project default="dist" name="Create Jar for Project devinsy-utils"> <project default="dist" name="devinsy-utils">
<!--ANT 1.7 is required --> <!--ANT 1.7 is required -->
<property file="build.properties"/> <property file="build.properties" />
<property name="build.dir" value="${basedir}/build" /> <property name="build.dir" value="${basedir}/build" />
<property name="build.src" value="${basedir}/src" /> <property name="build.src" value="${basedir}/src" />
<property name="build.classes" value="${build.dir}/classes" /> <property name="build.classes" value="${build.dir}/classes" />
<property name="build.javadoc" value="${build.dir}/javadoc" />
<property name="test.src" value="${basedir}/test" /> <property name="test.src" value="${basedir}/test" />
<property name="test.classes" value="${build.dir}/test-classes" /> <property name="test.classes" value="${build.dir}/test-classes" />
<property name="dist.dir" value="${basedir}/dist" /> <property name="debug" value="on" />
<property name="debug" value="on"/>
<path id="build.classpath"> <path id="build.classpath">
<fileset dir="lib" includes="**/*.jar"/> <fileset dir="lib" includes="**/*.jar" />
</path> </path>
<path id="test.classpath.compile"> <path id="test.classpath.compile">
<path refid="build.classpath"/> <path refid="build.classpath" />
<pathelement path="${build.classes}"/> <pathelement path="${build.classes}" />
</path> </path>
<path id="test.classpath.run"> <path id="test.classpath.run">
<path refid="test.classpath.compile"/> <path refid="test.classpath.compile" />
<pathelement path="${test.classes}"/> <pathelement path="${test.classes}" />
</path> </path>
@ -32,67 +32,97 @@
<!-- ***** Clean ***** --> <!-- ***** Clean ***** -->
<target name="clean" description="Clean temporary directories"> <target name="clean" description="Clean temporary directories">
<delete dir="${build.dir}"/> <delete dir="${build.dir}" />
</target> </target>
<!-- ***** Compile ***** --> <!-- ***** Compile ***** -->
<target name="compile" description="Compile main code"> <target name="compile" description="Compile main code">
<mkdir dir="${build.dir}/classes"/> <mkdir dir="${build.dir}/classes" />
<javac srcdir="${build.src}" destdir="${build.classes}" debug="${debug}" deprecation="on" includeantruntime="false"> <javac srcdir="${build.src}" destdir="${build.classes}" debug="${debug}" deprecation="on" includeantruntime="false">
<classpath refid="test.classpath.compile"/> <classpath refid="test.classpath.compile" />
</javac> </javac>
</target> </target>
<!-- ***** Compile test ***** --> <!-- ***** Compile test ***** -->
<target name="compile-test" description="Compile test code"> <target name="compile-test" description="Compile test code">
<mkdir dir="${test.classes}"/> <mkdir dir="${test.classes}" />
<javac srcdir="${test.src}" destdir="${test.classes}" debug="${debug}" deprecation="on" includeantruntime="false"> <javac srcdir="${test.src}" destdir="${test.classes}" debug="${debug}" deprecation="on" includeantruntime="false">
<classpath refid="test.classpath.compile"/> <classpath refid="test.classpath.compile" />
</javac> </javac>
</target> </target>
<!-- ***** Test ***** --> <!-- ***** Test ***** -->
<target name="test" description="Run unit tests" depends="clean,compile,compile-test"> <target name="test" description="Run unit tests" depends="clean,compile,compile-test">
<mkdir dir="${build.dir}/test-reports"/> <mkdir dir="${build.dir}/test-reports" />
<junit printsummary="yes" haltonfailure="yes"> <junit printsummary="yes" haltonfailure="no">
<classpath refid="test.classpath.run"/> <classpath refid="test.classpath.run" />
<formatter type="plain" usefile="true" /> <formatter type="plain" usefile="true" />
<batchtest fork="yes" todir="${build.dir}/test-reports/"> <batchtest fork="yes" todir="${build.dir}/test-reports/">
<fileset dir="test"> <fileset dir="test">
<include name="**/*Test.java"/> <include name="**/*Test.java" />
</fileset> </fileset>
</batchtest> </batchtest>
</junit> </junit>
</target> </target>
<!-- ***** JavaDoc ***** -->
<target name="javadoc" description="Javadoc construction">
<javadoc sourcepath="${build.src}" destdir="${build.javadoc}">
<classpath>
<fileset dir="lib" includes="**/*.jar" />
</classpath>
</javadoc>
</target>
<!-- ***** Dist ***** --> <!-- ***** Dist ***** -->
<target name="dist" description="Build distribution" depends="clean,compile"> <target name="dist" description="Build distribution" depends="clean,compile,javadoc">
<!-- --> <!-- -->
<mkdir dir="${dist.dir}"/> <buildnumber file="build.num" description="Id of the build" />
<buildnumber file="build.num" description="Id of the build"/> <!-- AUTOMATIC MANAGEMENT --> <!-- AUTOMATIC MANAGEMENT -->
<property name="dist.version" value="${product.revision.major}.${product.revision.minor}.${build.number}" /> <property name="dist.version" value="${product.revision.major}.${product.revision.minor}.${build.number}" />
<property name="dist.name" value="${product.name}-${dist.version}" /> <property name="dist.name" value="${product.name}-${dist.version}" />
<property name="dist.dir" value="${basedir}/dist/${dist.name}" />
<!-- Package compiled --> <!-- -->
<mkdir dir="${dist.dir}" />
<!-- -->
<copy file="LICENSE" todir="${dist.dir}/" overwrite="true" />
<!-- Package main -->
<property name="dist.jar" value="${dist.dir}/${dist.name}.jar" /> <property name="dist.jar" value="${dist.dir}/${dist.name}.jar" />
<tstamp> <tstamp>
<format property="dist.time" pattern="dd/MM/yyyy HH:mm:ss" /> <!-- TODAY --> <format property="dist.time" pattern="dd/MM/yyyy HH:mm:ss" />
<!-- TODAY -->
</tstamp> </tstamp>
<jar destfile="${dist.jar}" > <jar destfile="${dist.jar}">
<manifest> <manifest>
<attribute name="Built-By" value="${user.name} using ant"/> <attribute name="Built-By" value="${user.name} using ant" />
<attribute name="Built-Date" value="${dist.time}"/> <attribute name="Built-Date" value="${dist.time}" />
</manifest> </manifest>
<fileset dir="${basedir}/build" excludes="TestTree/**" /> <fileset dir="${build.classes}" />
<zipfileset dir="${basedir}/" includes="LICENSE"/> <zipfileset dir="${basedir}/" includes="LICENSE" />
</jar> </jar>
<!-- Package sources --> <!-- Package sources -->
<property name="dist.srczip" value="${basedir}/dist/${dist.name}-sources.zip" /> <property name="dist.srczip" value="${dist.dir}/${dist.name}-sources.zip" />
<zip destfile="${dist.srczip}" update="true" preserve0permissions="true"> <zip destfile="${dist.srczip}" update="true" preserve0permissions="true">
<fileset dir="${basedir}/src"/> <fileset dir="${basedir}/src" />
<zipfileset dir="${basedir}/" includes="LICENSE"/> <zipfileset dir="${basedir}/" includes="LICENSE" />
</zip> </zip>
<!-- Package Javadoc -->
<property name="dist.javadoc.zip" value="${dist.dir}/${dist.name}-javadoc.zip" />
<zip destfile="${dist.javadoc.zip}" update="true" preserve0permissions="true">
<fileset dir="${build.javadoc}" />
<zipfileset dir="${basedir}/" includes="LICENSE" />
</zip>
<!-- Package lib -->
<copy todir="${dist.dir}/lib" overwrite="true">
<fileset dir="lib" />
</copy>
</target> </target>
</project> </project>