www.libre-service.eu-webapp/buildwar.xml

197 lines
7 KiB
XML
Raw Permalink Normal View History

2023-12-01 01:51:53 +01:00
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<project default="dist" name="warbuild">
<!--ANT 1.7 is required -->
<property name="builwjar.version" value="1.3" />
<property file="src/build_information.properties" />
<property name="build.dir" value="${basedir}/build.tmp" />
<property name="build.src" value="${basedir}/src" />
<property name="build.web" value="${basedir}/WebContent" />
<property name="build.classes" value="${build.dir}/classes" />
<property name="build.javadoc" value="${build.dir}/javadoc" />
<property name="lib.dir" value="${basedir}/WebContent/WEB-INF/lib" />
<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.dir}" includes="**/*.jar" />
<fileset dir="resources/extra-jars" 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>
<!-- ***** Run 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.dir}" includes="**/*.jar" excludes="*source* *src*" />
<fileset dir="resources/extra-jars" includes="**/*.jar" excludes="*source* *src*" />
</classpath>
</javadoc>
</target>
<!-- ***** Dist ***** -->
<target name="dist" description="Build distribution" depends="clean,compile,javadoc">
<!-- Copy source resources -->
<copy todir="${build.classes}/">
<fileset dir="${build.src}" excludes="**/*.java" />
</copy>
<!-- -->
<buildnumber file="build.num" description="Id of the build" />
<!-- AUTOMATIC MANAGEMENT -->
<property name="dist.version" value="${product.revision.major}.${product.revision.minor}.${build.number}${product.revision.alpha}" />
<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" />
<!-- Update build_information.properties file -->
<propertyfile file="${build.classes}/build_information.properties" >
<entry key="product.name" value="${product.name}"/>
<entry key="product.revision.major" value="${product.revision.major}"/>
<entry key="product.revision.minor" value="${product.revision.minor}"/>
<entry key="product.revision.build" value="${build.number}${product.revision.alpha}"/>
<entry key="product.revision.date" type="date" value="now"/>
<entry key="product.revision.generator" value="Ant"/>
<entry key="product.revision.author" value="${user.name}"/>
</propertyfile>
<!-- Package war -->
<!-- property name="dist.war" value="${dist.dir}/${dist.name}.war" /-->
<property name="dist.war" value="${dist.dir}/${product.name}.war" />
<tstamp>
<!-- TODAY -->
<format property="dist.time" pattern="dd/MM/yyyy HH:mm:ss" />
</tstamp>
<war destfile="${dist.war}" webxml="WebContent/WEB-INF/web.xml">
<manifest>
<attribute name="Built-By" value="${user.name} using ant" />
<attribute name="Built-Date" value="${dist.time}" />
</manifest>
<classes dir="${build.classes}" />
<fileset dir="${build.web}">
<!-- Need to exclude it since webxml is an attribute of the war tag above. -->
<!--exclude name="WEB-INF/web.xml" /-->
<!-- Need to exclude it since environment configuration is made in $CATALINA_BASE/conf/Catalina/localhost/ folder. -->
<exclude name="META-INF/context.xml" />
</fileset>
<zipfileset dir="${basedir}/" includes="LICENSE" />
</war>
<!-- Copy resources -->
<copy todir="${dist.dir}/">
<fileset dir="${basedir}/resources" />
</copy>
<!-- 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>
<!-- Clean -->
<delete dir="${build.dir}" />
</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}" />
</target>
<!-- ***** Dist ***** -->
<target name="testgit">
<echo message="testgit" />
<exec executable="git" outputproperty="git.out" failifexecutionfails="true">
<arg value="version"/>
</exec>
<echo message="${git.out}" />
</target>
</project>