Refactored build.

This commit is contained in:
Christian P. MOMON 2016-09-21 13:53:45 +02:00
parent 588891a552
commit 7c608d8593
5 changed files with 65 additions and 79 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<project default="dist" name="jarbuild">
<project default="dist" name="Create Library Jar">
<!--ANT 1.7 is required -->
<property name="buildjar.version" value="1.4" />
<property name="buildjar.version" value="1.5" />
<property file="build.properties" />
<property name="build.dir" value="${basedir}/build" />
<property name="build.src" value="${basedir}/src" />
@ -25,23 +25,31 @@
<pathelement path="${test.classes}" />
</path>
<!-- ***** Help ***** -->
<target name="help" description="Display detailed usage information">
<echo>Type ant -p</echo>
</target>
<!-- ***** Clear ***** -->
<target name="clear" description="Clean temporary directories before work">
<delete dir="${build.dir}" />
</target>
<!-- ***** Clean ***** -->
<target name="clean" description="Clean temporary directories">
<target name="clean" description="Clean temporary directories afeter work">
<delete dir="${build.dir}" />
</target>
<!-- ***** Compile ***** -->
<target name="compile" description="Compile main code">
<mkdir dir="${build.dir}/classes" />
<delete dir="${build.classes}" />
<mkdir dir="${build.classes}" />
<javac srcdir="${build.src}" destdir="${build.classes}" debug="${debug}" deprecation="on" includeantruntime="false">
<classpath refid="test.classpath.compile" />
<classpath refid="build.classpath" />
</javac>
<copy todir="${build.classes}">
<fileset dir="${build.src}" excludes="**/*.java" />
</copy>
</target>
<!-- ***** Compile test ***** -->
@ -50,11 +58,13 @@
<javac srcdir="${test.src}" destdir="${test.classes}" debug="${debug}" deprecation="on" includeantruntime="false">
<classpath refid="test.classpath.compile" />
</javac>
<copy todir="${test.classes}">
<fileset dir="${test.src}" excludes="**/*.java" />
</copy>
</target>
<!-- ***** Test ***** -->
<target name="test" description="Run unit tests" depends="clean,compile,compile-test">
<target name="test" description="Run unit tests" depends="clear,compile,compile-test,clean">
<mkdir dir="${build.dir}/test-reports" />
<junit printsummary="yes" haltonfailure="no">
<classpath refid="test.classpath.run" />
@ -77,25 +87,23 @@
</target>
<!-- ***** Dist ***** -->
<target name="dist" description="Build distribution" depends="clean,compile,javadoc">
<!-- -->
<buildnumber file="build.num" description="Id of the build" />
<target name="dist" description="Build distribution" depends="clear,compile,javadoc">
<!-- AUTOMATIC MANAGEMENT -->
<buildnumber file="build.num" description="Id of the build" />
<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.dir" value="${basedir}/dist/${dist.name}" />
<!-- -->
<mkdir dir="${dist.dir}" />
<!-- -->
<copy file="LICENSE" todir="${dist.dir}/" overwrite="true" />
<copy file="LICENSE" todir="${dist.dir}/" overwrite="true" failonerror="false" />
<copy file="README" todir="${dist.dir}/" overwrite="true" failonerror="false" />
<copy file="README.md" todir="${dist.dir}/" overwrite="true" failonerror="false" />
<!-- Package main -->
<property name="dist.jar" value="${dist.dir}/${dist.name}.jar" />
<tstamp>
<format property="dist.time" pattern="dd/MM/yyyy HH:mm:ss" />
<!-- TODAY -->
<format property="dist.time" pattern="dd/MM/yyyy HH:mm:ss" />
</tstamp>
<jar destfile="${dist.jar}">
<manifest>
@ -103,7 +111,6 @@
<attribute name="Built-Date" value="${dist.time}" />
</manifest>
<fileset dir="${build.classes}" />
<zipfileset dir="${basedir}/" includes="LICENSE" />
</jar>
<!-- Package sources -->
@ -115,37 +122,39 @@
<!-- Package Javadoc -->
<property name="dist.javadoc.zip" value="${dist.dir}/${dist.name}-javadoc.zip" />
<zip destfile="${dist.javadoc.zip}" update="true" preserve0permissions="true">
<zip destfile="${dist.javadoc.zip}" update="true">
<fileset dir="${build.javadoc}" />
<zipfileset dir="${basedir}/" includes="LICENSE" />
</zip>
<!-- Package lib -->
<copy todir="${dist.dir}/lib" overwrite="true">
<fileset dir="lib" excludes="hamcrest-core*,junit*" />
</copy>
</target>
<!-- ***** Dist ***** -->
<target name="buildandgit" depends="dist">
<!-- GIT actions-->
<echo message="Commit build.num"/>
<exec executable="git" outputproperty="git.commit.out" failifexecutionfails="true">
<arg line="commit -m 'Build ${dist.version}' build.num"/>
</exec>
<echo message="${git.commit.out}" />
<echo message="Tag"/>
<exec executable="git" outputproperty="git.tag.out" failifexecutionfails="true">
<arg line="tag -a ${dist.version} -m 'Build ${dist.version}'"/>
</exec>
<echo message="${git.tag.out}" />
<echo message="Push"/>
<exec executable="git" outputproperty="git.push.out" failifexecutionfails="true">
<arg line="push --follow-tags"/>
</exec>
<echo message="${git.push.out}" />
<!-- Zip package -->
<!--
<property name="dist.zip" value="${basedir}/dist/${dist.name}.zip" />
<zip destfile="${dist.zip}" update="true">
<fileset dir="${dist.dir}" />
<zipfileset filemode="755" dir="${dist.dir}/" includes="*.sh *.command" />
</zip>
-->
</target>
<!-- ***** Build and GIT ***** -->
<target name="buildandgit" depends="dist,clean">
<echo message="Commit build.num" />
<exec executable="git" outputproperty="git.commit.out" failifexecutionfails="true">
<arg line="commit -m 'Build ${dist.version}' build.num" />
</exec>
<echo message="${git.commit.out}" />
<echo message="Tag" />
<exec executable="git" outputproperty="git.tag.out" failifexecutionfails="true">
<arg line="tag -a ${dist.version} -m 'Build ${dist.version}'" />
</exec>
<echo message="${git.tag.out}" />
<echo message="Push" />
<exec executable="git" outputproperty="git.push.out" failifexecutionfails="true">
<arg line="push --follow-tags" />
</exec>
<echo message="${git.push.out}" />
</target>
</project>

View file

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Wed Feb 05 00:10:04 CET 2014
build.number=2
#Wed Sep 21 13:47:02 CEST 2016
build.number=0

View file

@ -1,13 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="dist-top" name="Xidyn">
<!-- -->
<import file="buildjar.xml" />
<project default="dist" name="Xidyn">
<!-- ***** Import ***** -->
<import file="build-libjar.xml" />
<!-- -->
<!-- ***** Define demo properties ***** -->
<property name="demo.src" value="${basedir}/demo" />
<property name="demo.classes" value="${build.dir}/demo-classes" />
<!-- -->
<path id="demo.classpath.compile">
<path refid="build.classpath"/>
<pathelement path="${build.classes}"/>
@ -16,6 +15,8 @@
<path id="demo.classpath.run">
<path refid="demo.classpath.compile"/>
<pathelement path="${demo.classes}"/>
<pathelement path="${build.classes}"/>
<pathelement path="${build.classpath}"/>
</path>
<!-- ***** Compile demo ***** -->
@ -26,24 +27,11 @@
</javac>
</target>
<!-- ***** Demo ***** -->
<target name="demo" description="Run demo" depends="clean,compile,compile-demo">
<!-- ***** Run demo ***** -->
<target name="demo" description="Run demo" depends="clear,compile,compile-demo">
<java classname="XidynDemo" maxmemory="20m" fork="true">
<classpath refid="demo.classpath.run" />
</java>
</target>
<!-- -->
<target name="dist-top" description="Build distribution" depends="dist,compile-demo">
<!-- Package demo -->
<property name="demo.jar" value="${dist.dir}/demo.jar" />
<jar update="no" jarfile="${demo.jar}">
<fileset dir="${build.classes}" />
<fileset dir="${demo.classes}" />
<fileset dir="resources" />
</jar>
<copy file="rundemo" todir="${dist.dir}/" overwrite="true" />
<chmod file="${dist.dir}/rundemo" perm="ugo+rx" />
<delete dir="${build.dir}" />
</target>
</project>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<project default="buildandgit" name="xidyn">
<!-- -->
<import file="buildjar.xml" />
<import file="build.xml" />
</project>

11
rundemo
View file

@ -1,11 +0,0 @@
$JAVA_HOME/bin/java -classpath \
lib/activation.jar:\
lib/log4j-1.2.17.jar:\
lib/slf4j-api-1.7.5.jar:\
lib/slf4j-log4j-1.2.5.jar:\
lib/mail.jar:\
servlet-api.jar:\
build/classes:\
build/demo-classes/:\
demo.jar\
XidynDemo