forked from music-encoding/music-encoding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
247 lines (230 loc) · 11.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
<?xml version="1.0" encoding="UTF-8"?>
<project name="music-encoding" default="dist">
<property name="github.sha" value="github.sha"/>
<property name="github.ref" value="github.ref"/>
<!-- string The branch or tag ref that triggered the workflow run. For branches this in the format refs/heads/<branch_name>, and for tags it is refs/tags/<tag_name> -->
<property name="github.event_name" value="github.event_name"/>
<!--string The name of the event that triggered the workflow run. e.g.: push, pull_request; cf. https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows -->
<loadresource property="github.ref-type">
<string value="${github.ref}"/>
<filterchain>
<tokenfilter>
<replaceregex pattern="([^\/]+\/)([^\/]+)(\/[^\/]+)" replace="\2"/>
</tokenfilter>
</filterchain>
</loadresource>
<loadresource property="github.ref-name">
<string value="${github.ref}"/>
<filterchain>
<tokenfilter>
<replaceregex pattern="([^\/]+\/)+" replace=""/>
</tokenfilter>
</filterchain>
</loadresource>
<loadresource property="windir">
<string value="${basedir}"/>
<filterchain>
<tokenfilter>
<replaceregex pattern="\\" replace="/"/>
</tokenfilter>
</filterchain>
</loadresource>
<property name="version" value="dev"/>
<!-- in XSLT version = att.meiversion defaultVal -->
<property name="dir.dist" value="dist"/>
<property name="dir.dist.guidelines" value="${basedir}/${dir.dist}/guidelines/${version}"/>
<property name="dir.dist.schemata" value="${basedir}/${dir.dist}/schemata/${version}"/>
<path id="mei.classpath">
<pathelement path="${basedir}/lib/xerces/oxygen-patched-xerces-21.1.0.2.jar"/>
<pathelement path="${basedir}/lib/saxon/saxon-he-10.5.jar"/>
</path>
<property name="java.class.path" value="" classpathref="mei.classpath"/>
<condition property="canonicalizedSourcePath" value="${dir.dist.schemata}/mei-source_canonicalized.xml" else="file:/${windir}/${dir.dist}/schemata/${version}/mei-source_canonicalized.xml">
<not>
<os family="windows"/>
</not>
</condition>
<loadresource property="dir.dist.guidelines_win">
<string value="${dir.dist.guidelines}"/>
<filterchain>
<tokenfilter>
<replaceregex pattern="\\" replace="/"/>
</tokenfilter>
</filterchain>
</loadresource>
<condition property="dir.dist.guidelines_adjusted" value="${dir.dist.guidelines}" else="file:/${dir.dist.guidelines_win}">
<not>
<os family="windows"/>
</not>
</condition>
<target name="help">
<echo>================================================</echo>
<echo>= Welcome to the MEI music-encoding ant-script! =</echo>
<echo>================================================</echo>
<echo/>
<echo>This is the default build target with some usage information.</echo>
<echo>You can also call this via 'ant help'</echo>
<echo/>
<echo>To build distribution of canonicalized source, compiled ODDs and customization RNGs run:</echo>
<echo>ant init</echo>
<echo>ant -lib lib/saxon/saxon-he-10.5.jar</echo>
<echo/>
<echo>run 'ant -projecthelp' or 'ant -p' to get more information on the available build targets</echo>
<echo/>
<echo>The following buildproperties are configured in your environment:</echo>
<echo/>
</target>
<target name="clean">
<delete dir="temp/"/>
<delete dir="dist/"/>
</target>
<target name="echo-properties" description="Outputs ">
<echoproperties/>
</target>
<target name="get-local-git-sha" description="Get the local git sha">
<exec executable="git" outputproperty="github.sha.local">
<arg value="describe"/>
<arg value="--match=NeVeRmAtCh"/>
<arg value="--always"/>
<arg value="--abbrev"/>
<arg value="--dirty"/>
</exec>
<echo>Local github.sha: ${github.sha.local}</echo>
</target>
<target name="reset">
<delete dir="temp/"/>
<delete dir="lib/"/>
<delete dir="dist/"/>
</target>
<target name="init" description="initializes the build, e.g. downloads saxon">
<available property="xerces-available" file="${basedir}/lib/xerces/oxygen-patched-xerces-21.1.0.2.jar"/>
<available property="saxon-available" file="${basedir}/lib/saxon/saxon-he-10.5.jar"/>
<antcall target="saxon-prepare"/>
<antcall target="xerces-download"/>
<echo>initialized</echo>
</target>
<target name="saxon-download" unless="${saxon-available}">
<mkdir dir="temp"/>
<get src="https://sourceforge.net/projects/saxon/files/Saxon-HE/10/Java/SaxonHE10-5J.zip/download" dest="temp/"/>
<!-- TODO check for newer releases-->
</target>
<target name="saxon-prepare" depends="saxon-unzip" unless="${saxon-available}">
<delete dir="temp/"/>
</target>
<target name="saxon-unzip" depends="saxon-download" unless="${saxon-available}">
<mkdir dir="lib"/>
<unzip src="temp/download" overwrite="true" dest="lib/saxon/"/>
</target>
<target name="xerces-download" unless="${xerces-available}">
<mkdir dir="lib/xerces/"/>
<get src="https://www.oxygenxml.com/maven/com/oxygenxml/oxygen-patched-xerces/21.1.0.2/oxygen-patched-xerces-21.1.0.2.jar" dest="lib/xerces/"/>
<!--TODO update to latest version -->
</target>
<target name="canonicalize-source" description="Canonicalizes the mei-source.xml, i.e. resolves xincludes and puts result in dist/mei-source_canonicalized.xml" depends="init">
<java classname="net.sf.saxon.Transform" classpathref="mei.classpath">
<arg value="-s:${basedir}/source/mei-source.xml"/>
<arg value="-xsl:${basedir}/utils/canonicalization/copy.xsl"/>
<arg value="-o:${dir.dist.schemata}/mei-source_canonicalized.xml"/>
<arg value="-xi:on"/>
</java>
</target>
<target name="build-compiled-odd" depends="canonicalize-source">
<basename property="odd.basename" file="${customization.path}" suffix=".xml"/>
<echo>${odd.basename}</echo>
<ant dir="submodules/Stylesheets/odd/" antfile="build-to.xml" target="go" inheritall="true">
<property name="inputFile" value="${customization.path}"/>
<property name="outputFile" value="${dir.dist.schemata}/${odd.basename}_compiled.odd"/>
<property name="defaultSource" value="${canonicalizedSourcePath}"/>
<property name="verbose">true</property>
<property name="summaryDoc" value="false"/>
<property name="suppressTEIexamples" value="true"/>
</ant>
</target>
<target name="build-rng" depends="canonicalize-source">
<basename property="odd.basename" file="${customization.path}" suffix=".xml"/>
<echo>building rng ${odd.basename} from ${customization.path}</echo>
<ant dir="submodules/Stylesheets/relaxng/" antfile="build-to.xml" target="dist" inheritall="true" usenativebasedir="true"><!-- check whether nativebasdir is required -->
<property name="inputFile" value="${customization.path}"/>
<property name="outputFile" value="${dir.dist.schemata}/${odd.basename}.rng"/>
<property name="defaultSource" value="${canonicalizedSourcePath}"/>
<property name="verbose">true</property>
</ant>
</target>
<target name="build-guidelines-html" depends="canonicalize-source, get-local-git-sha">
<!-- TODO check dependency try with mei-source.xml -->
<basename property="odd.basename" file="${customization.path}" suffix=".xml"/>
<echo>building HTML guidelines for ${odd.basename} from ${customization.path}</echo>
<echo>github.sha: ${github.sha}</echo>
<echo>github.sha.local: ${github.sha.local}</echo>
<condition property="hash" value="${github.sha}" else="${github.sha.local}">
<not>
<equals arg1="${github.sha}" arg2="github.sha" forcestring="true"/>
</not>
</condition>
<java classname="net.sf.saxon.Transform" classpath="${basedir}/lib/xerces/oxygen-patched-xerces-21.1.0.2.jar;${basedir}/lib/saxon/saxon-he-10.5.jar" failonerror="true">
<arg value="-s:${dir.dist.schemata}/mei-source_canonicalized.xml"/>
<arg value="-xsl:${basedir}/utils/guidelines_xslt/odd2html.xsl"/>
<arg value="-xi:on"/>
<arg value="output.folder=${dir.dist.guidelines_adjusted}/"/>
<arg value="hash=${hash}"/>
</java>
<copy todir="${dir.dist.guidelines}/web/css">
<fileset dir="source/web/css">
<include name="*.css"/>
</fileset>
</copy>
<copy todir="${dir.dist.guidelines}/web/images">
<fileset dir="source/images">
<include name="**/*"/>
</fileset>
</copy>
</target>
<target name="build-customizations">
<antcall target="build-rng">
<param name="customization.path" value="${basedir}/customizations/mei-all.xml"/>
</antcall>
<antcall target="build-rng">
<param name="customization.path" value="${basedir}/customizations/mei-all_anyStart.xml"/>
</antcall>
<antcall target="build-rng">
<param name="customization.path" value="${basedir}/customizations/mei-basic.xml"/>
</antcall>
<antcall target="build-rng">
<param name="customization.path" value="${basedir}/customizations/mei-CMN.xml"/>
</antcall>
<antcall target="build-rng">
<param name="customization.path" value="${basedir}/customizations/mei-Mensural.xml"/>
</antcall>
<antcall target="build-rng">
<param name="customization.path" value="${basedir}/customizations/mei-Neumes.xml"/>
</antcall>
</target>
<target name="build-compiled-odds">
<antcall target="build-compiled-odd">
<param name="customization.path" value="${basedir}/customizations/mei-all.xml"/>
</antcall>
<antcall target="build-compiled-odd">
<param name="customization.path" value="${basedir}/customizations/mei-all_anyStart.xml"/>
</antcall>
<antcall target="build-compiled-odd">
<param name="customization.path" value="${basedir}/customizations/mei-basic.xml"/>
</antcall>
<antcall target="build-compiled-odd">
<param name="customization.path" value="${basedir}/customizations/mei-CMN.xml"/>
</antcall>
<antcall target="build-compiled-odd">
<param name="customization.path" value="${basedir}/customizations/mei-Mensural.xml"/>
</antcall>
<antcall target="build-compiled-odd">
<param name="customization.path" value="${basedir}/customizations/mei-Neumes.xml"/>
</antcall>
</target>
<target name="dist" depends="init">
<!-- TODO does not work with depends="init" only works if init run before -->
<!-- TODO if depends init works add to all other targets and introduce global initialized param so that init will only be reexecuted if init not run before -->
<classfileset refid="mei.classpath"/>
<antcall target="build-customizations"/>
<antcall target="build-compiled-odds"/>
<antcall target="build-guidelines-html"/>
</target>
</project>