-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.xml
More file actions
251 lines (221 loc) · 11.7 KB
/
Copy pathbuild.xml
File metadata and controls
251 lines (221 loc) · 11.7 KB
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2012 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="ml-ant-http" default="test" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- Ivy -->
<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>
<property name="ml-ant-http.src.dir" location="src"/>
<property name="ml-ant-http.java.src.dir" location="${ml-ant-http.src.dir}/main/java"/>
<property name="ml-ant-http.resources.dir" location="${ml-ant-http.src.dir}/main/resources"/>
<property name="ml-ant-http.test.src.dir" location="${ml-ant-http.src.dir}/test/java"/>
<property name="ml-ant-http.test.resources.dir" location="${ml-ant-http.src.dir}/test/resources"/>
<property name="ml-ant-http.build.dir" location="build"/>
<property name="ml-ant-http.build.classes.dir" location="${ml-ant-http.build.dir}/classes"/>
<property name="ml-ant-http.build.test.classes.dir" location="${ml-ant-http.build.dir}/test-classes"/>
<property name="ml-ant-http.build.docs.dir" location="${ml-ant-http.build.dir}/docs"/>
<property name="ml-ant-http.javadoc.dir" location="${ml-ant-http.build.dir}/api"/>
<property name="ml-ant-http.test.report.dir" location="${ml-ant-http.build.dir}/test-report"/>
<property name="ml-ant-http.dist.dir" location="dist"/>
<property name="ml-ant-http.site.dir" location="${ml-ant-http.src.dir}/site/resources"/>
<property name="ml-ant-http.license.dir" location="${basedir}"/>
<property name="ml-ant-http.license.file" value="LICENSE"/>
<property name="ml-ant-http.java.baseline" value="1.6"/>
<property name="jacoco.log" value="${ml-ant-http.build.dir}/jacoco.data"/>
<property name="jacoco.version" value="0.8.6"/>
<target name="clean" description="o Clean build tree">
<delete dir="${ml-ant-http.build.dir}"/>
<delete dir="${ml-ant-http.dist.dir}"/>
</target>
<target name="init" depends="init-ivy">
<mkdir dir="${ml-ant-http.build.dir}"/>
<mkdir dir="${ml-ant-http.build.classes.dir}"/>
<mkdir dir="${ml-ant-http.build.docs.dir}"/>
<mkdir dir="${ml-ant-http.dist.dir}"/>
</target>
<target name="resolve" depends="init">
<ivy:resolve file="ivy.xml"/>
<ivy:cachepath pathid="compile.classpath" conf="compile" type="jar"/>
<ivy:cachepath pathid="runtime.classpath" conf="runtime" type="jar"/>
<ivy:cachepath pathid="test.classpath" conf="test" type="jar"/>
<property name="ml-ant-http.dist.jar.dir" location="${ml-ant-http.dist.dir}/${ivy.module}-${ivy.revision}"/>
<mkdir dir="${ml-ant-http.dist.jar.dir}"/>
</target>
<target name="compile" depends="resolve" description="o Java source build">
<javac debug="yes" destdir="${ml-ant-http.build.classes.dir}"
classpathref="compile.classpath" includeantruntime="false"
source="${ml-ant-http.java.baseline}" target="${ml-ant-http.java.baseline}">
<src path="${ml-ant-http.java.src.dir}"/>
</javac>
</target>
<target name="jar" depends="compile">
<copy todir="${ml-ant-http.build.classes.dir}">
<fileset dir="${ml-ant-http.resources.dir}" includes="org/missinglink/**/*.xml"/>
</copy>
<jar destfile="${ml-ant-http.dist.jar.dir}/${ivy.module}-${ivy.revision}.jar"
basedir="${ml-ant-http.build.classes.dir}" index="true">
<metainf dir="${ml-ant-http.license.dir}">
<include name="${ml-ant-http.license.file}"/>
</metainf>
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Automatic-Module-Name" value="org.missinglink.http"/>
</manifest>
</jar>
</target>
<target name="jar-src" depends="jar">
<jar destfile="${ml-ant-http.dist.jar.dir}/${ivy.module}-${ivy.revision}-sources.jar"
basedir="${ml-ant-http.java.src.dir}">
<metainf dir="${ml-ant-http.license.dir}">
<include name="${ml-ant-http.license.file}"/>
</metainf>
<manifest>
<attribute name="Built-By" value="${user.name}"/>
</manifest>
</jar>
</target>
<target name="javadoc" depends="resolve" description="o 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="${ml-ant-http.javadoc.dir}" author="true" version="true" use="true"
windowtitle="missing link Ant HTTP task ${ivy.revision}">
<packageset dir="${ml-ant-http.java.src.dir}" defaultexcludes="yes">
<include name="org/missinglink/**"/>
</packageset>
<doctitle><![CDATA[<h1>missing link Ant HTTP task ${ivy.revision}</h1>]]></doctitle>
<bottom><![CDATA[<i>missing link Ant HTTP task ${ivy.revision}</i>]]></bottom>
<tag name=".todo" scope="all" description="To do:"/>
<link href="https://docs.oracle.com/javase/6/docs/api/"/>
<!-- for Java 11 or later: https://docs.oracle.com/en/java/javase/11/docs/api/ -->
</javadoc>
<zip destfile="${ml-ant-http.dist.jar.dir}/${ivy.module}-${ivy.revision}-api.zip"
basedir="${ml-ant-http.javadoc.dir}"/>
</target>
<target name="copy-dist-files" depends="jar-src">
<!-- license -->
<copy filtering="false" flatten="false" todir="${ml-ant-http.dist.jar.dir}">
<fileset dir="${ml-ant-http.license.dir}">
<include name="${ml-ant-http.license.file}"/>
</fileset>
</copy>
<filter token="ml-ant-http-jar-name" value="${ivy.module}"/>
<filter token="ml-ant-http-version" value="${ivy.revision}"/>
<copy filtering="true" flatten="true" todir="${ml-ant-http.dist.jar.dir}">
<fileset dir="${ml-ant-http.site.dir}">
<include name="ant/build-sample.xml"/>
</fileset>
</copy>
<copy filtering="false" flatten="true" todir="${ml-ant-http.dist.jar.dir}">
<fileset dir="${ml-ant-http.site.dir}">
<include name="doc/readme.pdf"/>
</fileset>
</copy>
</target>
<target name="dist" depends="copy-dist-files,javadoc" description="o Build distribution archive">
<zip destfile="${ml-ant-http.dist.dir}/${ivy.module}-${ivy.revision}.zip"
basedir="${ml-ant-http.dist.jar.dir}"/>
</target>
<target name="compile-tests" depends="compile" description="o Java test source build">
<mkdir dir="${ml-ant-http.build.test.classes.dir}"/>
<javac debug="yes" destdir="${ml-ant-http.build.test.classes.dir}" includeantruntime="false"
source="${ml-ant-http.java.baseline}" target="${ml-ant-http.java.baseline}">
<classpath>
<pathelement location="${ml-ant-http.build.classes.dir}"/>
<path refid="test.classpath"/>
</classpath>
<src path="${ml-ant-http.test.src.dir}"/>
</javac>
<copy todir="${ml-ant-http.build.test.classes.dir}">
<fileset dir="${ml-ant-http.test.src.dir}" excludes="**/*.java"/>
</copy>
</target>
<target name="init-jacoco" depends="compile-tests">
<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">
<mkdir dir="${ml-ant-http.test.report.dir}"/>
<!-- 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"
fork="true" tempdir="${ml-ant-http.build.dir}">
<classpath>
<pathelement location="${ml-ant-http.test.resources.dir}"/>
<pathelement location="${ml-ant-http.build.test.classes.dir}"/>
<pathelement location="${ml-ant-http.build.classes.dir}"/>
<path refid="test.classpath"/>
</classpath>
<formatter type="plain" usefile="no"/>
<formatter type="xml"/>
<batchtest todir="${ml-ant-http.test.report.dir}">
<fileset dir="${ml-ant-http.test.src.dir}">
<include name="**/*Test.java"/>
<exclude name="**/Abstract*"/>
</fileset>
</batchtest>
</junit>
</jacoco:coverage>
</target>
<target name="test" depends="test-internal" description="o JUnit tests">
<fail message="JUnit error (${junit.error}) encountered. See logs (in ${ml-ant-http.test.report.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 ${ml-ant-http.test.report.dir}) for details (use the target test-report to run the test with a report)" if="junit.failure"/>
</target>
<target name="main" depends="test,javadoc" description="o Complete build and test"/>
<target name="test-report" depends="test-internal" description="o Report of JUnit tests">
<junitreport todir="${ml-ant-http.test.report.dir}">
<fileset dir="${ml-ant-http.test.report.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${ml-ant-http.build.docs.dir}/test-report"/>
</junitreport>
<fail message="JUnit error (${junit.error}) encountered. See logs (in ${ml-ant-http.test.report.dir}) or report (in ${ml-ant-http.build.docs.dir}/test-report)" if="junit.error"/>
<fail message="JUnit failure (${junit.failure}) encountered. See logs (in ${ml-ant-http.test.report.dir}) or report (in ${ml-ant-http.build.docs.dir}/test-report)" if="junit.failure"/>
</target>
<target name="coverage-report" depends="test-internal" description="o 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="${ml-ant-http.build.classes.dir}"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${ml-ant-http.java.src.dir}"/>
</sourcefiles>
</structure>
<html destdir="${ml-ant-http.build.docs.dir}/coverage-report/"/>
</jacoco:report>
</target>
<target name="report" depends="test-report,coverage-report" description="o Complete test report"/>
</project>