build.gradle 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /*
  2. * The Maven coordinates for the project artifact
  3. */
  4. ext.title = 'Simple car'
  5. description = 'This is an example of a simple car'
  6. group = 'be.ua'
  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-query-gradle:+'
  23. classpath 'io.opencaesar.owl:owl-load-gradle:+'
  24. classpath 'io.opencaesar.owl:owl-reason-gradle:+'
  25. classpath 'io.opencaesar.oml:oml-merge-gradle:+'
  26. classpath 'io.opencaesar.adapters:oml2owl-gradle:+'
  27. }
  28. }
  29. /*
  30. * Dataset-specific variables
  31. */
  32. ext.dataset = [
  33. // Name of dataset (matches one used in .fuseki.ttl file)
  34. name: 'simple_car',
  35. // Root ontology IRI of the dataset
  36. rootOntologyIri: 'http://ua.be/simple_car/description/bundle',
  37. ]
  38. /*
  39. * The repositories to look up OML dependencies in
  40. */
  41. repositories {
  42. mavenLocal()
  43. mavenCentral()
  44. }
  45. /*
  46. * The configuration of OML dependencies
  47. */
  48. configurations {
  49. oml
  50. }
  51. /*
  52. * Dependency versions
  53. */
  54. ext {
  55. coreVersion = '+'
  56. }
  57. /*
  58. * The OML dependencies
  59. */
  60. dependencies {
  61. oml "io.opencaesar.ontologies:core-vocabularies:$coreVersion"
  62. oml "be.ua:SystemDesignOntology2Layers:1.0.0"
  63. }
  64. /*
  65. * A task to extract and merge the OML dependencies
  66. */
  67. task omlDependencies(type:io.opencaesar.oml.merge.OmlMergeTask, group:"oml") {
  68. inputZipPaths = configurations.oml.files
  69. outputCatalogFolder = file('build/oml')
  70. }
  71. /*
  72. * A task to convert the OML catalog to OWL catalog
  73. */
  74. task omlToOwl(type:io.opencaesar.oml2owl.Oml2OwlTask, group:"oml", dependsOn: omlDependencies) {
  75. // OML catalog
  76. inputCatalogPath = file('catalog.xml')
  77. // OWL catalog
  78. outputCatalogPath = file('build/owl/catalog.xml')
  79. }
  80. /*
  81. * A task to run the Openllet reasoner on the OWL catalog
  82. */
  83. task owlReason(type:io.opencaesar.owl.reason.OwlReasonTask, group:"oml", dependsOn: omlToOwl) {
  84. // OWL catalog
  85. catalogPath = file('build/owl/catalog.xml')
  86. // Input ontology IRI to reason on
  87. inputOntologyIri = "$dataset.rootOntologyIri".toString()
  88. // Entailment statements to generate and the ontologies to persist them in
  89. specs = [
  90. "$dataset.rootOntologyIri/classes = ALL_SUBCLASS".toString(),
  91. "$dataset.rootOntologyIri/properties = INVERSE_PROPERTY | ALL_SUBPROPERTY".toString(),
  92. "$dataset.rootOntologyIri/individuals = ALL_INSTANCE | DATA_PROPERTY_VALUE | OBJECT_PROPERTY_VALUE | SAME_AS".toString()
  93. ]
  94. // Junit error report
  95. reportPath = file('build/reports/reasoning.xml')
  96. }
  97. /*
  98. * Start the headless Fuseki server
  99. */
  100. task startFuseki(type: io.opencaesar.owl.fuseki.StartFusekiTask, group:"oml") {
  101. configurationPath = file('.fuseki.ttl')
  102. outputFolderPath = file('.fuseki')
  103. webUI = true
  104. }
  105. /*
  106. * Stop the headless Fuseki server
  107. */
  108. task stopFuseki(type: io.opencaesar.owl.fuseki.StopFusekiTask, group:"oml") {
  109. outputFolderPath = file('.fuseki')
  110. }
  111. /*
  112. * A task to load an OWL catalog to a Fuseki dataset endpoint
  113. */
  114. task owlLoad(type:io.opencaesar.owl.load.OwlLoadTask, group:"oml", dependsOn: owlReason) {
  115. catalogPath = file('build/owl/catalog.xml')
  116. endpointURL = "http://localhost:3030/$dataset.name".toString()
  117. fileExtensions = ['owl', 'ttl']
  118. iris = [
  119. "$dataset.rootOntologyIri/classes".toString(),
  120. "$dataset.rootOntologyIri/properties".toString(),
  121. "$dataset.rootOntologyIri/individuals".toString()
  122. ]
  123. }
  124. /*
  125. * A task to run a set of SPARQL queries on a Fuseki dataset endpoint
  126. */
  127. task owlQuery(type:io.opencaesar.owl.query.OwlQueryTask, group:"oml", dependsOn: owlLoad) {
  128. endpointURL = "http://localhost:3030/$dataset.name".toString()
  129. queryPath = file('src/sparql')
  130. resultPath = file('build/results')
  131. format = 'json'
  132. }
  133. /*
  134. * A task to build the project, which executes several tasks together
  135. */
  136. task build(group: "oml") {
  137. dependsOn owlReason
  138. }
  139. /*
  140. * A task to delete the build artifacts
  141. */
  142. task clean(type: Delete, group: "oml") {
  143. delete 'build'
  144. }
  145. /*
  146. * Publish artifact to maven
  147. */
  148. task omlZip(type: Zip, group:"oml") {
  149. from file('src/oml')
  150. include "**/*.oml"
  151. destinationDirectory = file('build/libs')
  152. archiveBaseName = project.name
  153. archiveVersion = project.version
  154. }
  155. def pomConfig = {
  156. licenses {
  157. license {
  158. name "The Apache Software License, Version 2.0"
  159. url "http://www.apache.org/licenses/LICENSE-2.0.txt"
  160. distribution "repo"
  161. }
  162. }
  163. developers {
  164. developer {
  165. id "uantwerp"
  166. name "University of Antwerp"
  167. email ""
  168. }
  169. }
  170. scm {
  171. url 'https://msdl.uantwerpen.be/git/lucasalbertins/DTDesign/'
  172. }
  173. }
  174. publishing {
  175. publications {
  176. maven(MavenPublication) {
  177. groupId project.group
  178. artifactId project.name
  179. version project.version
  180. artifact omlZip
  181. pom {
  182. packaging = 'zip'
  183. withXml {
  184. def root = asNode()
  185. if (configurations.find { it.name == 'oml' }) {
  186. def dependencies = root.appendNode('dependencies')
  187. configurations.oml.resolvedConfiguration.resolvedArtifacts.each {
  188. def dependency = dependencies.appendNode('dependency')
  189. dependency.appendNode('groupId', it.moduleVersion.id.group)
  190. dependency.appendNode('artifactId', it.moduleVersion.id.name)
  191. dependency.appendNode('version', it.moduleVersion.id.version)
  192. if (it.classifier != null) {
  193. dependency.appendNode('classifier', it.classifier)
  194. dependency.appendNode('type', it.extension)
  195. }
  196. }
  197. }
  198. root.appendNode('name', project.ext.title)
  199. root.appendNode('description', project.description)
  200. root.appendNode('url', 'https://msdl.uantwerpen.be/git/lucasalbertins/DTDesign/')
  201. root.children().last() + pomConfig
  202. }
  203. }
  204. }
  205. }
  206. }
  207. tasks.named('wrapper') {
  208. gradleVersion = '6.5.1' //version required
  209. }
  210. /*
  211. * Integration with the Eclipse IDE
  212. */
  213. apply plugin: 'eclipse'
  214. eclipse {
  215. synchronizationTasks omlDependencies
  216. }