-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.xml
536 lines (499 loc) · 23.5 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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
<?xml version="1.0" encoding="UTF-8"?>
<!-- +=====================================================================+ -->
<!-- | | -->
<!-- | b u i l d . x m l | -->
<!-- | | -->
<!-- | abstract: Netbeans/ant build for Audiveris application | -->
<!-- | location: ${basedir}/build.xml | -->
<!-- | | -->
<!-- +=====================================================================+ -->
<!-- Initial NetBeans comments: -->
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project basedir="." default="run" name="audiveris">
<description>
Build, test, and run the Audiveris project
</description>
<!-- Create the time stamp -->
<tstamp/>
<!-- Where generated sources are written -->
<property location="${basedir}/target/generated-sources/java" name="generated.src.dir"/>
<!-- Mercurial -->
<condition else="false" property="hg.present">
<available file="${basedir}/.hg"/>
</condition>
<echo level="verbose" message="hg.present=${hg.present}"/>
<!-- Operating system -->
<condition else="false" property="is.windows">
<os family="windows"/>
</condition>
<echo level="verbose" message="is.windows=${is.windows}"/>
<condition else="false" property="is.mac">
<os family="mac"/>
</condition>
<echo level="verbose" message="is.mac=${is.mac}"/>
<condition else="false" property="is.unix">
<and>
<os family="unix"/>
<not>
<os family="mac"/>
</not>
</and>
</condition>
<echo level="verbose" message="is.unix=${is.unix}"/>
<!-- Environment -->
<property name="name" value="audiveris"/>
<property name="Name" value="Audiveris"/>
<property name="CompanyName" value="${Name} Ltd."/>
<property name="CompanyId" value="${Name}Ltd"/>
<property environment="env"/>
<property location="${basedir}/dev" name="dev.dir"/>
<!-- Environment (user) for Mac variants, if any -->
<!-- TODO: implement this for Mac -->
<!-- Environment (user) for Windows variants, if any -->
<property file="${env.APPDATA}/${CompanyId}/${name}/settings/build.properties"/>
<!-- Environment (user) for Unix variants, if any -->
<property file="${env.XDG_CONFIG_HOME}/${CompanyId}/${name}/settings/build.properties"/>
<property file="${env.HOME}/.config/${CompanyId}/${name}/settings/build.properties"/>
<!-- Environment (developer specific), if any -->
<property file="${dev.dir}/build.properties"/>
<!-- Environment (default) -->
<property file="${dev.dir}/build.default.properties"/>
<!-- Classpaths -->
<path id="build.classpath">
<pathelement path="${build.classes.dir}"/>
</path>
<path id="tools.classpath">
<fileset dir="${tools.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<path id="externals.classpath">
<fileset dir="${externals.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<!-- Import for Mac, Unix & Windows -->
<import file="dev/mac/-mac.xml"/>
<import file="dev/unix/-unix.xml"/>
<import file="dev/windows/-windows.xml"/>
<!-- Import NetBeans implementation targets -->
<import file="nbproject/build-impl.xml"/>
<!-- Needed for ant-contrib tasks -->
<taskdef classpathref="tools.classpath" resource="net/sf/antcontrib/antlib.xml"/>
<!-- === Public Targets ============================================== -->
<!--
There is no more redefined public targets
To build Audiveris on Java Web Start, simply use:
CLI: ant clean jar
NetBeans: "Clean and Build" action
-->
<!-- ========== -->
<!-- installers (obsolete) -->
<!-- ========== -->
<target depends="jar, -installers-mac, -installers-unix, -installers-windows" description="Build installers (obsolete)" name="installers"/>
<!-- =============== -->
<!-- test-regression -->
<!-- =============== -->
<target name="test-regression"
description="Test of non regression on reference data">
<!-- Key properties, if not set yet -->
<property name="ref.scripts" value="dev/validation/ref-scripts" />
<property name="ref.scores" value="dev/validation/ref-scores" />
<property name="new.scores" value="data/scores/new" />
<!-- Make sure the target directory exists -->
<mkdir dir="${new.scores}"/>
<!-- Drive processing through the collection of reference scripts -->
<path id="scripts.path">
<fileset dir="${ref.scripts}"
includes="**/*.script.xml">
</fileset>
</path>
<pathconvert property="names.path" refid="scripts.path" pathsep=",">
<chainedmapper>
<flattenmapper />
<filtermapper>
<replacestring from=".script.xml" to="" />
</filtermapper>
</chainedmapper>
</pathconvert>
<for list="${names.path}" param="name">
<sequential>
<echo><![CDATA[Transcribing @{name} to ${new.scores}]]></echo>
<java jar="${dist.jar}" fork="true">
<jvmarg value="-Dlogback.configurationFile=dev/validation/logback.xml" />
<arg value="-batch"/>
<arg value="-option"/>
<arg value="omr.score.ScoresManager.defaultExportDirectory=${new.scores}"/>
<arg value="-script"/>
<arg value="${ref.scripts}/@{name}.script.xml"/>
</java>
<!-- Clean up existing diff file, if any -->
<delete file="${new.scores}/@{name}.diff" quiet="true" verbose="true"/>
<echo><![CDATA[Comparing @{name}]]></echo>
<java jar="musicxmldiff/dist/musicxmldiff.jar" fork="true">
<jvmarg value="-Dlogback.configurationFile=dev/validation/logback.xml" />
<arg value="-filter"/>
<arg value="musicxmldiff/config/music-filter.xml"/>
<arg value="-control"/>
<arg value="${ref.scores}/@{name}.xml"/>
<arg value="-test"/>
<arg value="${new.scores}/@{name}.xml"/>
<arg value="-output"/>
<arg value="${new.scores}/@{name}.diff"/>
</java>
<concat>
<fileset dir="${new.scores}" includes="@{name}.diff"/>
</concat>
</sequential>
</for>
</target>
<!-- === Internal Targets ============================================ -->
<!-- =============== -->
<!-- -copy-resources -->
<!-- =============== -->
<target description="Populate dist/resources" name="-copy-resources">
<!-- Copy logo and splash to dist/resources -->
<copy todir="${dist.dir}/resources">
<fileset dir="res">
<include name="icon-64.png"/>
<include name="splash.png"/>
</fileset>
</copy>
<!-- Collection of specific files -->
<echo message="== Building ${dist.dir}/resources/specifics.jar"/>
<jar destfile="${dist.dir}/resources/specifics.jar">
<fileset dir="dev" includes="windows/audiveris.bat" />
<fileset dir="dev" includes="unix/audiveris.sh" />
<fileset dir="dev" includes="unix/AddPlugins.sh" />
</jar>
<!-- Populate plugins + examples + docs + train to dist/resources -->
<echo message="== Building ${dist.dir}/resources/plugins.jar"/>
<jar basedir="config" destfile="${dist.dir}/resources/plugins.jar" includes="plugins/**"/>
<echo message="== Building ${dist.dir}/resources/examples.jar"/>
<jar basedir="data" destfile="${dist.dir}/resources/examples.jar" includes="examples/**/*"/>
<echo message="== Building ${dist.dir}/resources/documentation.jar"/>
<jar basedir="data" destfile="${dist.dir}/resources/documentation.jar" includes="www/**/*"/>
<echo message="== Building ${dist.dir}/resources/train.jar"/>
<jar basedir="data" destfile="${dist.dir}/resources/train.jar" includes="train/**/*"/>
</target>
<!-- =================== -->
<!-- -gen-installer-file -->
<!-- =================== -->
<!--
We copy master-installer.jnlp to dist/installer.jnlp and update the
codebase field with proper value. Value depends on option selected in
NetBeans | Web Start dialog, codebase combobox:
- No codebase (JDK 1.6u18) file:/D:/soft/audiveris/dist/
- Local Execution file:/D:/soft/audiveris/dist/
- Web Application deployment [do not use this one]
- User defined (e.g. HTTP deployment) http://audiveris.kenai.com/jnlp
-->
<target depends="-check-codebase" description="Generate installer.jnlp from master-installer.jnlp" name="-gen-installer-file">
<copy file="${basedir}/master-installer.jnlp" overwrite="yes" tofile="${dist.dir}/installer.jnlp"/>
<replace file="${dist.dir}/installer.jnlp" token="%codebase%" value="${my.codebase}"/>
</target>
<!-- =============== -->
<!-- -check-codebase -->
<!-- =============== -->
<target name="-check-codebase">
<!-- Target implementation inspired from jnlp-impl.xml -->
<makeurl file="${dist.dir}" property="my.codebase.url"/>
<condition property="my.codebase" value="${my.codebase.url}">
<or>
<not>
<isset property="jnlp.codebase.type"/>
</not>
<equals arg1="${jnlp.codebase.type}" arg2="local" trim="true"/>
<equals arg1="${jnlp.codebase.type}" arg2="no.codebase" trim="true"/>
</or>
</condition>
<condition property="my.codebase" value="${jnlp.codebase.user}">
<equals arg1="${jnlp.codebase.type}" arg2="user" trim="true"/>
</condition>
<echo level="verbose" message="my.codebase=${my.codebase}"/>
</target>
<!-- =============== -->
<!-- -gen-program-id -->
<!-- =============== -->
<target description="Write a Java class to gather program identification" name="-gen-program-id">
<property location="${generated.src.dir}/omr" name="program.id.dir"/>
<mkdir dir="${program.id.dir}"/>
<property location="${program.id.dir}/ProgramId.java" name="program.id.java"/>
<echo message="== Generating ${program.id.java}"/>
<echo file="${program.id.java}"><![CDATA[
package omr;
/**
* Class {@code ProgramId} provides full program identification.
* This code is generated by an Ant target using Hg information.
*/
public class ProgramId
{
/** Precise company name: {@value} */
public static final java.lang.String COMPANY_NAME = "${CompanyName}";
/** Precise company id: {@value} */
public static final java.lang.String COMPANY_ID = "${CompanyId}";
/** Precise program name: {@value} */
public static final java.lang.String NAME = "${name}";
/** Precise program version: {@value} */
public static final java.lang.String VERSION = "${version}";
/** Precise program revision: {@value} */
public static final java.lang.String REVISION = "${program.revision}";
/** Precise program build: {@value} */
public static final java.lang.String BUILD = "${program.build}";
}]]></echo>
</target>
<!-- ======= -->
<!-- -hg-tip -->
<!-- ======= -->
<target description="Retrieve Hg information" if="${hg.present}" name="-hg-tip">
<exec executable="hg" outputproperty="program.revision">
<arg line="log -r tip --template "{rev}""/>
</exec>
<echo message="== program.revision=${program.revision}"/>
<exec executable="hg" outputproperty="program.build">
<arg line="log -r tip --template "{node|short}""/>
</exec>
<echo message="== program.build=${program.build}"/>
<property name="version.revision" value="${version}.${program.revision}"/>
</target>
<!-- =============== -->
<!-- -installers-mac -->
<!-- =============== -->
<target if="${is.mac}" name="-installers-mac">
<antcall target="mac.-installers"/>
</target>
<!-- ================ -->
<!-- -installers-unix -->
<!-- ================ -->
<target if="${is.unix}" name="-installers-unix">
<antcall target="unix.-installers"/>
</target>
<!-- =================== -->
<!-- -installers-windows -->
<!-- =================== -->
<target if="${is.windows}" name="-installers-windows">
<antcall target="windows.-installers"/>
</target>
<!-- ============== -->
<!-- -javadoc-build -->
<!-- ============== -->
<target depends="-uml, audiveris-impl.-javadoc-build" name="-javadoc-build"/>
<!-- ========== -->
<!-- -no-hg-tip -->
<!-- ========== -->
<target description="Cope with no Hg information" name="-no-hg-tip" unless="${hg.present}">
<property name="version.revision" value="${version}"/>
</target>
<!-- ========== -->
<!-- -pack-libs -->
<!-- ========== -->
<target description="Pack all native libraries into proper jars" name="-pack-libs">
<sequential>
<for list="32bit,64bit" param="arch">
<sequential>
<antcall target="mac.-do-pack-libs">
<param name="bits" value="@{arch}"/>
</antcall>
<antcall target="unix.-do-pack-libs">
<param name="bits" value="@{arch}"/>
</antcall>
<antcall target="windows.-do-pack-libs">
<param name="bits" value="@{arch}"/>
</antcall>
</sequential>
</for>
</sequential>
</target>
<!-- ============ -->
<!-- -post-clean -->
<!-- ============ -->
<!-- Perform cleanup for all OS'es -->
<target depends="mac.-clean, unix.-clean, windows.-clean" name="-post-clean">
<!-- Non OS dependent part -->
<delete verbose="${verbose}">
<fileset dir="${basedir}" includes="*.zip"/>
</delete>
<echo message="== Cleaning up target directory"/>
<delete dir="${basedir}/target" quiet="true" verbose="${verbose}"/>
</target>
<!-- ========= -->
<!-- -post-jar -->
<!-- ========= -->
<target depends="-pack-libs, -copy-resources, -gen-installer-file" name="-post-jar">
<!-- Some house keeping -->
<delete verbose="${verbose}">
<!-- The generated README.TXT is irrelevant -->
<fileset dir="${dist.dir}" includes="README.TXT"/>
<!-- Delete the temporary manifest -->
<!-- <fileset dir="${basedir}" includes="manifest.mf"/>-->
</delete>
</target>
<!-- ========== -->
<!-- -post-init -->
<!-- ========== -->
<target depends="-hg-tip, -no-hg-tip" name="-post-init">
<property name="name.version.revision" value="${name}-${version.revision}"/>
</target>
<!-- ============ -->
<!-- -pre-compile -->
<!-- ============ -->
<target depends="-gen-program-id" name="-pre-compile"/>
<!-- ======== -->
<!-- -pre-jar -->
<!-- ======== -->
<target name="-pre-jar">
<!-- Prepare a (half) temporary manifest -->
<echo message="== Pre-populating ${basedir}/manifest.mf"/>
<echo append="false" file="${basedir}/manifest.mf"><![CDATA[Manifest-Version: 1.0
Built-By: ${CompanyName}
Specification-Title: ${Name}
Specification-Vendor: ${CompanyName}
Specification-Version: ${version}
Implementation-Version: ${version.revision}
]]></echo>
<!-- Purge build/classes folder from documentation items -->
<delete includeEmptyDirs="true" verbose="${verbose}">
<fileset dir="${build.classes.dir}" includes="**/*.html,**/doc-files/*,**/doc-files"/>
</delete>
<!-- Copy all resources to classes dir -->
<echo message="== Copying resources to ${build.classes.dir}"/>
<copy todir="${build.classes.dir}" verbose="$verbose">
<fileset dir="${src.dir}" includes="**/*.properties"/>
<fileset dir="${src.dir}" includes="**/icon*.png"/>
<fileset dir="${basedir}" includes="res/**/*"/>
</copy>
</target>
<!-- ==== -->
<!-- -uml -->
<!-- ==== -->
<!-- Generate UML drawings with Umlet utility -->
<target name="-uml">
<for param="file">
<path>
<fileset dir="${src.dir}" includes="**/*.uxf">
<depend targetdir="${src.dir}">
<mapper from="*.uxf" to="*.jpg" type="glob"/>
</depend>
</fileset>
<fileset dir="${material.dir}" includes="**/*.uxf">
<depend targetdir="${material.dir}">
<mapper from="*.uxf" to="*.jpg" type="glob"/>
</depend>
</fileset>
</path>
<sequential>
<for list="jpg,pdf" param="format">
<sequential>
<echo><![CDATA[Umlet format=@{format} file=@{file}]]></echo>
<java classname="com.baselet.control.Main" classpathref="tools.classpath" fork="true">
<arg value="-action=convert"/>
<arg value="-format=@{format}"/>
<arg value="-filename=@{file}"/>
</java>
</sequential>
</for>
</sequential>
</for>
</target>
<!--
Properties set: unix-like (if it is unix or linux), x64 (if it is 64-bits),
register- size (32 or 64)
<target name="check-architecture" depends="check-family,check-register" >
<echo>Register size: ${register-size}</echo>
<echo>OS Family: ${os-family}</echo>
</target>
===================================================================
Checking the architecture
<target name="check-family" >
<condition property="os-family" value="unix" else="windows">
<os family="unix" />
</condition>
<condition property="unix">
<os family="unix" />
</condition>
</target>
<target name="check-register" depends="reg-unix,reg-windows">
</target>
Test under GNU/Linux
<target name="reg-unix" if="unix">
<exec dir="." executable="uname" outputproperty="result">
<arg line="-m"/>
</exec>
String ends in 64
<condition property="x64">
<matches string="${result}" pattern="^.*64$"/>
</condition>
<condition property="register-size" value="64" else="32">
<isset property="x64"/>
</condition>
</target>
Test under MS/Windows
<target name="reg-windows" unless="unix">
64 bit Windows versions have the variable "ProgramFiles(x86)"
<exec dir="." executable="cmd" outputproperty="result">
<arg line="/c SET ProgramFiles(x86)"/>
</exec>
String ends in "Program Files (x86)"
<condition property="x64">
<matches string="${result}" pattern="^.*=.*Program Files \(x86\)"/>
</condition>
<condition property="register-size" value="64" else="32">
<isset property="x64"/>
</condition>
</target> -->
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar-with-manifest: JAR building (if you are using a manifest)
-do-jar-without-manifest: JAR building (if you are not using a manifest)
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="audiveris-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>