build.gradle 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. import org.apache.tools.ant.filters.*
  136. task render(group:"oml", dependsOn: owlQuery) {
  137. inputs.files(fileTree("src/bs/assets"))
  138. inputs.files(fileTree("src/bs/js"))
  139. inputs.files(fileTree("build/json"))
  140. outputs.files(fileTree("build/web"))
  141. doFirst {
  142. copy {
  143. from 'src/bs/assets'
  144. into 'build/web/assets'
  145. }
  146. copy {
  147. from 'src/bs/js'
  148. into 'build/web/js'
  149. }
  150. copy {
  151. from 'build/results'
  152. into 'build/web/json'
  153. filter { line -> line.replaceAll('\\{ "head": \\{', 'var data = \\{ "head": \\{') }
  154. }
  155. }
  156. }
  157. /*
  158. * Generate a bikeshed document with mixed narrative and model data
  159. */
  160. task bikeshed(group:"oml", dependsOn: render) {
  161. inputs.files(fileTree("src/bs"))
  162. outputs.files(file("build/web/index.html"))
  163. doFirst {
  164. exec {
  165. commandLine "bikeshed", "--die-on=link-error", "spec", "src/bs/index.bs", "build/web/index.html"
  166. }
  167. }
  168. }
  169. /*
  170. * A task to build the project, which executes several tasks together
  171. */
  172. task build(group: "oml") {
  173. dependsOn owlReason
  174. }
  175. /*
  176. * A task to delete the build artifacts
  177. */
  178. task clean(type: Delete, group: "oml") {
  179. delete 'build'
  180. }
  181. /*
  182. * Publish artifact to maven
  183. */
  184. task omlZip(type: Zip, group:"oml") {
  185. from file('src/oml')
  186. include "**/*.oml"
  187. destinationDirectory = file('build/libs')
  188. archiveBaseName = project.name
  189. archiveVersion = project.version
  190. }
  191. def pomConfig = {
  192. licenses {
  193. license {
  194. name "The Apache Software License, Version 2.0"
  195. url "http://www.apache.org/licenses/LICENSE-2.0.txt"
  196. distribution "repo"
  197. }
  198. }
  199. developers {
  200. developer {
  201. id "uantwerp"
  202. name "University of Antwerp"
  203. email ""
  204. }
  205. }
  206. scm {
  207. url 'https://msdl.uantwerpen.be/git/lucasalbertins/DTDesign/'
  208. }
  209. }
  210. publishing {
  211. publications {
  212. maven(MavenPublication) {
  213. groupId project.group
  214. artifactId project.name
  215. version project.version
  216. artifact omlZip
  217. pom {
  218. packaging = 'zip'
  219. withXml {
  220. def root = asNode()
  221. if (configurations.find { it.name == 'oml' }) {
  222. def dependencies = root.appendNode('dependencies')
  223. configurations.oml.resolvedConfiguration.resolvedArtifacts.each {
  224. def dependency = dependencies.appendNode('dependency')
  225. dependency.appendNode('groupId', it.moduleVersion.id.group)
  226. dependency.appendNode('artifactId', it.moduleVersion.id.name)
  227. dependency.appendNode('version', it.moduleVersion.id.version)
  228. if (it.classifier != null) {
  229. dependency.appendNode('classifier', it.classifier)
  230. dependency.appendNode('type', it.extension)
  231. }
  232. }
  233. }
  234. root.appendNode('name', project.ext.title)
  235. root.appendNode('description', project.description)
  236. root.appendNode('url', 'https://msdl.uantwerpen.be/git/lucasalbertins/DTDesign/')
  237. root.children().last() + pomConfig
  238. }
  239. }
  240. }
  241. }
  242. }
  243. /*
  244. * Integration with the Eclipse IDE
  245. */
  246. apply plugin: 'eclipse'
  247. eclipse {
  248. synchronizationTasks omlDependencies
  249. }