-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
225 lines (186 loc) · 8.54 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
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." name="Diagnostics" default="all"
xmlns:if="ant:if"
xmlns:unless="ant:unless">
<description>
diagnostics/build.xml
ANT FILE FOR TEI PROJECT DIAGNOSTICS.
See diagnostics/README.md and diagnostics/instructions.html
for instructions on how to run this diagnostics suite.
Note that this assume oXygen version 17.0 or
higher.
[[Other descriptive things go here]]
</description>
<property name="echo.separator" value="*********************************************"/>
<tstamp>
<format property="date" pattern="yyyy-MM-dd" locale="en"/>
</tstamp>
<condition property="isWindows" value="true">
<os family="windows"/>
</condition>
<condition property="isUnix">
<os family="unix" />
</condition>
<property name="projectDir" value=""/>
<dirname property="antfile.dir" file="${ant.file}"/>
<condition property="promptForFile">
<equals arg1="${projectDir}" arg2=""/>
</condition>
<!-- This is taken with thanks from:
http://stackoverflow.com/questions/4696176/using-ant-how-do-i-open-a-file-in-a-browser -->
<scriptdef name="open" language="javascript">
<attribute name="file" />
<![CDATA[
var location = "file://"+attributes.get("file").toString().replaceAll("\\\\","/");
location = location.toString().replaceAll(" ","%20");
location = java.net.URLEncoder.encode(location, "UTF-8");
location = location.toString().replaceAll("%3A",":");
location = location.toString().replaceAll("%2F","/");
location = location.toString().replaceAll("%25","%");
var uriLocation = java.net.URI.create(location);
var desktop = java.awt.Desktop.getDesktop();
desktop.browse(uriLocation);
]]>
</scriptdef>
<!--Documentation:
property: user.input.string.dir
input: user.input.string
description:
This takes in user.input.string from the
user's input from the Oxygen editor variable
user.input and translates it from a file
to a path to a directory.
-->
<target name="setup" depends="convertForUnix, convertForWindows">
<description>
TARGET: setup
This task creates a diagnostics directory in the projectFolder.
</description>
<echo message="Input: ${projectDir}"/>
<echo message="Input after conversion: ${projectDirFull}"/>
<echo message="Output dir: ${outputDir}"/>
<fail message="Aborting. Directory selection was cancelled.">
<condition>
<equals arg1="${projectDirFull}" arg2=""/>
</condition>
</fail>
<fail message="Project directory not found. Please check input: ${projectDir}.">
<condition>
<not>
<available file="${projectDirFull}" type="dir"/>
</not>
</condition>
</fail>
<echo message="Executing diagnostics on directory ${projectDirFull}"/>
<echo message="Creating diagnostics directory: ${outputDir}"/>
<mkdir dir="${outputDir}"/>
<echo message="Downloading the IANA Media Types listing..."/>
<!-- Download the IANA media types registry-->
<get src="https://www.iana.org/assignments/media-types/media-types.xml" dest="xsl/mimeTypes.xml"/>
</target>
<target name="runDiagnostics">
<description>
TARGET: runDiagnostics
This task runs the diagnostics suite.
</description>
<echo message="${echo.separator}"/>
<echo message="Creating diagnostics output for project: ${projectDirFull}"/>
<echo message="Outputdir: ${outputDir}"/>
<java classname="net.sf.saxon.Transform" classpath="utilities/saxon9he.jar">
<arg value="-s:${antfile.dir}/xsl/diagnostics_master.xsl"/>
<arg value="-xsl:${antfile.dir}/xsl/diagnostics_master.xsl"/>
<arg value="projectDirectory=${projectDirFull}"/>
<arg value="outputDirectory=${outputDir}"/>
<arg value="currDate=${date}"/>
<arg value="--suppressXsltNamespaceCheck:on"/>
</java>
</target>
<target name="convertForWindows" if="${isWindows}">
<pathconvert property="projectDirFull" targetos="windows">
<path path="${projectDir}"/>
<identitymapper/>
</pathconvert>
<property name="outputDir" value="${projectDirFull}\diagnostics_${date}"/>
</target>
<target name="convertForUnix" if="${isUnix}">
<pathconvert property="projectDirFull" targetos="unix">
<path path="${projectDir}"/>
<identitymapper/>
</pathconvert>
<property name="outputDir" value="${projectDirFull}/diagnostics_${date}"/>
</target>
<target name="getDirectory" if="${promptForFile}">
<script language="javascript">
<![CDATA[
var chooser = new javax.swing.JFileChooser();
chooser.setDialogTitle("Choose the directory containing your TEI files");
chooser.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY);
//chooser.setCurrentDirectory(new java.io.File("."));
if (chooser.showOpenDialog(null) == javax.swing.JFileChooser.APPROVE_OPTION) {
dir = chooser.getSelectedFile();
project.setProperty('projectDir', dir);
}
else{
project.setProperty('projectDir', '');
}
]]>
</script>
<echo>You chose this directory: ${projectDir}.</echo>
</target>
<target name="open" depends="open.if.windows, open.if.unix">
<exec executable="open" if:true="${isMac}">
<arg value="${diagnosticsFile}"/>
</exec>
<exec executable="firefox" unless:true="${isMac}">
<arg value="${diagnosticsFile}"/>
</exec>
</target>
<target name="open.if.windows" if="${isWindows}">
<property name="diagnosticsFile" value="${outputDir}\diagnostics.html"/>
<echo message="Opening ${diagnosticsFile}"/>
</target>
<target name="open.if.unix" if="${isUnix}">
<!--Convert the path-->
<property name="diagnosticsFile" value="${outputDir}/diagnostics.html"/>
<!--Now determine if I'm a mac-->
<exec executable="uname"
outputproperty="os.type"/>
<!--Taken, with thanks, from
https://stackoverflow.com/questions/19500112/can-i-detect-if-i-am-on-a-linux-system-and-not-a-generic-unix-system-using-ant-->
<condition property="isMac" value="true" else="false">
<equals arg1="${os.type}" arg2="Darwin"/>
</condition>
<echo message="Opening ${diagnosticsFile}"/>
</target>
<target name="all" depends="getDirectory, setup, runDiagnostics, open">
<description>
TARGET: all
This target is the default and runs all the build processes.
</description>
<!--<antcall target="getDirectory"/>
<antcall target="setup"/>
<antcall target="runDiagnostics"/>-->
</target>
<target name="moeml">
<description>
TARGET: moeml
This is a test target which retrieves a useful set of 1700+ XML
files from the Map of Early Modern London build server and
runs the diagnostics against the set. We use it to test speed
on large collections, and also as part of ongoing quality
control on the MoEML project itself.
</description>
<echo message="${echo.separator}"/>
<echo message="Retrieving the latest build of the MoEML Standard XML collection..."/>
<delete dir="moeml"/>
<mkdir dir="moeml"/>
<get src="http://jenkins.hcmc.uvic.ca/job/MoEML/lastSuccessfulBuild/artifact/static/site/xml/standard/*zip*/standard.zip" dest="moeml/standard.zip" verbose="true"/>
<unzip src="moeml/standard.zip" dest="moeml"/>
<dirname property="moemlDirFull" file="moeml/standard.zip"/>
<delete file="moeml/standard.zip"/>
<antcall target="all">
<param name="projectDir" value="moeml"/>
<param name="projectDirFull" value="${moemlDirFull}"/>
</antcall>
</target>
</project>