build.gradle 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /*
  2. * The Maven coordinates for the project artifact
  3. */
  4. ext.title = 'System Design Ontology - 2 Layers'
  5. description = 'System design ontology considering only 2 layers (types and instances).'
  6. group = 'be.com.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-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-merge-gradle:+'
  27. classpath 'io.opencaesar.adapters:oml2owl-gradle:+'
  28. }
  29. }
  30. /*
  31. * Dataset-specific variables
  32. */
  33. ext.dataset = [
  34. // Name of dataset (matches one used in .fuseki.ttl file)
  35. name: 'SystemDesignOntology2Layers',
  36. // Root ontology IRI of the dataset
  37. rootOntologyIri: 'http://ua.com.be/sdo2l/description/bundle',
  38. ]
  39. /*
  40. * The repositories to look up OML dependencies in
  41. */
  42. repositories {
  43. mavenLocal()
  44. mavenCentral()
  45. }
  46. /*
  47. * The configuration of OML dependencies
  48. */
  49. configurations {
  50. oml
  51. }
  52. /*
  53. * Dependency versions
  54. */
  55. ext {
  56. //coreVersion = '+'
  57. metrologyVersion = '+'
  58. }
  59. /*
  60. * The OML dependencies
  61. */
  62. dependencies {
  63. //oml "io.opencaesar.ontologies:core-vocabularies:$coreVersion"
  64. oml "io.opencaesar.ontologies:metrology-vocabularies:$metrologyVersion"
  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. }
  106. /*
  107. * Stop the headless Fuseki server
  108. */
  109. task stopFuseki(type: io.opencaesar.owl.fuseki.StopFusekiTask, group:"oml") {
  110. outputFolderPath = file('.fuseki')
  111. }
  112. /*
  113. * A task to load an OWL catalog to a Fuseki dataset endpoint
  114. */
  115. task owlLoad(type:io.opencaesar.owl.load.OwlLoadTask, group:"oml", dependsOn: owlReason) {
  116. catalogPath = file('build/owl/catalog.xml')
  117. endpointURL = "http://localhost:3030/$dataset.name".toString()
  118. fileExtensions = ['owl', 'ttl']
  119. iris = [
  120. "$dataset.rootOntologyIri/classes".toString(),
  121. "$dataset.rootOntologyIri/properties".toString(),
  122. "$dataset.rootOntologyIri/individuals".toString()
  123. ]
  124. }
  125. /*
  126. * A task to run a set of SPARQL queries on a Fuseki dataset endpoint
  127. */
  128. task owlQuery(type:io.opencaesar.owl.query.OwlQueryTask, group:"oml", dependsOn: owlLoad) {
  129. endpointURL = "http://localhost:3030/$dataset.name".toString()
  130. queryPath = file('src/sparql')
  131. resultPath = file('build/results')
  132. format = 'json'
  133. }
  134. /*
  135. * A task to run a set of SHACL validation rules on a Fuseki dataset endpoint
  136. */
  137. task owlShacl(type:io.opencaesar.owl.shacl.fuseki.OwlShaclFusekiTask, group:"oml", dependsOn: owlLoad) {
  138. endpointURL = "http://localhost:3030/$dataset.name".toString()
  139. queryPath = file('src/shacl')
  140. resultPath = file('build/results')
  141. }
  142. /*
  143. * A task to build the project, which executes several tasks together
  144. */
  145. task build(group: "oml") {
  146. dependsOn owlReason
  147. }
  148. /*
  149. * A task to delete the build artifacts
  150. */
  151. task clean(type: Delete, group: "oml") {
  152. delete 'build'
  153. }
  154. /*
  155. * Publish artifact to maven
  156. */
  157. task omlZip(type: Zip, group:"oml") {
  158. from file('src/oml')
  159. include "**/*.oml"
  160. destinationDirectory = file('build/libs')
  161. archiveBaseName = project.name
  162. archiveVersion = project.version
  163. }
  164. def pomConfig = {
  165. licenses {
  166. license {
  167. name "The Apache Software License, Version 2.0"
  168. url "http://www.apache.org/licenses/LICENSE-2.0.txt"
  169. distribution "repo"
  170. }
  171. }
  172. developers {
  173. developer {
  174. id "melaasar"
  175. name "Maged Elaasar"
  176. email "melaasar@gmail.com"
  177. }
  178. }
  179. scm {
  180. url 'https://github.com/opencaesar/'+rootProject.name
  181. }
  182. }
  183. publishing {
  184. publications {
  185. maven(MavenPublication) {
  186. groupId project.group
  187. artifactId project.name
  188. version project.version
  189. artifact omlZip
  190. pom {
  191. packaging = 'zip'
  192. withXml {
  193. def root = asNode()
  194. if (configurations.find { it.name == 'oml' }) {
  195. def dependencies = root.appendNode('dependencies')
  196. configurations.oml.resolvedConfiguration.resolvedArtifacts.each {
  197. def dependency = dependencies.appendNode('dependency')
  198. dependency.appendNode('groupId', it.moduleVersion.id.group)
  199. dependency.appendNode('artifactId', it.moduleVersion.id.name)
  200. dependency.appendNode('version', it.moduleVersion.id.version)
  201. if (it.classifier != null) {
  202. dependency.appendNode('classifier', it.classifier)
  203. dependency.appendNode('type', it.extension)
  204. }
  205. }
  206. }
  207. root.appendNode('name', project.ext.title)
  208. root.appendNode('description', project.description)
  209. root.appendNode('url', 'https://github.com/opencaesar/'+rootProject.name)
  210. root.children().last() + pomConfig
  211. }
  212. }
  213. }
  214. }
  215. }
  216. tasks.named('wrapper') {
  217. gradleVersion = '6.5.1' //version required
  218. }
  219. /*
  220. * Integration with the Eclipse IDE
  221. */
  222. apply plugin: 'eclipse'
  223. eclipse {
  224. synchronizationTasks omlDependencies
  225. }