-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
243 lines (221 loc) · 7.41 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
/*
* The Maven coordinates for the project artifact
*/
ext.title = 'Open Source Rover'
description = 'This is the open source rover description'
group = 'io.opencaesar'
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-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 = 'open-source-rover'
// Root ontology IRI of the dataset
rootIri = 'http://opencaesar.io/open-source-rover/description/bundle'
}
/*
* The repositories to look up OML dependencies in
*/
repositories {
mavenLocal()
mavenCentral()
}
/*
* The OML dependencies
*/
dependencies {
oml "io.opencaesar.ontologies:imce-vocabularies:5.+"
}
/*
* 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')
}
/*
* 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:"vision", dependsOn: owlReason) {
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:"vision", dependsOn: owlLoad) {
inputs.files(owlLoad.inputs.files) // rerun when the dataset changes
endpointURL = "http://localhost:3030/$dataset".toString()
queryPath = file('src/vision/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
}