Skip to content
This repository has been archived by the owner on Nov 9, 2018. It is now read-only.

Commit

Permalink
improved build script for Jenkins
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Håkansson committed Nov 16, 2012
1 parent 386ee65 commit 3b9e42d
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 117 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ Dotify/lib/texhyphj.jar -text
Dotify/lib/wstx-lgpl-3.2.8.jar -text
Dotify/lib/xercesImpl.jar -text
Dotify/logging.properties -text svneol=unset#text/plain
Dotify/run-tests.xml -text svneol=unset#text/plain
Dotify/src/META-INF/services/javax.xml.transform.TransformerFactory -text
Dotify/src/META-INF/services/javax.xml.validation.SchemaFactory -text
Dotify/src/META-INF/services/org.daisy.dotify.config.ConfigurationsProvider -text
Expand Down
121 changes: 114 additions & 7 deletions Dotify/build.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,50 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="buildJar">
<project default="buildAndTest">
<description>Buildfile for this project</description>

<import file="build-properties.xml"/>

<property name="dist.jar" value="${dist.dir}/dotify.jar"/>
<property name="build.dir" value="${ant-output.dir}/build.temp"/>

<!-- Testing properties -->
<property name="test-src.dir" value="${basedir}/test"/>
<property name="test-build.dir" value="${ant-output.dir}/test-build.temp"/>
<property name="tests-jar.name" value="tests-temp.jar"/>
<property name="dist-unzip.dir" value="${ant-output.dir}/test-unzip"/>
<property name="dist-root.dir" value="${ant-output.dir}/test-unzip/${zip-foler-prefix}"/>
<property name="dist-lib.dir" value="${dist-unzip.dir}/${zip-foler-prefix}/lib"/>
<property name="test.report.dir" value="${ant-output.dir}/test-report"/>
<property name="test.report-temp.dir" value="${ant-output.dir}/test-report.temp"/>

<patternset id="dist-jar.patternset">
<include name="**/*.*"/>
<exclude name="**/package.html"/>
</patternset>


<!-- Testing paths -->
<path id="test.classpath">
<!--
<fileset dir="${dist-lib.dir}">
<include name="*.jar"/>
</fileset>-->
<fileset dir="${dist-root.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${lib.dir}">
<include name="junit*.jar"/>
</fileset>
<fileset dir="${ant-output.dir}">
<include name="${tests-jar.name}"/>
</fileset>
</path>

<patternset id="test.patternset">
<include name="**/*.*"/>
<exclude name="**/doc-files/**/*.*"/>
<exclude name="**/package.html"/>
</patternset>

<!-- - - - - - - - - - - - - - - - - -
target: emptyBuildDir
- - - - - - - - - - - - - - - - - -->
Expand All @@ -21,16 +54,17 @@
</target>

<!-- - - - - - - - - - - - - - - - - -
target: createDistDir
target: emptyDistDir
- - - - - - - - - - - - - - - - - -->
<target name="createDistDir">
<target name="emptyDistDir">
<delete dir="${dist.dir}"/>
<mkdir dir="${dist.dir}"/>
</target>

<!-- - - - - - - - - - - - - - - - - -
target: compile
- - - - - - - - - - - - - - - - - -->
<target name="compile" depends="emptyBuildDir, createDistDir">
<target name="compile" depends="emptyBuildDir, emptyDistDir">
<!-- Compile core files -->
<javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false" encoding="UTF-8" debug="true">
<classpath>
Expand All @@ -39,9 +73,35 @@
</fileset>
</classpath>
</javac>
</target>

<!-- - - - - - - - - - - - - - - - - -
target: compileTests
- - - - - - - - - - - - - - - - - -->
<target name="compileTests">
<!-- Unzip dotify -->
<delete dir="${dist-unzip.dir}"/>
<unzip src="${distribution.zip}" dest="${dist-unzip.dir}"/>

<delete dir="${test-build.dir}"/>
<mkdir dir="${test-build.dir}"/>

<!-- Compile test files -->
<javac srcdir="${test-src.dir}" destdir="${test-build.dir}" includeantruntime="false" encoding="UTF-8">
<classpath>
<fileset dir="${dist-root.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${lib.dir}">
<include name="junit*.jar"/>
</fileset>
</classpath>
</javac>
</target>

<!-- =================================
target: buildJar
================================= -->
<target name="buildJar" description="Builds distribution jar">
<antcall target="compile"></antcall>
<jar destfile="${dist.jar}">
Expand All @@ -65,6 +125,9 @@
<delete dir="${build.dir}"/>
</target>

<!-- =================================
target: buildZip
================================= -->
<target name="buildZip" depends="buildJar" description="Builds distribution zip including all required jars">
<zip destfile="${distribution.zip}">
<zipfileset file="${dist.jar}" prefix="${zip-foler-prefix}/"/>
Expand All @@ -73,6 +136,50 @@
<exclude name="junit*.jar"/>
</zipfileset>
</zip>
<delete file="${dist.jar}"/>
</target>

<!-- =================================
target: buildAndTest
================================= -->
<target name="buildAndTest" description="Build distribution zip and run unit tests" depends="buildZip, compileTests">
<jar destfile="${ant-output.dir}/${tests-jar.name}">
<fileset dir="${test-build.dir}">
<patternset refid="test.patternset"/>
</fileset>
<fileset dir="${test-src.dir}">
<patternset refid="test.patternset"/>
</fileset>
</jar>

<delete dir="${test.report.dir}"/>
<mkdir dir="${test.report.dir}"/>

<mkdir dir="${test.report-temp.dir}"/>

<junit fork="yes" printsummary="no" haltonfailure="no" errorproperty="testerror" failureproperty="testfail">
<batchtest fork="yes" todir="${test.report-temp.dir}">
<fileset dir="${test-build.dir}">
<include name="**/*Test.class" />
</fileset>
</batchtest>
<formatter type="xml" />
<classpath refid="test.classpath" />
</junit>

<junitreport todir="${test.report.dir}">
<fileset dir="${test.report-temp.dir}">
<include name="TEST-*.xml" />
</fileset>
<report todir="${test.report.dir}" />
</junitreport>

<delete dir="${test.report-temp.dir}"/>
<delete dir="${test-build.dir}"/>
<delete file="${ant-output.dir}/${tests-jar.name}"/>
<delete dir="${dist-unzip.dir}"/>

<fail if="testerror" message="Error in tests"/>
</target>

</project>
109 changes: 0 additions & 109 deletions Dotify/run-tests.xml

This file was deleted.

0 comments on commit 3b9e42d

Please sign in to comment.