-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathbuild.xml
355 lines (317 loc) · 17.3 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
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
<!--
~ Jakarta Validation: constrain once, validate everywhere.
~
~ License: Apache License, Version 2.0
~ See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
-->
<project name="Documentation" default="all.doc" xmlns:asciidoctor="antlib:org.asciidoctor.ant" xmlns:if="ant:if" xmlns:unless="ant:unless">
<tstamp>
<format property="current.date" pattern="yyyy-MM-dd"/>
</tstamp>
<property name="bv.version" value="3.1.0-M2" /><!-- e.g. '2.0.0-RC1' -->
<property name="bv.version.spec" value="3.1" /><!-- The major.minor of the specification (no service releases) -->
<property name="bv.version.qualifier" value="Draft" /><!-- e.g. ' (Early Draft 1)' - be careful about the space before the qualifier -->
<property name="bv.revdate" value="${current.date}" /> <!-- Replace with fixed date when releasing -->
<!-- value to use for releasing: license-final -->
<property name="license" value="license-evaluation" />
<!-- Value to use for releasing: jakarta_ee_logo_schooner_color_stacked_default.png[pdfwidth=4.25in,align=right] -->
<property name="logo" value="jakarta_ee_logo_schooner_color_stacked_default.png[pdfwidth=4.25in,align=right]" />
<property name="asciidoctor-ant.version" value="1.6.0-alpha.5" />
<property name="asciidoctorj.version" value="1.6.0-alpha.5" />
<property name="asciidoctorj-pdf.version" value="1.5.0-alpha.16" />
<property name="jruby.version" value="9.1.8.0" />
<property name="jcommander.version" value="1.35" />
<property name="hibernate-asciidoctor-theme.version" value="1.0.2.Final" />
<property name="hibernate-asciidoctor-extensions.version" value="1.0.2.Final" />
<property name="maven-dependency-plugin.version" value="2.10" />
<property name="base.name" value="validation-specification"/>
<property name="spec.styles.dir" value="${basedir}/styles"/>
<property name="document.basedir" value="${basedir}"/>
<property name="validation-api.sourcedir" value="target/validation-api" />
<property name="spec-examples.sourcedir" value="spec-examples/src/test/java" />
<property name="hibernate-asciidoctor-theme.sourcedir" value="target/hibernate-asciidoctor-theme" />
<property name="downloaded-jars.dir" value="target/downloaded-jars" />
<property name="m2-repository.path" value="${user.home}/.m2/repository" />
<property name="maven-central.url" value="https://repo.maven.apache.org/maven2" />
<property name="maven-settings.path">settings-example.xml</property>
<property name="ci-user">jenkins</property>
<!-- Needed for the quick preview only -->
<property name="browser" location="/usr/bin/google-chrome"/>
<target name="clean" description="Delete all generated documentation" depends="clean-html-output, clean-pdf-output, clean-docbook-output, clean-preprocessed-output">
<delete dir="target" />
</target>
<target name="clean-html-output">
<delete dir="target/html" />
</target>
<target name="clean-pdf-output">
<delete dir="target/pdf" />
</target>
<target name="clean-docbook-output">
<delete dir="target/docbook" />
</target>
<target name="clean-preprocessed-output">
<delete dir="target/preprocessed" />
</target>
<target name="downloaded-jars-dir-clean">
<delete dir="${downloaded-jars.dir}" />
</target>
<target name="deep-clean" description="Delete all generated documentation and downloaded libraries" depends="clean, downloaded-jars-dir-clean">
<delete dir="lib" />
</target>
<target name="lib-dir-exists">
<mkdir dir="lib" />
</target>
<target name="pdf-output-dir-exists">
<mkdir dir="target/pdf" />
</target>
<target name="docbook-output-dir-exists">
<mkdir dir="target/docbook" />
</target>
<target name="html-output-dir-exists">
<mkdir dir="target/html" />
</target>
<target name="preprocessed-output-dir-exists">
<mkdir dir="target/preprocessed" />
</target>
<target name="downloaded-jars-dir-exists">
<mkdir dir="${downloaded-jars.dir}" />
</target>
<target name="validation-api-dir-exists">
<delete dir="${validation-api.sourcedir}" />
<mkdir dir="${validation-api.sourcedir}" />
</target>
<target name="hibernate-asciidoctor-theme-dir-exists">
<delete dir="${hibernate-asciidoctor-theme.sourcedir}" />
<mkdir dir="${hibernate-asciidoctor-theme.sourcedir}" />
</target>
<!-- Check that a mvn command is available -->
<property environment="env" />
<available file="mvn" filepath="${env.PATH}" property="mvn-available" />
<target name="have-mvn" unless="${mvn-available}">
<fail message="You need a Maven installation in your path." />
</target>
<target name="have-validation-api-sources" depends="validation-api-dir-exists, have-mvn">
<add-maven-dependency groupId="jakarta.validation" groupDirectory="jakarta/validation" artifactId="jakarta.validation-api" version="${bv.version}" qualifier="jar:sources" dotExtension="-sources.jar" />
<unzip src="${downloaded-jars.dir}/jakarta.validation-api-${bv.version}-sources.jar" dest="${validation-api.sourcedir}" />
</target>
<target name="have-hibernate-asciidoctor-theme" depends="hibernate-asciidoctor-theme-dir-exists, have-mvn">
<add-maven-dependency groupId="org.hibernate.infra" groupDirectory="org/hibernate/infra" artifactId="hibernate-asciidoctor-theme" version="${hibernate-asciidoctor-theme.version}" qualifier="zip" dotExtension=".zip" />
<unzip src="${downloaded-jars.dir}/hibernate-asciidoctor-theme-${hibernate-asciidoctor-theme.version}.zip" dest="target" />
<copy todir="${hibernate-asciidoctor-theme.sourcedir}" overwrite="true">
<fileset dir="resources" />
</copy>
</target>
<target name="have-dependencies" depends="have-mvn, have-validation-api-sources, have-hibernate-asciidoctor-theme">
<add-maven-dependency groupId="org.hibernate.infra" groupDirectory="org/hibernate/infra" artifactId="hibernate-asciidoctor-extensions" version="${hibernate-asciidoctor-extensions.version}" outputDirectory="lib" />
<add-maven-dependency groupId="org.asciidoctor" groupDirectory="org/asciidoctor" artifactId="asciidoctor-ant" version="${asciidoctor-ant.version}" qualifier="jar:core" dotExtension="-core.jar" outputDirectory="lib" />
<add-maven-dependency groupId="org.asciidoctor" groupDirectory="org/asciidoctor" artifactId="asciidoctorj" version="${asciidoctorj.version}" qualifier="jar" outputDirectory="lib" />
<add-maven-dependency groupId="org.asciidoctor" groupDirectory="org/asciidoctor" artifactId="asciidoctorj-pdf" version="${asciidoctorj-pdf.version}" qualifier="jar" outputDirectory="lib" />
<add-maven-dependency groupId="org.jruby" groupDirectory="org/jruby" artifactId="jruby-complete" version="${jruby.version}" qualifier="jar" outputDirectory="lib" />
<add-maven-dependency groupId="com.beust" groupDirectory="com/beust" artifactId="jcommander" version="${jcommander.version}" qualifier="jar" outputDirectory="lib" />
</target>
<target name="render-html" depends="clean-html-output, have-dependencies, html-output-dir-exists">
<renderer outputDirectory="target/html" backend="html" sourceHighlighter="coderay" />
<move file="target/html/index.html" tofile="target/html/${base.name}-${bv.version}.html" />
</target>
<target name="render-docbook" depends="clean-docbook-output, have-dependencies, docbook-output-dir-exists">
<renderer-docbook outputDirectory="target/docbook" sourceHighlighter="coderay" />
</target>
<target name="render-pdf" depends="clean-pdf-output, have-dependencies, pdf-output-dir-exists">
<renderer outputDirectory="target/pdf" backend="pdf" sourceHighlighter="coderay" />
<move file="target/pdf/index.pdf" tofile="target/pdf/${base.name}-${bv.version}.pdf" />
</target>
<target name="generate-preprocessed" depends="have-dependencies, preprocessed-output-dir-exists">
<taskdef uri="antlib:org.asciidoctor.ant" resource="org/asciidoctor/ant/antlib.xml" classpath="lib/jruby-complete-${jruby.version}.jar:
lib/jcommander-${jcommander.version}.jar:
lib/asciidoctorj-${asciidoctorj.version}.jar:
lib/asciidoctorj-pdf-${asciidoctorj-pdf.version}.jar:
lib/hibernate-asciidoctor-extensions-${hibernate-asciidoctor-extensions.version}.jar:
lib/asciidoctor-ant-${asciidoctor-ant.version}-core.jar" />
<asciidoctor:convert
sourceDocumentName="index.asciidoc"
sourceDirectory="sources"
sourceHighlighter="coderay"
outputDirectory="target/preprocessed"
backend="html"
imagesDir="${hibernate-asciidoctor-theme.sourcedir}/images">
<preProcessor className="org.hibernate.infra.asciidoctor.extensions.savepreprocessed.SavePreprocessedOutputPreprocessor" />
<attribute key="license" value="${license}" />
<attribute key="tabsize" value="4" />
<attribute key="validation-api-source-dir" value="../${validation-api.sourcedir}/" />
<attribute key="spec-examples-source-dir" value="../${spec-examples.sourcedir}/" />
<attribute key="bv-version" value="${bv.version}" />
</asciidoctor:convert>
<delete file="target/preprocessed/index.html" />
</target>
<target name="all.doc" depends="render-html,render-pdf" description="Builds the specification documents in all formats" />
<target name="preview" depends="render-html" description="Build and opens the HTML version of the specification in your browser">
<property name="outputDirectory" location="target"/>
<exec executable="${browser}" spawn="true">
<arg value="${outputDirectory}/html/index.html"/>
</exec>
</target>
<target name="determine-git-revision" description="Stores the current git revision in ${repository.version}">
<exec executable="git" outputproperty="repository.revision" failifexecutionfails="true" errorproperty="">
<arg value="describe"/>
<arg value="--tags"/>
<arg value="--always"/>
<arg value="HEAD"/>
</exec>
</target>
<!-- Creates the tck-audit.xml file; Run after updates to the spec and copy+commit to the validation-tck repository -->
<!-- Converts the spec to DocBook before as that's the input format for the audit file creation -->
<target name="create-tck-audit-file" depends="determine-git-revision, render-docbook">
<tstamp>
<format property="NOW" pattern="yyyy-MM-dd HH:mm" locale="en"/>
</tstamp>
<xslt
in="${basedir}/target/docbook/index.xml"
out="target/tck-audit.xml"
force="true"
style="tck-audit.xsl">
<param name="currentDate" expression="${NOW}"/>
<param name="repositoryRevision" expression="${repository.revision}" />
</xslt>
</target>
<!-- Creates the tck-sectionid-renaming.sed file; should be used only one time -->
<!-- Converts the spec to DocBook before as that's the input format for the audit file creation -->
<target name="create-tck-sectionid-renaming" depends="render-docbook">
<tstamp>
<format property="NOW" pattern="yyyy-MM-dd HH:mm" locale="en"/>
</tstamp>
<xslt
in="${basedir}/target/docbook/index.xml"
out="target/tck-sectionid-renaming.sed"
force="true"
style="tck-sectionid-renaming.xsl">
<param name="currentDate" expression="${NOW}"/>
</xslt>
</target>
<!-- Macro definitions -->
<macrodef name="renderer">
<attribute name="outputDirectory" />
<attribute name="backend" />
<attribute name="sourceHighlighter" />
<sequential>
<taskdef uri="antlib:org.asciidoctor.ant" resource="org/asciidoctor/ant/antlib.xml" classpath="lib/jruby-complete-${jruby.version}.jar:
lib/jcommander-${jcommander.version}.jar:
lib/asciidoctorj-${asciidoctorj.version}.jar:
lib/asciidoctorj-pdf-${asciidoctorj-pdf.version}.jar:
lib/hibernate-asciidoctor-extensions-${hibernate-asciidoctor-extensions.version}.jar:
lib/asciidoctor-ant-${asciidoctor-ant.version}-core.jar" />
<asciidoctor:convert
sourceDocumentName="index.asciidoc"
sourceDirectory="sources"
sourceHighlighter="@{sourceHighlighter}"
outputDirectory="@{outputdirectory}"
backend="@{backend}"
imagesDir="${hibernate-asciidoctor-theme.sourcedir}/images">
<treeProcessor className="org.hibernate.infra.asciidoctor.extensions.customnumbering.CustomNumberingProcessor" />
<attribute key="license" value="${license}" />
<attribute key="tabsize" value="4" />
<attribute key="pdf-stylesdir" value="${hibernate-asciidoctor-theme.sourcedir}/theme" />
<attribute key="pdf-style" value="hibernate" />
<attribute key="pdf-fontsdir" value="${hibernate-asciidoctor-theme.sourcedir}/theme/fonts" />
<attribute key="validation-api-source-dir" value="../${validation-api.sourcedir}/" />
<attribute key="spec-examples-source-dir" value="../${spec-examples.sourcedir}/" />
<attribute key="bv-version" value="${bv.version}" />
<attribute key="bv-version-spec" value="${bv.version.spec}" />
<attribute key="bv-version-qualifier" value="${bv.version.qualifier}" />
<attribute key="bv-revdate" value="${bv.revdate}" />
<attribute key="logo" value="${logo}" />
</asciidoctor:convert>
</sequential>
</macrodef>
<macrodef name="renderer-docbook">
<attribute name="outputDirectory" />
<attribute name="sourceHighlighter" />
<sequential>
<taskdef uri="antlib:org.asciidoctor.ant" resource="org/asciidoctor/ant/antlib.xml" classpath="lib/jruby-complete-${jruby.version}.jar:
lib/jcommander-${jcommander.version}.jar:
lib/asciidoctorj-${asciidoctorj.version}.jar:
lib/asciidoctorj-pdf-${asciidoctorj-pdf.version}.jar:
lib/hibernate-asciidoctor-extensions-${hibernate-asciidoctor-extensions.version}.jar:
lib/asciidoctor-ant-${asciidoctor-ant.version}-core.jar" />
<asciidoctor:convert
sourceDocumentName="index.asciidoc"
sourceDirectory="sources"
sourceHighlighter="@{sourceHighlighter}"
outputDirectory="@{outputdirectory}"
backend="docbook"
imagesDir="${hibernate-asciidoctor-theme.sourcedir}/images">
<blockProcessor blockName="tck-testable" className="org.hibernate.infra.asciidoctor.extensions.customroleblock.DocBookCustomRoleBlockProcessor" />
<blockProcessor blockName="tck-not-testable" className="org.hibernate.infra.asciidoctor.extensions.customroleblock.DocBookCustomRoleBlockProcessor" />
<blockProcessor blockName="tck-ignore" className="org.hibernate.infra.asciidoctor.extensions.customroleblock.DocBookCustomRoleBlockProcessor" />
<attribute key="license" value="${license}" />
<attribute key="tabsize" value="4" />
<attribute key="validation-api-source-dir" value="../${validation-api.sourcedir}/" />
<attribute key="spec-examples-source-dir" value="../${spec-examples.sourcedir}/" />
<attribute key="bv-version" value="${bv.version}" />
<attribute key="bv-version-qualifier" value="${bv.version.qualifier}" />
<attribute key="bv-revdate" value="${bv.revdate}" />
</asciidoctor:convert>
</sequential>
</macrodef>
<macrodef name="add-maven-dependency">
<attribute name="groupId" />
<attribute name="groupDirectory" />
<attribute name="artifactId" />
<attribute name="version" />
<attribute name="qualifier" default="jar" />
<attribute name="dotExtension" default=".jar" />
<attribute name="outputDirectory" default="${downloaded-jars.dir}" />
<sequential>
<local name="artifactFileName" />
<local name="isSnapshot" />
<local name="isAlreadyPresent" />
<local name="isInM2" />
<local name="isDownloaded" />
<local name="isCI" />
<condition property="isCI">
<equals arg1="${env.USER}" arg2="${ci-user}" />
</condition>
<property name="artifactFileName" value="@{artifactId}-@{version}@{dotExtension}" />
<condition property="isSnapshot">
<contains string="@{version}" substring="-SNAPSHOT" casesensitive="true" />
</condition>
<available file="@{outputDirectory}/${artifactFileName}" property="isAlreadyPresent" unless:true="${isSnapshot}" />
<delete file="@{outputDirectory}/${artifactFileName}" if:true="${isSnapshot}" />
<available file="${m2-repository.path}/@{groupDirectory}/@{artifactId}/@{version}/${artifactFileName}" property="isInM2" unless:true="${isAlreadyPresent}"></available>
<copy file="${m2-repository.path}/@{groupDirectory}/@{artifactId}/@{version}/${artifactFileName}" todir="@{outputDirectory}" if:true="${isInM2}" />
<condition property="isDownloaded">
<and>
<or>
<istrue value="${isAlreadyPresent}" />
<istrue value="${isInM2}" />
</or>
<not>
<!-- if we are on CI, we download a fresh version anyway -->
<istrue value="${isCI}" />
</not>
</and>
</condition>
<!-- if we are on CI, we clean up the artifact potentially present -->
<delete file="@{outputDirectory}/${artifactFileName}" if:true="${isCI}" quiet="true" />
<download-maven-dependency groupId="@{groupId}" artifactId="@{artifactId}" version="@{version}" qualifier="@{qualifier}" outputDirectory="@{outputDirectory}" unless:true="${isDownloaded}" />
</sequential>
</macrodef>
<macrodef name="download-maven-dependency">
<attribute name="groupId" />
<attribute name="artifactId" />
<attribute name="version" />
<attribute name="qualifier" default="jar" />
<attribute name="outputDirectory" default="${downloaded-jars.dir}" />
<sequential>
<exec executable="mvn" failonerror="true">
<arg value="-s" />
<arg value="${maven-settings.path}" />
<arg value="org.apache.maven.plugins:maven-dependency-plugin:${maven-dependency-plugin.version}:copy"/>
<arg value="-Dartifact=@{groupId}:@{artifactId}:@{version}:@{qualifier}" />
<arg value="-DoutputDirectory=@{outputDirectory}" />
<arg value="-DoverWriteSnapshots=true" />
<arg value="-Dmdep.useBaseVersion=true" />
<arg value="-Dmdep.overWriteSnapshots=true" />
</exec>
</sequential>
</macrodef>
</project>