-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
264 lines (241 loc) · 8.21 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
/*
* The Maven coordinates for the project artifact
*/
ext.title = 'Tutorial2'
description = 'This is tutorial2 example'
group = 'com.example'
version = '1.0.0'
/*
* The Gradle plugins
*/
apply plugin: 'base'
apply plugin: 'oml'
/*
* The Gradle task dependencies
*/
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'io.opencaesar.owl:owl-doc-gradle:2.+'
classpath 'io.opencaesar.owl:owl-fuseki-gradle:+'
classpath 'io.opencaesar.owl:owl-query-gradle:+'
classpath 'io.opencaesar.owl:owl-load-gradle:+'
classpath 'io.opencaesar.owl:owl-reason-gradle:+'
classpath 'io.opencaesar.oml:oml-merge-gradle:+'
classpath 'io.opencaesar.adapters:oml2owl-gradle:+'
}
}
/*
* Dataset-specific variables
*/
ext {
// Name of dataset (matches one used in .fuseki.ttl file)
dataset = 'tutorial2'
// Root ontology IRI of the dataset
rootIri = 'http://example.com/tutorial2/description/bundle'
}
/*
* The repositories to look up OML dependencies in
*/
repositories {
mavenLocal()
mavenCentral()
}
/*
* The OML dependencies
*/
dependencies {
//oml "io.opencaesar.ontologies:core-vocabularies:5.+"
oml "io.opencaesar.ontologies:metrology-vocabularies:+"
}
/*
* 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) {
// OML catalog
inputCatalogPath = file('catalog.xml')
// OWL catalog
outputCatalogPath = file('build/owl/catalog.xml')
}
/*
* 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 owlReason(type:io.opencaesar.owl.reason.OwlReasonTask, group:"oml", dependsOn: omlToOwl) {
// OWL catalog
catalogPath = file('build/owl/catalog.xml')
// Input ontology IRI to reason on
inputOntologyIri = "$rootIri".toString()
// Entailment statements to generate and the ontologies to persist them in
specs = [
"$rootIri/classes = ALL_SUBCLASS".toString(),
"$rootIri/properties = INVERSE_PROPERTY | ALL_SUBPROPERTY".toString(),
"$rootIri/individuals = ALL_INSTANCE | DATA_PROPERTY_VALUE | OBJECT_PROPERTY_VALUE | SAME_AS".toString()
]
// Junit error report
reportPath = file('build/reports/reasoning.xml')
}
/*
* 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: owlReason) {
// OWL catalog
inputCatalogPath = file('build/owl/catalog.xml')
// OWL catalog title
inputCatalogTitle = 'Kepler16b'
// OWL catalog version
inputCatalogVersion = project.version
// OWL Ontology Iris
inputOntologyIris = [ "$rootIri/classes", "$rootIri/properties", "$rootIri/individuals" ]
// Output folder
outputFolderPath = file('build/web/doc')
// Output case sensitivie path
outputCaseSensitive = org.gradle.internal.os.OperatingSystem.current().isLinux()
}
/*
* 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") {
configurationPath = file('.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 = file('.fuseki')
}
/*
* A task to load an OWL catalog to a Fuseki dataset endpoint
* @seeAlso https://github.com/opencaesar/owl-tools/blob/master/owl-load/README.md
*/
task owlLoad(type:io.opencaesar.owl.load.OwlLoadTask, group:"oml", dependsOn:[owlReason, startFuseki]) {
inputs.files(startFuseki.outputFolderPath) // rerun when fuseki restarts
catalogPath = file('build/owl/catalog.xml')
endpointURL = "http://localhost:3030/$dataset".toString()
fileExtensions = ['owl', 'ttl']
iris = [
"$rootIri/classes".toString(),
"$rootIri/properties".toString(),
"$rootIri/individuals".toString()
]
}
/*
* 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 owlQuery(type:io.opencaesar.owl.query.OwlQueryTask, group:"oml", dependsOn: owlLoad) {
inputs.files(owlLoad.inputs.files) // rerun when the dataset changes
endpointURL = "http://localhost:3030/$dataset".toString()
queryPath = file('src/sparql')
resultPath = file('build/results')
format = 'json'
}
/*
* A task to check the project's build artifacts
* @seeAlso https://docs.gradle.org/current/userguide/base_plugin.html
*/
tasks.named('check') {
dependsOn owlReason
}
/*
* Define project's artifacts
*/
task omlZip(type: Zip, group:"oml") {
from file('src/oml')
include "**/*.oml"
destinationDirectory = file('build/libs')
archiveBaseName = project.name
archiveVersion = 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 project.group
artifactId project.name
version 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', project.ext.title)
root.appendNode('description', project.description)
root.appendNode('url', 'https://github.com/opencaesar/'+rootProject.name)
root.children().last() + pomConfig
}
}
}
}
}
signing {
def pgpSigningKey = project.findProperty('pgpSigningKey')
if (pgpSigningKey != null) { pgpSigningKey = new String(pgpSigningKey.decodeBase64()) }
def pgpSigningPassword = project.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
}