-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.gradle
218 lines (191 loc) · 5.82 KB
/
build.gradle
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
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://dev.saxonica.com/maven"
}
}
dependencies {
classpath group: "net.sf.saxon", name: "Saxon-HE", version: "11.4"
}
}
plugins {
id "java"
}
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://dev.saxonica.com/maven"
}
}
configurations.all {
resolutionStrategy {
force 'xml-apis:xml-apis:1.4.01'
}
}
configurations {
saxon.extendsFrom(implementation)
}
dependencies {
implementation (
[group: "net.sf.saxon", name: "Saxon-HE", version: "11.4"],
[group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.30'],
[group: 'org.nineml', name: 'coffeepot', version: '1.99.11']
)
}
def getenv(String name) {
if (System.getenv(name) == null) {
return ""
} else {
return System.getenv(name)
}
}
println("Building with Java version ${System.getProperty('java.version')}")
if (getenv('CIWORKFLOW') != '') {
println("Building for CI commit ${getenv('CI_SHA1')}");
println("Building for CI branch ${getenv('CI_BRANCH')}");
} else {
println("Building locally...")
}
defaultTasks 'publish'
task publish(
group: "publish",
dependsOn: ["formatSpec", "copyResources", "ixmlInXml", "ixmlInIxml", "publishTests"],
description: "Publish the current specification") {
}
task extractIxmlInIxml(
type: JavaExec,
description: "Extract the iXML Grammar in iXML"
) {
inputs.files fileTree(dir: "${projectDir}/src")
inputs.files fileTree(dir: "${projectDir}/build-tools")
outputs.file "${buildDir}/current/ixml.ixml"
classpath = configurations.saxon
mainClass = "net.sf.saxon.Transform"
args "-s:${projectDir}/src/ixml-specification.html",
"-xsl:${projectDir}/build-tools/extract-ixml.xsl",
"-o:${buildDir}/current/ixml.ixml",
"ci-sha1=${getenv('CI_SHA1')}",
"ci-build-num=${getenv('CI_BUILD_NUM')}",
"ci-project-username=${getenv('CI_PROJECT_USERNAME')}",
"ci-project-reponame=${getenv('CI_PROJECT_REPONAME')}",
"ci-branch=${getenv('CI_BRANCH')}",
"ci-tag=${getenv('CI_TAG')}",
"ci-pull=${getenv('CI_PULL')}"
}
task extractIxmlInXml(
type: JavaExec,
dependsOn: ['extractIxmlInIxml', 'copyResources'],
description: "Extract the iXML Grammar in XML"
) {
inputs.files fileTree(dir: "${buildDir}/current/ixml.ixml")
outputs.file "${buildDir}/current/ixml.xml"
classpath = configurations.saxon
mainClass = "org.nineml.coffeepot.Main"
args "-i:${buildDir}/current/ixml.ixml",
"-o:${buildDir}/current/ixml.xml",
'-pp'
}
task formatSpec(
type: JavaExec,
dependsOn: ['extractIxmlInIxml', 'extractIxmlInXml', 'copyResources'],
description: "Copy the specification into the build directory"
) {
inputs.files fileTree(dir: "${projectDir}/src")
inputs.files fileTree(dir: "${projectDir}/build-tools")
inputs.file extractIxmlInIxml.outputs.getFiles().getSingleFile()
inputs.file extractIxmlInXml.outputs.getFiles().getSingleFile()
outputs.file "${buildDir}/current/index.html"
classpath = configurations.saxon
mainClass = "net.sf.saxon.Transform"
args "-s:${projectDir}/src/ixml-specification.html",
"-xsl:${projectDir}/build-tools/format.xsl",
"-o:${buildDir}/current/index.html",
"ci-sha1=${getenv('CI_SHA1')}",
"ci-build-num=${getenv('CI_BUILD_NUM')}",
"ci-project-username=${getenv('CI_PROJECT_USERNAME')}",
"ci-project-reponame=${getenv('CI_PROJECT_REPONAME')}",
"ci-branch=${getenv('CI_BRANCH')}",
"ci-tag=${getenv('CI_TAG')}",
"ci-pull=${getenv('CI_PULL')}"
}
task copyResources(
description: "Copy the other resources into the build directory"
) {
inputs.files fileTree(dir: "${projectDir}/src/js")
inputs.files fileTree(dir: "${projectDir}/src/css")
outputs.files fileTree(dir: "${buildDir}/current/js")
outputs.files fileTree(dir: "${buildDir}/current/css")
outputs.file "${buildDir}/current/ixml.ixml"
outputs.file "${buildDir}/current/ixml.xml"
outputs.file "${buildDir}/current/errata.html"
doLast {
copy {
into "${buildDir}/current"
from "${projectDir}/src"
include "css/**"
include "js/**"
include "errata.html"
}
}
}
task ixmlInXml(
type: JavaExec,
dependsOn: ['extractIxmlInXml'],
description: "Format ixml.xml for the web"
) {
inputs.files fileTree(dir: "${projectDir}/build-tools")
inputs.file "${buildDir}/current/ixml.xml"
outputs.file "${buildDir}/current/ixml.xml.html"
classpath = configurations.saxon
mainClass = "net.sf.saxon.Transform"
args "-s:${buildDir}/current/ixml.xml",
"-xsl:${projectDir}/build-tools/format-xml.xsl",
"-o:${buildDir}/current/ixml.xml.html"
}
task ixmlInIxml(
type: JavaExec,
dependsOn: ['extractIxmlInIxml', 'copyResources'],
description: "Format ixml.ixml for the web"
) {
inputs.files fileTree(dir: "${projectDir}/build-tools")
inputs.file extractIxmlInIxml.outputs.getFiles().getSingleFile()
outputs.file "${buildDir}/current/ixml.ixml.html"
classpath = configurations.saxon
mainClass = "net.sf.saxon.Transform"
args "-it",
"-xsl:${projectDir}/build-tools/format-ixml.xsl",
"-o:${buildDir}/current/ixml.ixml.html",
"ixml.ixml=${extractIxmlInIxml.outputs.getFiles().getSingleFile()}"
}
// ============================================================
task publishTests(
description: "Format the test suite for the web"
) {
doFirst {
mkdir "${buildDir}/test-catalog"
}
doLast {
javaexec {
classpath = configurations.saxon
mainClass = "net.sf.saxon.Transform"
args "-s:${projectDir}/tests/test-catalog.xml",
"-xsl:${projectDir}/tests/tools/to-html.xsl",
"-o:${buildDir}/test-catalog/index.html"
}
}
doLast {
copy {
into "${buildDir}/test-catalog/css/"
from "${projectDir}/tools/css/"
}
}
doLast {
copy {
into "${buildDir}/test-catalog/img/"
from "${projectDir}/tools/img/"
}
}
}