forked from antlibs/ant-xmltask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
183 lines (166 loc) · 8.52 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?xml version="1.0"?>
<project name="XmlTask" default="main" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
<property name="java.baseline" value="1.6"/>
<property name="src.dir" value="src/main/java"/>
<property name="res.dir" value="src/main/resources"/>
<property name="src.test.dir" value="src/test/java"/>
<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="javadoc.dir" value="${build.dir}/javadoc"/>
<property name="tests.dir" value="${build.dir}/tests"/>
<property name="jacoco.log" value="${build.dir}/jacoco.data"/>
<property name="jacoco.version" value="0.8.6"/>
<!-- Ivy: NB! 2.5+ requires Java 7 runtime -->
<property name="ivy.version" value="2.5.0"/>
<property name="ivy.dir" value="${user.home}/.ivy2/cache/org.apache.ivy/jars"/>
<property name="ivy.jar.name" value="ivy-${ivy.version}.jar"/>
<property name="ivy.jar.name" value="ivy-${ivy.version}.jar"/>
<available property="has.ivy" file="${ivy.dir}/${ivy.jar.name}" type="file"/>
<target name="get-ivy" unless="has.ivy">
<mkdir dir="${ivy.dir}"/>
<get usetimestamp="true" src="https://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/${ivy.jar.name}"
skipexisting="true"
dest="${ivy.dir}/${ivy.jar.name}"/>
</target>
<target name="init-ivy" depends="get-ivy">
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpath="${ivy.dir}/${ivy.jar.name}"/>
<ivy:settings file="${basedir}/ivy.settings.xml"/>
</target>
<target name="resolve" depends="init-ivy">
<ivy:resolve file="ivy.xml"/>
<ivy:cachepath pathid="compile.classpath" conf="compile" type="jar"/>
<ivy:cachepath pathid="test.classpath" conf="test" type="jar"/>
<!-- prepare dirs -->
<mkdir dir="${classes.dir}"/>
<echo file="${classes.dir}/xmltask.properties" message="com.oopsconsultancy.xmltask.version = ${ivy.revision}"/>
</target>
<target name="compile" depends="resolve" description="Java source build">
<javac srcdir="${src.dir}" destdir="${classes.dir}" debug="on" nowarn="true"
includeantruntime="false" source="${java.baseline}" target="${java.baseline}"
classpathref="compile.classpath">
<include name="**/*.java"/>
</javac>
</target>
<target name="jar" depends="compile">
<copy todir="${classes.dir}">
<fileset dir="${res.dir}" includes="com/oopsconsultancy/**/*.xml"/>
</copy>
<jar jarfile="${build.dir}/${ivy.module}-${ivy.revision}.jar" basedir="${classes.dir}"
includes="com/oopsconsultancy/**/*.class,com/oopsconsultancy/**/*.xml,xmltask.properties"
excludes="**/test/**/*" index="true">
<manifest>
<attribute name="Automatic-Module-Name" value="com.oopsconsultancy.xmltask"/>
</manifest>
</jar>
</target>
<target name="compile-test" depends="compile" description="Java test source build">
<javac srcdir="${src.test.dir}" destdir="${classes.dir}" debug="on" nowarn="true"
includeantruntime="false" source="${java.baseline}" target="${java.baseline}">
<include name="**/*.java"/>
<classpath>
<pathelement location="${classes.dir}"/>
<path refid="test.classpath"/>
</classpath>
</javac>
<copy todir="${tests.dir}">
<fileset dir="src/test/resources" includes="current/**" excludes="**/*.pl"/>
</copy>
</target>
<target name="init-jacoco" depends="compile-test">
<ivy:cachepath organisation="org.jacoco" module="org.jacoco.ant" revision="${jacoco.version}"
inline="true" conf="default" pathid="jacoco.classpath" log="download-only"/>
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml"
classpathref="jacoco.classpath"/>
</target>
<target name="test-internal" depends="init-jacoco">
<!-- multiple runs saving into the same logfile cause report generation failures -->
<delete file="${jacoco.log}"/>
<jacoco:coverage xmlns:jacoco="antlib:org.jacoco.ant" destfile="${jacoco.log}"
exclclassloader="sun.reflect.DelegatingClassLoader:javassist.Loader">
<junit printsummary="yes" haltonerror="false" haltonfailure="false"
errorproperty="junit.error" failureproperty="junit.failure"
includeantruntime="true" fork="true"
dir="${tests.dir}" tempdir="${tests.dir}">
<batchtest todir="${build.dir}">
<fileset dir="${src.test.dir}">
<include name="**/*Test*.java"/>
</fileset>
</batchtest>
<classpath>
<pathelement path="${classes.dir}"/>
<path refid="test.classpath"/>
</classpath>
<formatter type="plain" usefile="no"/>
<formatter type="xml"/>
<sysproperty key="project.test.workingDirectory" value="."/>
</junit>
</jacoco:coverage>
</target>
<target name="test" depends="test-internal" description="JUnit tests">
<fail message="JUnit error (${junit.error}) encountered. See logs (in ${build.dir}}) for details (use the target test-report to run the test with a report)" if="junit.error"/>
<fail message="JUnit failure (${junit.failure}) encountered. See logs (in ${build.dir}) for details (use the target test-report to run the test with a report)" if="junit.failure"/>
</target>
<target name="test-report" depends="test-internal" description="Report of JUnit tests">
<junitreport todir="${build.dir}">
<fileset dir="${build.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${build.dir}/test-report"/>
</junitreport>
<fail message="JUnit error (${junit.error}) encountered. See logs (in ${build.dir}) or report (in ${build.dir}/test-report)" if="junit.error"/>
<fail message="JUnit failure (${junit.failure}) encountered. See logs (in ${build.dir}) or report (in ${build.dir}/test-report)" if="junit.failure"/>
</target>
<target name="coverage-report" depends="test-internal" description="Coverage report of JUnit tests">
<jacoco:report xmlns:jacoco="antlib:org.jacoco.ant">
<executiondata>
<file file="${jacoco.log}"/>
</executiondata>
<structure name="${ant.project.name}">
<classfiles>
<fileset dir="${classes.dir}"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${src.dir}"/>
</sourcefiles>
</structure>
<html destdir="${build.dir}/coverage-report/"/>
</jacoco:report>
</target>
<target name="report" depends="test-report,coverage-report" description="Complete test report"/>
<target name="javadoc" depends="resolve" description="Javadoc build">
<!-- A workaround for a "unnamed module" error -->
<condition property="ant.build.javac.source" value="1.8" else="${java.baseline}">
<javaversion atleast="9"/>
</condition>
<javadoc destdir="${javadoc.dir}" author="true" version="true" use="true" windowtitle="Ant xmltask ${ivy.revision}">
<packageset dir="${src.dir}" defaultexcludes="yes">
<include name="com/oopsconsultancy/**"/>
</packageset>
<doctitle><![CDATA[<h1>Ant xmltask ${ivy.revision}</h1>]]></doctitle>
<bottom><![CDATA[<i>Ant xmltask ${ivy.revision}</i>]]></bottom>
<link href="https://docs.oracle.com/javase/6/docs/api/"/>
</javadoc>
</target>
<target name="main" depends="test,javadoc" description="Complete build and test"/>
<target name="dist" depends="jar,javadoc" description="Build distribution archives">
<jar destfile="${build.dir}/${ivy.module}-${ivy.revision}-javadoc.jar" basedir="${javadoc.dir}"/>
<jar jarfile="${build.dir}/${ivy.module}-${ivy.revision}-sources.jar">
<fileset dir="${src.dir}" includes="**/*.java"/>
</jar>
<tar tarfile="${build.dir}/${ivy.module}-${ivy.revision}.tar.gz" compression="gzip">
<tarfileset dir="." includes="LICENSE,CREDITS,CHANGES,*.md,*.xml"/>
<tarfileset dir="${classes.dir}" includes="xmltask.properties"/>
<tarfileset dir="src/site/resources" prefix="doc" includes="**/*.css,**/*.gif,**/*.jpg"/>
<tarfileset dir="src/site/xhtml" prefix="doc" includes="**/*.xhtml"/>
</tar>
<echo>Created source and documentation archives</echo>
</target>
<target name="clean" description="Clean build tree">
<delete dir="${build.dir}"/>
<delete includeemptydirs="true">
<fileset dir="src/test/resources" includes="**/scripts/*-out.xml"/>
<fileset dir="src/test/resources" includes="**/scripts/to/**"/>
<fileset dir="src/test/resources" includes="**/scripts/from/**"/>
</delete>
</target>
</project>