-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
313 lines (284 loc) · 9.44 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
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
/*
* The build dependencies
*/
buildscript {
ext {
oml = '2.+'
owl = '2.+'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.yaml:snakeyaml:2.+"
classpath "io.opencaesar.owl:owl-fuseki-gradle:$owl"
classpath "io.opencaesar.owl:owl-shacl-gradle:$owl"
classpath "io.opencaesar.owl:owl-query-gradle:$owl"
classpath "io.opencaesar.owl:owl-load-gradle:$owl"
classpath "io.opencaesar.owl:owl-save-gradle:$owl"
classpath "io.opencaesar.owl:owl-reason-gradle:$owl"
classpath "io.opencaesar.owl:owl-doc-gradle:$owl"
classpath "io.opencaesar.oml:oml-merge-gradle:$oml"
classpath "io.opencaesar.adapters:oml2owl-gradle:$oml"
classpath "io.opencaesar.adapters:owl2oml-gradle:$oml"
}
}
/*
* The applied plugins
*/
apply plugin: 'base'
apply plugin: 'oml'
/*
* Read the configuration files
*/
ext.oml = new org.yaml.snakeyaml.Yaml().load(file(".oml/oml.yml").text)
/*
* Dataset-specific variables
*/
var dataset_name = hasProperty("dataset") ? getProperty("dataset") : oml.datasets.entrySet().iterator().next().getKey()
oml.dataset = oml.datasets.get(dataset_name)
oml.dataset.name = dataset_name
/*
* The repositories to look up OML dependencies in
*/
repositories {
mavenLocal()
mavenCentral()
}
/*
* The OML dependencies
*/
dependencies {
oml.dependencies.each { oml it }
}
/*
* A task to extract and merge the OML dependencies
* @seeAlso https://github.com/opencaesar/oml-tools/blob/master/oml-merge/README.md
*/
task downloadDependencies(type:io.opencaesar.oml.merge.OmlMergeTask, group:"oml", dependsOn: configurations.oml) {
inputZipPaths = configurations.oml.files
outputCatalogFolder = file('build/oml')
}
/*
* A task to convert the OML catalog to OWL catalog
* @seeAlso https://github.com/opencaesar/owl-adapter/blob/master/oml2owl/README.md
*/
task omlToOwl(type:io.opencaesar.oml2owl.Oml2OwlTask, group:"oml", dependsOn: downloadDependencies) {
inputCatalogPath = file('catalog.xml')
outputCatalogPath = file('build/owl/catalog.xml')
generateRules = true
}
/*
* A task to generate documentation for the OWL catalog
* @seeAlso https://github.com/opencaesar/owl-tools/blob/master/owl-doc/README.md
*/
task generateDocs (type: io.opencaesar.owl.doc.OwlDocTask, dependsOn: omlToOwl) {
// OML catalog
inputCatalogPath = file('build/owl/catalog.xml')
// OML catalog title
inputCatalogTitle = oml.project.title
// OML catalog version
inputCatalogVersion = oml.project.version
// Output folder
outputFolderPath = file('build/docs')
// Output case sensitivie path
outputCaseSensitive = org.gradle.internal.os.OperatingSystem.current().isLinux()
}
/*
* A task to run the Openllet reasoner on the OWL catalog
* @seeAlso https://github.com/opencaesar/owl-tools/blob/master/owl-reason/README.md
*/
task reason(type:io.opencaesar.owl.reason.OwlReasonTask, group:"oml", dependsOn: omlToOwl) {
catalogPath = file('build/owl/catalog.xml')
inputOntologyIri = oml.dataset.iri
specs = [
"$oml.dataset.iri/classes = ALL_SUBCLASS",
"$oml.dataset.iri/properties = INVERSE_PROPERTY | ALL_SUBPROPERTY",
"$oml.dataset.iri/individuals = ALL_INSTANCE | DATA_PROPERTY_VALUE | OBJECT_PROPERTY_VALUE | SAME_AS"
]
reportPath = file('build/logs/reasoning.xml')
uniqueNames = true
}
/*
* Start the headless Fuseki server
* @seeAlso https://github.com/opencaesar/owl-tools/blob/master/owl-doc/README.md
*/
task startFuseki(type: io.opencaesar.owl.fuseki.StartFusekiTask, group:"oml", dependsOn: reason) {
configurationPath = file(".oml/fuseki.ttl")
outputFolderPath = file(".fuseki")
webUI = true
}
/*
* Stop the headless Fuseki server
* @seeAlso https://github.com/opencaesar/owl-tools/blob/master/owl-fuseki/README.md
*/
task stopFuseki(type: io.opencaesar.owl.fuseki.StopFusekiTask, group:"oml") {
outputFolderPath = startFuseki.outputFolderPath
}
/*
* A task to load the dataset to a SPARQL tdb endpoint
* @seeAlso https://github.com/opencaesar/owl-tools/blob/master/owl-load/README.md
*/
task loadTdb(type:io.opencaesar.owl.load.OwlLoadTask, group:"oml", dependsOn: startFuseki) {
inputs.files(startFuseki.outputFolderPath.toString()+"fuseki.pid") // rerun when fuseki restarts
catalogPath = file('build/owl/catalog.xml')
endpointURL = oml.dataset.url+".tdb"
fileExtensions = ['owl', 'ttl']
iris = [ "$oml.dataset.iri" ]
loadToDefaultGraph = false
}
/*
* A task to load the dataset to a SPARQL inference endpoint
* @seeAlso https://github.com/opencaesar/owl-tools/blob/master/owl-load/README.md
*/
task loadInf(type:io.opencaesar.owl.load.OwlLoadTask, group:"oml", dependsOn: startFuseki) {
inputs.files(startFuseki.outputFolderPath.toString()+"fuseki.pid") // rerun when fuseki restarts
catalogPath = file('build/owl/catalog.xml')
endpointURL = oml.dataset.url+".inf"
fileExtensions = ['owl', 'ttl']
iris = [ "$oml.dataset.iri/classes", "$oml.dataset.iri/properties" ]
loadToDefaultGraph = true
}
/*
* A task to load the dataset to SPARQL endpoints
*/
task load(group:"oml", dependsOn: [loadInf, loadTdb])
/*
* A task to run a set of SPARQL queries on a Fuseki dataset endpoint
* @seeAlso https://github.com/opencaesar/owl-tools/blob/master/owl-query/README.md
*/
task query(type:io.opencaesar.owl.query.OwlQueryTask, group:"oml", dependsOn: load) {
inputs.files(load.inputs.files) // rerun when the dataset changes
endpointURL = oml.dataset.url+".inf"
queryPath = oml.dataset.queries ? file(oml.dataset.queries) : null
resultPath = file("build/results/${oml.dataset.name}")
format = 'json'
}
/*
* A task to run a set of SHACL validation rules on a dataset endpoint
* @seeAlso https://github.com/opencaesar/owl-tools/blob/master/owl-shacl/README.md
*/
task validate(type:io.opencaesar.owl.shacl.OwlShaclTask, group:"oml", dependsOn: load) {
inputs.files(load.inputs.files) // rerun when the dataset changes
endpointURL = oml.dataset.url
queryPath = oml.dataset.validations ? file(oml.dataset.validations) : null
resultPath = file("build/logs/${oml.dataset.name}")
}
/*
* A task to save a Fuseki dataset to an OWL catalog
* @seeAlso https://github.com/opencaesar/owl-tools/blob/master/owl-save/README.md
*/
task saveTdb(type:io.opencaesar.owl.save.OwlSaveTask, group:"oml") {
inputs.files(startFuseki.outputFolderPath.toString()+"fuseki.pid") // rerun when fuseki restarts
endpointURL = oml.dataset.url+".tdb"
catalogPath = file("build/save/${oml.dataset.name}/catalog.xml")
fileExtension = 'ttl'
}
/*
* A task to convert an OWL catalog to OML catalog
* @seeAlso https://github.com/opencaesar/owl-adapter/blob/master/owl2oml/README.md
*/
task owlToOml(type:io.opencaesar.owl2oml.Owl2OmlTask, group:"oml", dependsOn: [downloadDependencies, saveTdb]) {
inputCatalogPath = saveTdb.catalogPath
outputCatalogPath = file('catalog.xml')
sourcePaths = oml.dataset.sources.collect{f -> file(f)}
inputFileExtensions = ['ttl']
outputFileExtension = 'oml'
}
/*
* A task to save a Fuseki dataset to OML catalog
*/
task save(group:"oml", dependsOn: [owlToOml])
/*
* A task to check the project's build artifacts
* @seeAlso https://docs.gradle.org/current/userguide/base_plugin.html
*/
tasks.named('check') {
dependsOn reason
}
/*
* Define project's artifacts
*/
task omlZip(type: Zip, group:"oml") {
from file('src/oml')
include "**/*.oml"
destinationDirectory = file('build/libs')
archiveBaseName = oml.dataset.name
archiveVersion = oml.project.version
}
artifacts.default omlZip
/*
* Publish project artifacts to maven
*/
apply plugin: 'maven-publish'
apply plugin: 'signing'
def pomConfig = {
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
developers {
developer {
id "melaasar"
name "Maged Elaasar"
email "[email protected]"
}
}
scm {
url 'https://github.com/opencaesar/'+rootProject.name
}
}
publishing {
publications {
maven(MavenPublication) {
groupId oml.project.group
artifactId oml.dataset.name
version oml.project.version
artifact omlZip
pom {
packaging = 'zip'
withXml {
def root = asNode()
if (configurations.find { it.name == 'oml' }) {
def dependencies = root.appendNode('dependencies')
configurations.oml.resolvedConfiguration.resolvedArtifacts.each {
def dependency = dependencies.appendNode('dependency')
dependency.appendNode('groupId', it.moduleVersion.id.group)
dependency.appendNode('artifactId', it.moduleVersion.id.name)
dependency.appendNode('version', it.moduleVersion.id.version)
if (it.classifier != null) {
dependency.appendNode('classifier', it.classifier)
dependency.appendNode('type', it.extension)
}
}
}
root.appendNode('name', oml.project.title)
root.appendNode('description', oml.project.description)
root.appendNode('url', 'https://github.com/opencaesar/'+rootProject.name)
root.children().last() + pomConfig
}
}
}
}
}
signing {
def pgpSigningKey = findProperty('pgpSigningKey')
if (pgpSigningKey != null) { pgpSigningKey = new String(pgpSigningKey.decodeBase64()) }
def pgpSigningPassword = findProperty('pgpSigningPassword')
useInMemoryPgpKeys(pgpSigningKey, pgpSigningPassword)
sign publishing.publications.maven
}
gradle.taskGraph.whenReady { taskGraph ->
signMavenPublication.onlyIf { taskGraph.allTasks.any{it.name == 'publishMavenPublicationToSonatypeRepository'} }
}
/*
* Integration with the Eclipse IDE
*/
apply plugin: 'eclipse'
eclipse {
synchronizationTasks downloadDependencies
}