-
Notifications
You must be signed in to change notification settings - Fork 27
/
build.xml
379 lines (333 loc) · 18.9 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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
<!--
Ant build.xml for all Zserio projects.
The following external properties can be set:
zserio.build_dir - Zserio build directory.
zserio.install_dir - Zserio install directory.
zserio_bundle.build_dir - Directory where to put generated bundled tool.
Default is "${zserio.build_dir}/zserio/${ant.java.version}".
zserio_bundle.install_dir - Directory where to install bundled Zserio tool.
Default is "${zserio_install_dir}".
zserio_extensions.build_dir - Zserio extensions build directory.
Default is "${zserio.build_dir}/compiler/extensions".
zserio.deploy.snapshot_flag - Flag whether to deploy snapshot. Default is "yes".
maven.executable - Maven executable to use for deployment. Default is "mvn".
gpg.executable - GnuPG executable to use for artifact signing. Default is "gpg".
-->
<project name="zserio" basedir="." default="jar">
<property name="zserio.build_dir" value="${basedir}/build" />
<property name="zserio.install_dir" value="${basedir}/distr" />
<property name="zserio.deploy_dir" value="${zserio.build_dir}/deploy"/>
<property name="zserio.download_dir" value="${zserio.deploy_dir}/download"/>
<property name="zserio_bundle.build_dir" value="${zserio.build_dir}/zserio/${ant.java.version}" />
<property name="zserio_bundle.install_dir" value="${zserio.install_dir}" />
<property name="zserio.deploy.pom_template_file" value="${basedir}/mvn/deploy_pom_template.xml"/>
<property name="zserio.deploy.settings_template_file" value="${basedir}/mvn/deploy_settings_template.xml"/>
<property name="zserio.deploy.pom_bundle_file" value="${zserio.deploy_dir}/pom_bundle.xml"/>
<property name="zserio.deploy.pom_runtime_file" value="${zserio.deploy_dir}/pom_runtime.xml"/>
<property name="zserio.deploy.settings_file" value="${zserio.deploy_dir}/settings.xml"/>
<property name="zserio_extensions.build_dir" location="${zserio.build_dir}/compiler/extensions"/>
<property name="zserio.jars_dir" value="${zserio.install_dir}/zserio_libs"/>
<property name="commons_cli_jar_name" value="commons-cli-1.4.jar"/>
<property name="freemarker_jar_name" value="freemarker-2.3.28.jar"/>
<property name="antlr_jar_name" value="antlr-4.7.2-complete.jar"/>
<property name="zserio_bundle.jar_file_name" value="zserio.jar"/>
<property name="zserio_bundle.javadocs_jar_file_name" value="zserio_javadocs.jar"/>
<property name="zserio_bundle.sources_jar_file_name" value="zserio_sources.jar"/>
<property name="zserio_bundle.jar_file" value="${zserio_bundle.build_dir}/${zserio_bundle.jar_file_name}"/>
<property name="zserio_bundle.javadocs_jar_file"
value="${zserio_bundle.build_dir}/${zserio_bundle.javadocs_jar_file_name}"/>
<property name="zserio_bundle.sources_jar_file"
value="${zserio_bundle.build_dir}/${zserio_bundle.sources_jar_file_name}"/>
<property name="zserio_bundle.javadocs_dir" value="${zserio_bundle.build_dir}/javadocs"/>
<property name="zserio_bundle.javadocs_src_dir" value="${zserio_bundle.build_dir}/javadocs_src"/>
<uptodate property="zserio_bundle.javadocs_up_to_date">
<srcfiles dir= "${zserio.jars_dir}" includes="*_sources.jar" erroronmissingdir="false"/>
<srcfiles file="build.xml"/>
<mapper type="merge" to="${zserio_bundle.javadocs_dir}/index.html"/>
</uptodate>
<property name="zserio.deploy.snapshot_flag" value="yes"/>
<property name="maven.executable" value="mvn"/>
<property name="gpg.executable" value="gpg"/>
<!-- Zserio release version -->
<loadfile
encoding="UTF-8"
property="zserio.version"
srcFile="${basedir}/compiler/core/src/zserio/tools/ZserioVersion.java">
<filterchain>
<striplinebreaks/>
<tokenfilter>
<replaceregex
pattern='.*VERSION_STRING\s*=\s*"([0-9]+.[0-9]+.[0-9]+(-[A-Za-z0-9]+)?)".*'
replace="\1"/>
</tokenfilter>
</filterchain>
</loadfile>
<include file="${basedir}/compiler/core/build.xml"/>
<target name="clean" depends="zserio_core.clean"/>
<target name="compile" depends="zserio_core.compile"/>
<target name="jar" depends="zserio_core.jar"/>
<target name="install" depends="zserio_core.install"/>
<target name="spotbugs" depends="zserio_core.spotbugs"/>
<target name="test" depends="zserio_core.test"/>
<!-- Bundled Zserio -->
<target name="zserio_bundle.clean" depends="clean">
<delete dir="${zserio_bundle.build_dir}"/>
</target>
<target name="zserio_bundle.javadocs" unless="zserio_bundle.javadocs_up_to_date">
<tstamp>
<format property="timestamp" pattern="yyyy-MM-dd HH:mm:ss"/>
</tstamp>
<unzip dest="${zserio_bundle.javadocs_src_dir}">
<fileset dir="${zserio.jars_dir}" includes="*_sources.jar"/>
</unzip>
<fileset id="zserio_bundle.sources" dir="${zserio_bundle.javadocs_src_dir}"/>
<javadoc packagenames="zserio.*" destdir="${zserio_bundle.javadocs_dir}"
failonerror="true" failonwarning="true" useexternalfile="true">
<arg value="-Xdoclint:-missing"/>
<fileset refid="zserio_bundle.sources"/>
<doctitle>
<![CDATA[<h1>Zserio Bundle</h1><h2>Version ${zserio.version}</h2]]>
</doctitle>
<bottom>
<![CDATA[<i>Last updated ${timestamp}</i>]]>
</bottom>
<classpath>
<fileset dir="${zserio.jars_dir}">
<include name="*.jar"/>
</fileset>
</classpath>
</javadoc>
</target>
<target name="zserio_bundle.jar" depends="install, zserio_bundle.javadocs">
<mkdir dir="${zserio_bundle.build_dir}"/>
<concat destfile="${zserio_bundle.build_dir}/metainf/services/zserio.tools.Extension">
<fileset dir="${zserio_extensions.build_dir}" includes="**/metainf/**/*" erroronmissingdir="false"/>
</concat>
<jar destfile="${zserio_bundle.jar_file}" duplicate="preserve">
<restrict>
<not>
<name name="META-INF/*"/>
</not>
<archives>
<zips>
<fileset dir="${zserio.jars_dir}" includes="*.jar"
excludes="${commons_cli_jar_name} ${freemarker_jar_name} ${antlr_jar_name} *_sources.jar *_javadocs.jar"/>
</zips>
</archives>
</restrict>
<zipfileset src="${zserio.jars_dir}/${commons_cli_jar_name}" excludes="META-INF/*"/>
<zipfileset src="${zserio.jars_dir}/${commons_cli_jar_name}" includes="META-INF/LICENSE.txt"
fullpath="META-INF/LICENSE_COMMONS_CLI.txt"/>
<zipfileset src="${zserio.jars_dir}/${freemarker_jar_name}" excludes="META-INF/*"/>
<zipfileset src="${zserio.jars_dir}/${freemarker_jar_name}" includes="META-INF/LICENSE"
fullpath="META-INF/LICENSE_FREEMARKER.txt"/>
<zipfileset src="${zserio.jars_dir}/${antlr_jar_name}" excludes="META-INF/*"/>
<manifest>
<attribute name="Main-Class" value="zserio.tools.ZserioTool"/>
<attribute name="Implementation-Version" value="${zserio.version}"/>
</manifest>
<metainf dir="${zserio_bundle.build_dir}/metainf" includes="**/*" erroronmissingdir="false"/>
</jar>
<jar destfile="${zserio_bundle.javadocs_jar_file}">
<fileset dir="${zserio_bundle.javadocs_dir}">
<include name="**"/>
</fileset>
<manifest>
<attribute name="Implementation-Version" value="${zserio.version}"/>
</manifest>
</jar>
<jar destfile="${zserio_bundle.sources_jar_file}">
<archives>
<zips>
<zipfileset dir="${zserio.jars_dir}" includes="*_sources.jar"/>
</zips>
</archives>
<manifest>
<attribute name="Implementation-Version" value="${zserio.version}"/>
</manifest>
</jar>
</target>
<target name="zserio_bundle.install" depends="zserio_bundle.jar">
<mkdir dir="${zserio_bundle.install_dir}"/>
<copy file="${zserio_bundle.jar_file}" todir="${zserio_bundle.install_dir}"/>
<copy file="${zserio_bundle.javadocs_jar_file}" todir="${zserio_bundle.install_dir}"/>
<copy file="${zserio_bundle.sources_jar_file}" todir="${zserio_bundle.install_dir}"/>
</target>
<target name="zserio_bundle.test" depends="zserio_bundle.install">
</target>
<target name="download_zserio">
<mkdir dir="${zserio.download_dir}"/>
<property name="latest_release_json_full_name" value="${zserio.download_dir}/latest_release.json"/>
<get src="https://api.github.com/repos/ndsev/zserio/releases/latest"
dest="${latest_release_json_full_name}" usetimestamp="true"/>
<loadfile encoding="UTF-8" property="latest_zserio_version" srcFile="${latest_release_json_full_name}">
<filterchain>
<striplinebreaks/>
<tokenfilter>
<replaceregex pattern='.*"tag_name"\s*:\s*"v([0-9\.]+)".*' replace="\1"/>
</tokenfilter>
</filterchain>
</loadfile>
<property name="github_https_download" value="https://github.com/ndsev/zserio/releases/download"/>
<property name="zserio_bin_zip_name" value="zserio-${latest_zserio_version}-bin.zip"/>
<property name="zserio_bin_zip_full_name" value="${zserio.download_dir}/${zserio_bin_zip_name}"/>
<get src="${github_https_download}/v${latest_zserio_version}/${zserio_bin_zip_name}"
dest="${zserio_bin_zip_full_name}" usetimestamp="true"/>
<unzip src="${zserio_bin_zip_full_name}" dest="${zserio.download_dir}"/>
<property name="zserio_runtime_libs_zip_name" value="zserio-${latest_zserio_version}-runtime-libs.zip"/>
<property name="zserio_runtime_libs_zip_full_name"
value="${zserio.download_dir}/${zserio_runtime_libs_zip_name}"/>
<get src="${github_https_download}/v${latest_zserio_version}/${zserio_runtime_libs_zip_name}"
dest="${zserio_runtime_libs_zip_full_name}" usetimestamp="true"/>
<unzip src="${zserio_runtime_libs_zip_full_name}" dest="${zserio.download_dir}"/>
<condition property="zserio.deploy.version"
value="${latest_zserio_version}-SNAPSHOT" else="${latest_zserio_version}">
<equals arg1="${zserio.deploy.snapshot_flag}" arg2="yes"/>
</condition>
</target>
<target name="generate_pom_bundle">
<local name="pom.artifactd_id"/>
<local name="pom.version"/>
<local name="pom.name"/>
<local name="pom.description"/>
<property name="pom.artifactd_id" value="zserio"/>
<property name="pom.version" value="${zserio.deploy.version}"/>
<property name="pom.name" value="Zserio Compiler"/>
<property name="pom.description" value="Zserio Serialization Framework Compiler"/>
<copy file="${zserio.deploy.pom_template_file}" tofile="${zserio.deploy.pom_bundle_file}">
<filterchain>
<filterreader classname="org.apache.tools.ant.filters.ExpandProperties"/>
</filterchain>
</copy>
</target>
<target name="generate_pom_runtime">
<local name="pom.artifactd_id"/>
<local name="pom.version"/>
<local name="pom.name"/>
<local name="pom.description"/>
<property name="pom.artifactd_id" value="zserio-runtime"/>
<property name="pom.version" value="${zserio.deploy.version}"/>
<property name="pom.name" value="Zserio Runtime"/>
<property name="pom.description" value="Java Runtime library for Zserio Serialization Framework"/>
<copy file="${zserio.deploy.pom_template_file}" tofile="${zserio.deploy.pom_runtime_file}">
<filterchain>
<filterreader classname="org.apache.tools.ant.filters.ExpandProperties"/>
</filterchain>
</copy>
</target>
<target name="generate_settings">
<property name="zserio.deploy.repository_id" value="ossrh"/>
<property name="settings.repository_id" value="${zserio.deploy.repository_id}"/>
<copy file="${zserio.deploy.settings_template_file}" tofile="${zserio.deploy.settings_file}">
<filterchain>
<filterreader classname="org.apache.tools.ant.filters.ExpandProperties"/>
</filterchain>
</copy>
</target>
<target name="deploy_clean">
<delete dir="${zserio.deploy_dir}"/>
</target>
<target name="deploy" depends="deploy_clean, download_zserio, generate_pom_runtime, generate_pom_bundle,
generate_settings">
<property name="zserio.deploy.release_repo_url"
value="https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"/>
<property name="zserio.deploy.snapshot_repo_url"
value="https://s01.oss.sonatype.org/content/repositories/snapshots"/>
<condition property="zserio.deploy.repo_url"
value="${zserio.deploy.snapshot_repo_url}" else="${zserio.deploy.release_repo_url}">
<equals arg1="${zserio.deploy.snapshot_flag}" arg2="yes"/>
</condition>
<echo message="Deploying zserio version '${zserio.deploy.version}' to '${zserio.deploy.repo_url}'"/>
<input message="Please enter repository token name: "
addproperty="zserio.deploy.user_name">
<handler classname="org.apache.tools.ant.input.DefaultInputHandler"/>
</input>
<input message="Please enter repository token password: "
addproperty="zserio.deploy.password">
<handler classname="org.apache.tools.ant.input.SecureInputHandler"/>
</input>
<!-- sign and deploy the zserio compiler artifact -->
<exec executable="${maven.executable}" failonerror="true">
<arg value="gpg:sign-and-deploy-file"/>
<arg value="--settings"/>
<arg value="${zserio.deploy.settings_file}"/>
<arg value="-Dgpg.executable=${gpg.executable}"/>
<arg value="-Dfile=${zserio.download_dir}/${zserio_bundle.jar_file_name}"/>
<arg value="-Durl=${zserio.deploy.repo_url}"/>
<arg value="-DrepositoryId=${zserio.deploy.repository_id}"/>
<arg value="-DpomFile=${zserio.deploy.pom_bundle_file}"/>
<arg value="-DrepositoryUsername=${zserio.deploy.user_name}"/>
<arg value="-DrepositoryPassword=${zserio.deploy.password}"/>
</exec>
<!-- sign and deploy the zserio compiler sources artifact -->
<exec executable="${maven.executable}" failonerror="true">
<arg value="gpg:sign-and-deploy-file"/>
<arg value="--settings"/>
<arg value="${zserio.deploy.settings_file}"/>
<arg value="-Dgpg.executable=${gpg.executable}"/>
<arg value="-Dfile=${zserio.download_dir}/${zserio_bundle.sources_jar_file_name}"/>
<arg value="-Durl=${zserio.deploy.repo_url}"/>
<arg value="-DrepositoryId=${zserio.deploy.repository_id}"/>
<arg value="-Dclassifier=sources"/>
<arg value="-DpomFile=${zserio.deploy.pom_bundle_file}"/>
<arg value="-DrepositoryUsername=${zserio.deploy.user_name}"/>
<arg value="-DrepositoryPassword=${zserio.deploy.password}"/>
</exec>
<!-- sign and deploy the zserio compiler javadocs artifact -->
<exec executable="${maven.executable}" failonerror="true">
<arg value="gpg:sign-and-deploy-file"/>
<arg value="--settings"/>
<arg value="${zserio.deploy.settings_file}"/>
<arg value="-Dgpg.executable=${gpg.executable}"/>
<arg value="-Dfile=${zserio.download_dir}/${zserio_bundle.javadocs_jar_file_name}"/>
<arg value="-Durl=${zserio.deploy.repo_url}"/>
<arg value="-DrepositoryId=${zserio.deploy.repository_id}"/>
<arg value="-Dclassifier=javadoc"/>
<arg value="-DpomFile=${zserio.deploy.pom_bundle_file}"/>
<arg value="-DrepositoryUsername=${zserio.deploy.user_name}"/>
<arg value="-DrepositoryPassword=${zserio.deploy.password}"/>
</exec>
<!-- sign and deploy the zserio runtime artifact -->
<property name="zserio.download_java_runtime_dir" value="${zserio.download_dir}/runtime_libs/java/"/>
<exec executable="${maven.executable}" failonerror="true">
<arg value="gpg:sign-and-deploy-file"/>
<arg value="--settings"/>
<arg value="${zserio.deploy.settings_file}"/>
<arg value="-Dgpg.executable=${gpg.executable}"/>
<arg value="-Dfile=${zserio.download_java_runtime_dir}/zserio_runtime.jar"/>
<arg value="-Durl=${zserio.deploy.repo_url}"/>
<arg value="-DrepositoryId=${zserio.deploy.repository_id}"/>
<arg value="-DpomFile=${zserio.deploy.pom_runtime_file}"/>
<arg value="-DrepositoryUsername=${zserio.deploy.user_name}"/>
<arg value="-DrepositoryPassword=${zserio.deploy.password}"/>
</exec>
<!-- sign and deploy the zserio runtime sources artifact -->
<exec executable="${maven.executable}" failonerror="true">
<arg value="gpg:sign-and-deploy-file"/>
<arg value="--settings"/>
<arg value="${zserio.deploy.settings_file}"/>
<arg value="-Dgpg.executable=${gpg.executable}"/>
<arg value="-Dfile=${zserio.download_java_runtime_dir}/zserio_runtime_sources.jar"/>
<arg value="-Durl=${zserio.deploy.repo_url}"/>
<arg value="-DrepositoryId=${zserio.deploy.repository_id}"/>
<arg value="-Dclassifier=sources"/>
<arg value="-DpomFile=${zserio.deploy.pom_runtime_file}"/>
<arg value="-DrepositoryUsername=${zserio.deploy.user_name}"/>
<arg value="-DrepositoryPassword=${zserio.deploy.password}"/>
</exec>
<!-- sign and deploy the zserio runtime javadocs artifact -->
<exec executable="${maven.executable}" failonerror="true">
<arg value="gpg:sign-and-deploy-file"/>
<arg value="--settings"/>
<arg value="${zserio.deploy.settings_file}"/>
<arg value="-Dgpg.executable=${gpg.executable}"/>
<arg value="-Dfile=${zserio.download_java_runtime_dir}/zserio_runtime_javadocs.jar"/>
<arg value="-Durl=${zserio.deploy.repo_url}"/>
<arg value="-DrepositoryId=${zserio.deploy.repository_id}"/>
<arg value="-Dclassifier=javadoc"/>
<arg value="-DpomFile=${zserio.deploy.pom_runtime_file}"/>
<arg value="-DrepositoryUsername=${zserio.deploy.user_name}"/>
<arg value="-DrepositoryPassword=${zserio.deploy.password}"/>
</exec>
</target>
</project>