build.gradle 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. /*
  2. * The Maven coordinates for the project artifact
  3. */
  4. ext.title = 'Car Example'
  5. description = 'This is a car example'
  6. group = 'one.rys.ontology'
  7. version = '1.0.0'
  8. /*
  9. * The Gradle plugins
  10. */
  11. apply plugin: 'maven-publish'
  12. /*
  13. * The Gradle task dependencies
  14. */
  15. buildscript {
  16. repositories {
  17. mavenLocal()
  18. mavenCentral()
  19. }
  20. dependencies {
  21. classpath 'io.opencaesar.owl:owl-fuseki-gradle:+'
  22. classpath 'io.opencaesar.owl:owl-shacl-fuseki-gradle:+'
  23. classpath 'io.opencaesar.owl:owl-query-gradle:+'
  24. classpath 'io.opencaesar.owl:owl-load-gradle:+'
  25. classpath 'io.opencaesar.owl:owl-reason-gradle:+'
  26. classpath 'io.opencaesar.oml:oml-bikeshed-gradle:1.+'
  27. classpath 'io.opencaesar.oml:oml-merge-gradle:1.+'
  28. classpath 'io.opencaesar.adapters:oml2owl-gradle:1.+'
  29. }
  30. }
  31. /*
  32. * Bikeshed folder
  33. */
  34. ext {
  35. bikeshed = 'build/bikeshed'
  36. }
  37. /*
  38. * Dataset-specific variables
  39. */
  40. ext.dataset = [
  41. // Name of dataset (matches one used in .fuseki.ttl file)
  42. name: 'car',
  43. // Root ontology IRI of the dataset
  44. rootOntologyIri: 'http://ontology.rys.one/project/vocabulary/bundle',
  45. ]
  46. /*
  47. * The repositories to look up OML dependencies in
  48. */
  49. repositories {
  50. mavenLocal()
  51. mavenCentral()
  52. }
  53. /*
  54. * The configuration of OML dependencies
  55. */
  56. configurations {
  57. oml
  58. }
  59. /*
  60. * Dependency versions
  61. */
  62. ext {
  63. coreVersion = '+'
  64. }
  65. /*
  66. * The OML dependencies
  67. */
  68. dependencies {
  69. oml "io.opencaesar.ontologies:core-vocabularies:$coreVersion"
  70. }
  71. /*
  72. * A task to extract and merge the OML dependencies
  73. */
  74. task downloadDependencies(type:io.opencaesar.oml.merge.OmlMergeTask) {
  75. inputZipPaths = configurations.oml.files
  76. outputCatalogFolder = file('build/oml')
  77. }
  78. /*
  79. * A task to extract and merge the OML dependencies
  80. */
  81. task omlDependencies(type:io.opencaesar.oml.merge.OmlMergeTask, group:"oml") {
  82. inputZipPaths = configurations.oml.files
  83. outputCatalogFolder = file('build/oml')
  84. }
  85. /*
  86. * A task to generate Bikeshed specification for the OML catalog
  87. */
  88. task omlToBikeshed(type: io.opencaesar.oml.bikeshed.Oml2BikeshedTask, dependsOn: downloadDependencies) {
  89. // OML catalog
  90. inputCatalogPath = file('catalog.xml')
  91. // OML catalog title
  92. inputCatalogTitle = project.title
  93. // OML catalog version
  94. inputCatalogVersion = project.version
  95. // Input Ontology Iri
  96. rootOntologyIri = 'http://ontology.rys.one/project/vocabulary/bundle'
  97. // OWL folder
  98. outputFolderPath = file("$bikeshed")
  99. // Publish URL
  100. publishUrl = 'https://git.rys.one/dtdesign/car-example'
  101. }
  102. /*
  103. * A task to generate the model documentation in HTML
  104. */
  105. import org.gradle.internal.os.OperatingSystem
  106. task generateDocs(dependsOn: omlToBikeshed) {
  107. inputs.files(fileTree("$bikeshed").include('**/*.bs'))
  108. outputs.files(fileTree("$bikeshed").include('**/*.html'))
  109. doLast {
  110. if (OperatingSystem.current().isWindows()) {
  111. exec { commandLine "$bikeshed/publish.bat" }
  112. } else {
  113. exec { commandLine "$bikeshed/publish.sh" }
  114. }
  115. }
  116. }
  117. /*
  118. * A task to convert the OML catalog to OWL catalog
  119. */
  120. task omlToOwl(type:io.opencaesar.oml2owl.Oml2OwlTask, group:"oml", dependsOn: omlDependencies) {
  121. // OML catalog
  122. inputCatalogPath = file('catalog.xml')
  123. // OWL catalog
  124. outputCatalogPath = file('build/owl/catalog.xml')
  125. }
  126. /*
  127. * A task to run the Openllet reasoner on the OWL catalog
  128. */
  129. task owlReason(type:io.opencaesar.owl.reason.OwlReasonTask, group:"oml", dependsOn: omlToOwl) {
  130. // OWL catalog
  131. catalogPath = file('build/owl/catalog.xml')
  132. // Input ontology IRI to reason on
  133. inputOntologyIri = "$dataset.rootOntologyIri".toString()
  134. // Entailment statements to generate and the ontologies to persist them in
  135. specs = [
  136. "$dataset.rootOntologyIri/classes = ALL_SUBCLASS".toString(),
  137. "$dataset.rootOntologyIri/properties = INVERSE_PROPERTY | ALL_SUBPROPERTY".toString(),
  138. "$dataset.rootOntologyIri/individuals = ALL_INSTANCE | DATA_PROPERTY_VALUE | OBJECT_PROPERTY_VALUE | SAME_AS".toString()
  139. ]
  140. // Junit error report
  141. reportPath = file('build/reports/reasoning.xml')
  142. }
  143. /*
  144. * Start the headless Fuseki server
  145. */
  146. task startFuseki(type: io.opencaesar.owl.fuseki.StartFusekiTask, group:"oml") {
  147. configurationPath = file('.fuseki.ttl')
  148. outputFolderPath = file('.fuseki')
  149. webUI = true
  150. }
  151. /*
  152. * Stop the headless Fuseki server
  153. */
  154. task stopFuseki(type: io.opencaesar.owl.fuseki.StopFusekiTask, group:"oml") {
  155. outputFolderPath = file('.fuseki')
  156. }
  157. /*
  158. * A task to load an OWL catalog to a Fuseki dataset endpoint
  159. */
  160. task owlLoad(type:io.opencaesar.owl.load.OwlLoadTask, group:"oml", dependsOn: owlReason) {
  161. catalogPath = file('build/owl/catalog.xml')
  162. endpointURL = "http://localhost:3030/$dataset.name".toString()
  163. fileExtensions = ['owl', 'ttl']
  164. iris = [
  165. "$dataset.rootOntologyIri/classes".toString(),
  166. "$dataset.rootOntologyIri/properties".toString(),
  167. "$dataset.rootOntologyIri/individuals".toString()
  168. ]
  169. }
  170. /*
  171. * A task to run a set of SPARQL queries on a Fuseki dataset endpoint
  172. */
  173. task owlQuery(type:io.opencaesar.owl.query.OwlQueryTask, group:"oml", dependsOn: owlLoad) {
  174. endpointURL = "http://localhost:3030/$dataset.name".toString()
  175. queryPath = file('src/sparql')
  176. resultPath = file('build/results')
  177. format = 'json'
  178. }
  179. /*
  180. * A task to run a set of SHACL validation rules on a Fuseki dataset endpoint
  181. */
  182. task owlShacl(type:io.opencaesar.owl.shacl.fuseki.OwlShaclFusekiTask, group:"oml", dependsOn: owlLoad) {
  183. endpointURL = "http://localhost:3030/$dataset.name".toString()
  184. queryPath = file('src/shacl')
  185. resultPath = file('build/reports')
  186. }
  187. /*
  188. * A task to build the project, which executes several tasks together
  189. */
  190. task build(group: "oml") {
  191. dependsOn owlReason
  192. }
  193. /*
  194. * A task to delete the build artifacts
  195. */
  196. task clean(type: Delete, group: "oml") {
  197. delete 'build'
  198. }
  199. /*
  200. * Publish artifact to maven
  201. */
  202. task omlZip(type: Zip, group:"oml") {
  203. from file('src/oml')
  204. include "**/*.oml"
  205. destinationDirectory = file('build/libs')
  206. archiveBaseName = project.name
  207. archiveVersion = project.version
  208. }
  209. def pomConfig = {
  210. licenses {
  211. license {
  212. name "The Apache Software License, Version 2.0"
  213. url "http://www.apache.org/licenses/LICENSE-2.0.txt"
  214. distribution "repo"
  215. }
  216. }
  217. developers {
  218. developer {
  219. id "arrys"
  220. name "Arkadiusz Michał Ryś"
  221. email "Arkadiusz.Michal.Rys@gmail.com"
  222. }
  223. }
  224. scm {
  225. url 'https://git.rys.one/dtdesign/car-example'
  226. }
  227. }
  228. publishing {
  229. publications {
  230. maven(MavenPublication) {
  231. groupId project.group
  232. artifactId project.name
  233. version project.version
  234. artifact omlZip
  235. pom {
  236. packaging = 'zip'
  237. withXml {
  238. def root = asNode()
  239. if (configurations.find { it.name == 'oml' }) {
  240. def dependencies = root.appendNode('dependencies')
  241. configurations.oml.resolvedConfiguration.resolvedArtifacts.each {
  242. def dependency = dependencies.appendNode('dependency')
  243. dependency.appendNode('groupId', it.moduleVersion.id.group)
  244. dependency.appendNode('artifactId', it.moduleVersion.id.name)
  245. dependency.appendNode('version', it.moduleVersion.id.version)
  246. if (it.classifier != null) {
  247. dependency.appendNode('classifier', it.classifier)
  248. dependency.appendNode('type', it.extension)
  249. }
  250. }
  251. }
  252. root.appendNode('name', project.ext.title)
  253. root.appendNode('description', project.description)
  254. root.appendNode('url', 'https://git.rys.one/dtdesign/car-example')
  255. root.children().last() + pomConfig
  256. }
  257. }
  258. }
  259. }
  260. }
  261. /*
  262. * Integration with the Eclipse IDE
  263. */
  264. apply plugin: 'eclipse'
  265. eclipse {
  266. synchronizationTasks omlDependencies
  267. }