Improve build.

This commit is contained in:
Christian P. MOMON 2013-06-26 02:21:03 +02:00
parent bd5c261f3f
commit 50bf01ce48
8 changed files with 173 additions and 160 deletions

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="src" path="demo"/> <classpathentry kind="src" path="demo"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/> <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="lib" path="lib/log4j-1.2.14.jar"/> <classpathentry kind="lib" path="lib/log4j-1.2.14.jar"/>
<classpathentry kind="lib" path="lib/servlet-api.jar"/> <classpathentry kind="lib" path="lib/servlet-api.jar"/>

View file

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Thu Jun 20 02:51:05 CEST 2013 #Thu Jun 20 02:51:05 CEST 2013
build.number=0 build.number=1

3
build.properties Normal file
View file

@ -0,0 +1,3 @@
product.name=xidyn
product.revision.major=0
product.revision.minor=2

190
build.xml
View file

@ -1,165 +1,49 @@
<?xml version="1.0"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE project> <project default="dist2" name="Xidyn">
<!-- Builds the XID Framework. --> <!-- -->
<project name="xid" default="all" basedir="."> <import file="jarbuild.xml" />
<buildnumber file="build.num" description="Id of the build"/>
<property name="version" value="0.2.${build.number}" /> <!-- AUTOMATIC MANAGEMENT -->
<property name="targetjar" value="xid.jar"/>
<property name="zip_file" value="xid.zip"/> <!-- Release zip file -->
<property name="src" value="src"/>
<property name="build" value="build"/>
<property name="doc" value="doc"/>
<property name="dist" value="dist"/>
<property name="resources" value="resources"/>
<property name="debug" value="on"/>
<target name="all" depends="build_xid,dist_xid,build_test,dist_test,build_demo,dist_demo" />
<!-- ******* Init ******* -->
<target name="init">
<tstamp/>
<mkdir dir="${build}"/>
<mkdir dir="build_demo/classes"/>
<mkdir dir="build_test/classes"/>
<mkdir dir="${build}/classes"/>
<mkdir dir="${dist}"/>
</target>
<!-- -->
<property name="demo.src" value="${basedir}/demo" />
<property name="demo.classes" value="${build.dir}/demo-classes" />
<!-- ******* build ******* --> <!-- -->
<target name="build_xid" depends="init"> <path id="demo.classpath.compile">
<javac srcdir="${src}" destdir="${build}/classes" debug="${debug}" deprecation="on" includeantruntime="false"> <path refid="build.classpath"/>
<classpath> <pathelement path="${build.classes}"/>
<fileset dir="lib" includes="**/*.jar"/> </path>
</classpath>
<path id="demo.classpath.run">
<path refid="demo.classpath.compile"/>
<pathelement path="${demo.classes}"/>
</path>
<!-- ***** Compile demo ***** -->
<target name="compile-demo" description="Compile demo">
<mkdir dir="${demo.classes}"/>
<javac srcdir="${demo.src}" destdir="${demo.classes}" debug="${debug}" deprecation="on" includeantruntime="false">
<classpath refid="demo.classpath.compile"/>
</javac> </javac>
</target> </target>
<!-- ***** Demo ***** -->
<!-- ****** dist_xid ****** --> <target name="demo" description="Run demo" depends="clean,compile,compile-demo">
<target name="dist_xid" depends="build_xid"> <java classname="XidynDemo" maxmemory="20m" fork="true">
<jar update="no" jarfile="dist/xid.jar"> <classpath refid="demo.classpath.run" />
<fileset dir="build/classes" />
<fileset dir="resources" />
</jar>
</target>
<!-- ******* build_test ******* -->
<target name="build_test" depends="dist_xid">
<javac srcdir="test" destdir="build_test/classes" debug="${debug}" deprecation="on" includeantruntime="false">
<classpath>
<fileset dir="lib" includes="**/*.jar"/>
<pathelement path="dist/xid.jar"/>
</classpath>
</javac>
</target>
<!-- ****** dist_test ****** -->
<target name="dist_test" depends="build_test">
<jar update="no" jarfile="dist/test.jar">
<fileset dir="build_test/classes" />
<fileset dir="resources" />
</jar>
</target>
<!-- *********** runtest ******** -->
<target name="test" depends="dist_test">
<java classname="xid.test.Test" maxmemory="20m" fork="true">
<classpath>
<fileset dir="lib" includes="**/*.jar" />
<fileset dir="resources" includes="**" />
<pathelement path="dist/xid.jar"/>
<pathelement path="dist/test.jar"/>
</classpath>
</java> </java>
</target> </target>
<!-- ******* build_demo ******* --> <!-- -->
<target name="build_demo" depends="dist_xid"> <target name="dist2" description="Build distribution" depends="dist,compile-demo">
<javac srcdir="demo" destdir="build_demo/classes" debug="${debug}" deprecation="on" includeantruntime="false"> <!-- Package demo -->
<classpath> <property name="demo.jar" value="${dist.dir}/demo.jar" />
<fileset dir="lib" includes="**/*.jar"/> <jar update="no" jarfile="${demo.jar}">
<pathelement path="dist/xid.jar"/> <fileset dir="${build.classes}" />
</classpath> <fileset dir="${demo.classes}" />
</javac>
</target>
<!-- ****** dist_demo ****** -->
<target name="dist_demo" depends="build_demo">
<jar update="no" jarfile="dist/demo.jar">
<fileset dir="build_demo/classes" />
<fileset dir="resources" /> <fileset dir="resources" />
</jar> </jar>
</target> <copy file="rundemo" todir="${dist.dir}/" overwrite="true" />
<chmod file="${dist.dir}/" perm="ugo+rx" />
<!-- *********** dodemo ******** -->
<target name="demo" depends="dist_demo">
<java classname="Demo" maxmemory="20m" fork="true">
<classpath>
<fileset dir="lib" includes="**/*.jar" />
<fileset dir="resources" includes="**" />
<pathelement path="dist/xid.jar"/>
<pathelement path="dist/demo.jar"/>
</classpath>
</java>
</target> </target>
</project>
<!-- ******* Examples (the webapp). ******* -->
<target name="examples" depends="dist_xid">
<copy todir="webapp-examples/WEB-INF/lib">
<fileset dir="lib" includes="*.jar" excludes="servlet-api.jar"/>
<fileset dir="dist" includes="*.jar"/>
</copy>
<copy file="${dist}/xid.jar" todir="webapp-examples/WEB-INF/lib" overwrite="yes" preservelastmodified="yes"/>
<delete>
<fileset dir="webapp-examples/WEB-INF/classes/" includes="**.class"/>
<fileset dir="webapp-examples/WEB-INF/classes/" includes="**/**.class"/>
</delete>
<javac srcdir="webapp-examples/WEB-INF/classes/" destdir="webapp-examples/WEB-INF/classes/" debug="${debug}" deprecation="on">
<classpath>
<fileset dir="webapp-examples/WEB-INF/lib" includes="**.jar"/>
</classpath>
</javac>
</target>
<!-- ****** JavaDoc ****** -->
<target name="javadoc" depends="build_xid">
<javadoc sourcepath="${src}" packageNames="xid.*" destdir="${doc}">
<classpath>
<fileset dir="lib" includes="**/*.jar"/>
</classpath>
</javadoc>
</target>
<!-- *************** Clean ***********************-->
<target name="clean">
<delete dir="${build}"/>
<delete dir="build_test"/>
<delete dir="build_demo"/>
</target>
<!-- *********** Produce ZIP release file ******** -->
<target name="zip">
<zip update="no" zipfile="../${zip_file}" basedir=".">
<include name=".project" />
<include name=".classpath" />
<include name="build.xml" />
<include name="src/**" />
<include name="resources/**" />
<include name="lib/*.jar" />
</zip>
</target>
</project>

View file

@ -9,7 +9,7 @@ import fr.devinsy.xidyn.StringPresenter;
/** /**
* *
*/ */
class XidDemo class XidynDemo
{ {
static static
{ {
@ -18,7 +18,7 @@ class XidDemo
org.apache.log4j.Logger log = null; org.apache.log4j.Logger log = null;
log = org.apache.log4j.Logger.getRootLogger(); log = org.apache.log4j.Logger.getRootLogger();
log = org.apache.log4j.Logger.getLogger(XidDemo.class); log = org.apache.log4j.Logger.getLogger(XidynDemo.class);
} }
/** /**

128
jarbuild.xml Normal file
View file

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<project default="dist" name="jarbuild">
<!--ANT 1.7 is required -->
<property file="build.properties" />
<property name="build.dir" value="${basedir}/build" />
<property name="build.src" value="${basedir}/src" />
<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.classes" value="${build.dir}/test-classes" />
<property name="debug" value="on" />
<path id="build.classpath">
<fileset dir="lib" includes="**/*.jar" />
</path>
<path id="test.classpath.compile">
<path refid="build.classpath" />
<pathelement path="${build.classes}" />
</path>
<path id="test.classpath.run">
<path refid="test.classpath.compile" />
<pathelement path="${test.classes}" />
</path>
<!-- ***** Help ***** -->
<target name="help" description="Display detailed usage information">
<echo>Type ant -p</echo>
</target>
<!-- ***** Clean ***** -->
<target name="clean" description="Clean temporary directories">
<delete dir="${build.dir}" />
</target>
<!-- ***** Compile ***** -->
<target name="compile" description="Compile main code">
<mkdir dir="${build.dir}/classes" />
<javac srcdir="${build.src}" destdir="${build.classes}" debug="${debug}" deprecation="on" includeantruntime="false">
<classpath refid="test.classpath.compile" />
</javac>
</target>
<!-- ***** Compile test ***** -->
<target name="compile-test" description="Compile test code">
<mkdir dir="${test.classes}" />
<javac srcdir="${test.src}" destdir="${test.classes}" debug="${debug}" deprecation="on" includeantruntime="false">
<classpath refid="test.classpath.compile" />
</javac>
</target>
<!-- ***** Test ***** -->
<target name="test" description="Run unit tests" depends="clean,compile,compile-test">
<mkdir dir="${build.dir}/test-reports" />
<junit printsummary="yes" haltonfailure="no">
<classpath refid="test.classpath.run" />
<formatter type="plain" usefile="true" />
<batchtest fork="yes" todir="${build.dir}/test-reports/">
<fileset dir="test">
<include name="**/*Test.java" />
</fileset>
</batchtest>
</junit>
</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 ***** -->
<target name="dist" description="Build distribution" depends="clean,compile,javadoc">
<!-- -->
<buildnumber file="build.num" description="Id of the build" />
<!-- AUTOMATIC MANAGEMENT -->
<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" />
<!-- 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 -->
</tstamp>
<jar destfile="${dist.jar}">
<manifest>
<attribute name="Built-By" value="${user.name} using ant" />
<attribute name="Built-Date" value="${dist.time}" />
</manifest>
<fileset dir="${build.classes}" />
<zipfileset dir="${basedir}/" includes="LICENSE" />
</jar>
<!-- Package sources -->
<property name="dist.srczip" value="${dist.dir}/${dist.name}-sources.zip" />
<zip destfile="${dist.srczip}" update="true" preserve0permissions="true">
<fileset dir="${basedir}/src" />
<zipfileset dir="${basedir}/" includes="LICENSE" />
</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>
</project>

View file

@ -1,2 +1,2 @@
#$JAVA_HOME/bin/java -classpath lib/activation.jar:lib/log4j-1.2.14.jar:lib/mail.jar:servlet-api.jar:dist/xid.jar:dist/demo.jar XidDemo #$JAVA_HOME/bin/java -classpath lib/activation.jar:lib/log4j-1.2.14.jar:lib/mail.jar:servlet-api.jar:dist/xid.jar:dist/demo.jar XidDemo
$JAVA_HOME/bin/java -classpath lib/activation.jar:lib/log4j-1.2.14.jar:lib/mail.jar:servlet-api.jar:build/classes/ XidDemo $JAVA_HOME/bin/java -classpath lib/activation.jar:lib/log4j-1.2.14.jar:lib/mail.jar:servlet-api.jar:build/classes:build/demo-classes/:demo.jar:xidyn*.jar XidynDemo

View file

@ -1,2 +0,0 @@
# $JAVA_HOME/bin/java -classpath lib/activation.jar:lib/log4j-1.2.14.jar:lib/mail.jar:servlet-api.jar:dist/xid.jar:dist/test.jar xid.test.Test
$JAVA_HOME/bin/java -classpath lib/activation.jar:lib/log4j-1.2.14.jar:lib/mail.jar:servlet-api.jar:dist/xid.jar:build/classes/ XidTest