build.gradle 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /*
  2. * The Maven coordinates for the project artifact
  3. */
  4. ext.title = 'CTO Action Knowledge Graphs Ontology'
  5. description = 'Ontology from efforts of the FM-CTO Action KG'
  6. group = 'be.flandersmake'
  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: 'be.flandersmake.knowledge.ontology',
  35. // Root ontology IRI of the dataset
  36. rootOntologyIri: 'http://flandersmake.be/knowledge/vocabulary/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.uantwerpen.msdl:vafl: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. }
  104. /*
  105. * Stop the headless Fuseki server
  106. */
  107. task stopFuseki(type: io.opencaesar.owl.fuseki.StopFusekiTask, group:"oml") {
  108. outputFolderPath = file('.fuseki')
  109. }
  110. /*
  111. * A task to load an OWL catalog to a Fuseki dataset endpoint
  112. */
  113. task owlLoad(type:io.opencaesar.owl.load.OwlLoadTask, group:"oml", dependsOn: owlReason) {
  114. catalogPath = file('build/owl/catalog.xml')
  115. endpointURL = "http://localhost:3030/$dataset.name".toString()
  116. fileExtensions = ['owl', 'ttl']
  117. iris = [
  118. "$dataset.rootOntologyIri/classes".toString(),
  119. "$dataset.rootOntologyIri/properties".toString(),
  120. "$dataset.rootOntologyIri/individuals".toString()
  121. ]
  122. }
  123. /*
  124. * A task to run a set of SPARQL queries on a Fuseki dataset endpoint
  125. */
  126. task owlQuery(type:io.opencaesar.owl.query.OwlQueryTask, group:"oml", dependsOn: owlLoad) {
  127. endpointURL = "http://localhost:3030/$dataset.name".toString()
  128. queryPath = file('src/sparql')
  129. resultPath = file('build/results')
  130. format = 'json'
  131. }
  132. /*
  133. * A task to build the project, which executes several tasks together
  134. */
  135. task build(group: "oml") {
  136. dependsOn owlReason
  137. }
  138. /*
  139. * A task to delete the build artifacts
  140. */
  141. task clean(type: Delete, group: "oml") {
  142. delete 'build'
  143. }
  144. /*
  145. * Publish artifact to maven
  146. */
  147. task omlZip(type: Zip, group:"oml") {
  148. from file('src/oml')
  149. include "**/*.oml"
  150. destinationDirectory = file('build/libs')
  151. archiveBaseName = project.name
  152. archiveVersion = project.version
  153. }
  154. def pomConfig = {
  155. licenses {
  156. license {
  157. name "The Apache Software License, Version 2.0"
  158. url "http://www.apache.org/licenses/LICENSE-2.0.txt"
  159. distribution "repo"
  160. }
  161. }
  162. developers {
  163. developer {
  164. id "melaasar"
  165. name "Maged Elaasar"
  166. email "melaasar@gmail.com"
  167. }
  168. }
  169. scm {
  170. url 'https://github.com/opencaesar/'+rootProject.name
  171. }
  172. }
  173. publishing {
  174. publications {
  175. maven(MavenPublication) {
  176. groupId project.group
  177. artifactId project.name
  178. version project.version
  179. artifact omlZip
  180. pom {
  181. packaging = 'zip'
  182. withXml {
  183. def root = asNode()
  184. if (configurations.find { it.name == 'oml' }) {
  185. def dependencies = root.appendNode('dependencies')
  186. configurations.oml.resolvedConfiguration.resolvedArtifacts.each {
  187. def dependency = dependencies.appendNode('dependency')
  188. dependency.appendNode('groupId', it.moduleVersion.id.group)
  189. dependency.appendNode('artifactId', it.moduleVersion.id.name)
  190. dependency.appendNode('version', it.moduleVersion.id.version)
  191. if (it.classifier != null) {
  192. dependency.appendNode('classifier', it.classifier)
  193. dependency.appendNode('type', it.extension)
  194. }
  195. }
  196. }
  197. root.appendNode('name', project.ext.title)
  198. root.appendNode('description', project.description)
  199. root.appendNode('url', 'https://github.com/opencaesar/'+rootProject.name)
  200. root.children().last() + pomConfig
  201. }
  202. }
  203. }
  204. }
  205. }
  206. /*
  207. * Integration with the Eclipse IDE
  208. */
  209. apply plugin: 'eclipse'
  210. eclipse {
  211. synchronizationTasks omlDependencies
  212. }