build.gradle 6.3 KB

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