Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.74 KB | None | 0 0
  1. buildscript {
  2. ext.cubaVersion = '6.8.1'
  3. repositories {
  4. maven {
  5. url 'https://repo.cuba-platform.com/content/groups/work'
  6. credentials {
  7. username(rootProject.hasProperty('repoUser') ? rootProject['repoUser'] : 'cuba')
  8. password(rootProject.hasProperty('repoPass') ? rootProject['repoPass'] : 'cuba123')
  9. }
  10. }
  11. }
  12. dependencies {
  13. classpath "com.haulmont.gradle:cuba-plugin:$cubaVersion"
  14. }
  15. }
  16.  
  17. def globalModule = project(':app-global')
  18. def coreModule = project(':app-core')
  19. def portalModule = project(':app-portal')
  20.  
  21. def servletApi = 'org.apache.tomcat:tomcat-servlet-api:8.0.26'
  22. apply(plugin: 'eclipse')
  23. apply(plugin: 'java')
  24. apply(plugin: 'cuba')
  25.  
  26. cuba {
  27. artifact {
  28. group = 'com.company.demo'
  29. version = '0.1'
  30. isSnapshot = true
  31. }
  32. tomcat {
  33. dir = "$project.rootDir/deploy/tomcat"
  34. }
  35. }
  36.  
  37. dependencies {
  38. appComponent("com.haulmont.cuba:cuba-global:$cubaVersion")
  39. }
  40.  
  41.  
  42. def hsql = 'org.hsqldb:hsqldb:2.2.9'
  43.  
  44. configure([globalModule, coreModule, portalModule]) {
  45. apply(plugin: 'java')
  46. apply(plugin: 'maven')
  47. apply(plugin: 'eclipse')
  48. apply(plugin: 'cuba')
  49.  
  50. dependencies {
  51. testCompile('junit:junit:4.12')
  52. }
  53.  
  54. task sourceJar(type: Jar) {
  55. from file('src')
  56. classifier = 'sources'
  57. }
  58.  
  59. artifacts {
  60. archives sourceJar
  61. }
  62. }
  63.  
  64. configure(globalModule) {
  65. task enhance(type: CubaEnhancing)
  66. }
  67.  
  68. configure(coreModule) {
  69.  
  70. configurations {
  71. jdbc
  72. dbscripts
  73. }
  74.  
  75. dependencies {
  76. compile(globalModule)
  77. provided(servletApi)
  78. jdbc(hsql)
  79. testRuntime(hsql)
  80.  
  81. }
  82.  
  83. task cleanConf(description: 'Cleans up conf directory') {
  84. doLast {
  85. def dir = new File(cuba.tomcat.dir, '/conf/app-core')
  86. if (dir.isDirectory()) {
  87. ant.delete(includeemptydirs: true) {
  88. fileset(dir: dir, includes: '**/*', excludes: 'local.app.properties')
  89. }
  90. }
  91. }
  92. }
  93.  
  94. task deploy(dependsOn: [assemble, cleanConf], type: CubaDeployment) {
  95. appName = 'app-core'
  96. appJars('app-global', 'app-core')
  97. }
  98.  
  99. task createDb(dependsOn: assembleDbScripts, description: 'Creates local database', type: CubaDbCreation) {
  100. dbms = 'hsql'
  101. host = 'localhost'
  102. dbName = 'demo'
  103. dbUser = 'sa'
  104. dbPassword = ''
  105. }
  106.  
  107. task updateDb(dependsOn: assembleDbScripts, description: 'Updates local database', type: CubaDbUpdate) {
  108. dbms = 'hsql'
  109. host = 'localhost'
  110. dbName = 'demo'
  111. dbUser = 'sa'
  112. dbPassword = ''
  113. }
  114. }
  115.  
  116.  
  117. configure(portalModule) {
  118. dependencies {
  119. provided(servletApi)
  120. compile(globalModule)
  121. testCompile('org.jmockit:jmockit:1.15')
  122.  
  123. }
  124.  
  125. def webappName = 'app-portal'
  126. def resourcesDir = "$cuba.tomcat.dir/webapps/$webappName/resources"
  127. def ftlDir = "$cuba.tomcat.dir/webapps/$webappName/WEB-INF/templates"
  128.  
  129. task deploy(dependsOn: assemble, type: CubaDeployment) {
  130. appName = webappName
  131. appJars('app-global', 'app-portal')
  132. }
  133.  
  134. task deployStatic() {
  135. doLast {
  136. copy {
  137. from file('web/resources')
  138. include '**/*.css'
  139. include '**/*.js'
  140. include '**/*.png'
  141. include '**/*.gif'
  142. include '**/*.jpg'
  143. into resourcesDir
  144. }
  145. copy {
  146. from file('web/WEB-INF/templates')
  147. include '**/*.ftl'
  148. include '**/*.html'
  149. into ftlDir
  150. }
  151. }
  152. }
  153.  
  154. task cleanStatic() {
  155. doLast {
  156. delete resourcesDir
  157. delete ftlDir
  158. }
  159. }
  160.  
  161. task webArchive(type: Zip) {
  162. from file('web')
  163. from file("$buildDir/web")
  164. exclude '**/web.xml', '**/app.properties'
  165. classifier = 'web'
  166. }
  167.  
  168. artifacts {
  169. archives webArchive
  170. }
  171. }
  172.  
  173.  
  174.  
  175. task undeploy(type: Delete, dependsOn: ':app-web:cleanConf') {
  176. delete("$cuba.tomcat.dir/shared")
  177. delete("$cuba.tomcat.dir/webapps/app-core")
  178. delete("$cuba.tomcat.dir/webapps/app")
  179. delete("$cuba.tomcat.dir/webapps/app-portal")
  180. delete("$cuba.tomcat.dir/webapps/app-front")
  181. }
  182.  
  183. task restart(dependsOn: ['stop', ':app-core:deploy', ':app-portal:deploy'], description: 'Redeploys applications and restarts local Tomcat') {
  184. doLast {
  185. ant.waitfor(maxwait: 6, maxwaitunit: 'second', checkevery: 2, checkeveryunit: 'second') {
  186. not {
  187. socket(server: 'localhost', port: '8787')
  188. }
  189. }
  190. start.execute()
  191. }
  192. }
  193.  
  194. task wrapper(type: Wrapper) {
  195. gradleVersion = '4.3.1'
  196. }
  197.  
  198. apply from: 'extra.gradle'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement