build.gradle 6.5 KB

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