Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- buildscript {
- ext.cubaVersion = '6.8.1'
- repositories {
- maven {
- url 'https://repo.cuba-platform.com/content/groups/work'
- credentials {
- username(rootProject.hasProperty('repoUser') ? rootProject['repoUser'] : 'cuba')
- password(rootProject.hasProperty('repoPass') ? rootProject['repoPass'] : 'cuba123')
- }
- }
- }
- dependencies {
- classpath "com.haulmont.gradle:cuba-plugin:$cubaVersion"
- }
- }
- def globalModule = project(':app-global')
- def coreModule = project(':app-core')
- def portalModule = project(':app-portal')
- def servletApi = 'org.apache.tomcat:tomcat-servlet-api:8.0.26'
- apply(plugin: 'eclipse')
- apply(plugin: 'java')
- apply(plugin: 'cuba')
- cuba {
- artifact {
- group = 'com.company.demo'
- version = '0.1'
- isSnapshot = true
- }
- tomcat {
- dir = "$project.rootDir/deploy/tomcat"
- }
- }
- dependencies {
- appComponent("com.haulmont.cuba:cuba-global:$cubaVersion")
- }
- def hsql = 'org.hsqldb:hsqldb:2.2.9'
- configure([globalModule, coreModule, portalModule]) {
- apply(plugin: 'java')
- apply(plugin: 'maven')
- apply(plugin: 'eclipse')
- apply(plugin: 'cuba')
- dependencies {
- testCompile('junit:junit:4.12')
- }
- task sourceJar(type: Jar) {
- from file('src')
- classifier = 'sources'
- }
- artifacts {
- archives sourceJar
- }
- }
- configure(globalModule) {
- task enhance(type: CubaEnhancing)
- }
- configure(coreModule) {
- configurations {
- jdbc
- dbscripts
- }
- dependencies {
- compile(globalModule)
- provided(servletApi)
- jdbc(hsql)
- testRuntime(hsql)
- }
- task cleanConf(description: 'Cleans up conf directory') {
- doLast {
- def dir = new File(cuba.tomcat.dir, '/conf/app-core')
- if (dir.isDirectory()) {
- ant.delete(includeemptydirs: true) {
- fileset(dir: dir, includes: '**/*', excludes: 'local.app.properties')
- }
- }
- }
- }
- task deploy(dependsOn: [assemble, cleanConf], type: CubaDeployment) {
- appName = 'app-core'
- appJars('app-global', 'app-core')
- }
- task createDb(dependsOn: assembleDbScripts, description: 'Creates local database', type: CubaDbCreation) {
- dbms = 'hsql'
- host = 'localhost'
- dbName = 'demo'
- dbUser = 'sa'
- dbPassword = ''
- }
- task updateDb(dependsOn: assembleDbScripts, description: 'Updates local database', type: CubaDbUpdate) {
- dbms = 'hsql'
- host = 'localhost'
- dbName = 'demo'
- dbUser = 'sa'
- dbPassword = ''
- }
- }
- configure(portalModule) {
- dependencies {
- provided(servletApi)
- compile(globalModule)
- testCompile('org.jmockit:jmockit:1.15')
- }
- def webappName = 'app-portal'
- def resourcesDir = "$cuba.tomcat.dir/webapps/$webappName/resources"
- def ftlDir = "$cuba.tomcat.dir/webapps/$webappName/WEB-INF/templates"
- task deploy(dependsOn: assemble, type: CubaDeployment) {
- appName = webappName
- appJars('app-global', 'app-portal')
- }
- task deployStatic() {
- doLast {
- copy {
- from file('web/resources')
- include '**/*.css'
- include '**/*.js'
- include '**/*.png'
- include '**/*.gif'
- include '**/*.jpg'
- into resourcesDir
- }
- copy {
- from file('web/WEB-INF/templates')
- include '**/*.ftl'
- include '**/*.html'
- into ftlDir
- }
- }
- }
- task cleanStatic() {
- doLast {
- delete resourcesDir
- delete ftlDir
- }
- }
- task webArchive(type: Zip) {
- from file('web')
- from file("$buildDir/web")
- exclude '**/web.xml', '**/app.properties'
- classifier = 'web'
- }
- artifacts {
- archives webArchive
- }
- }
- task undeploy(type: Delete, dependsOn: ':app-web:cleanConf') {
- delete("$cuba.tomcat.dir/shared")
- delete("$cuba.tomcat.dir/webapps/app-core")
- delete("$cuba.tomcat.dir/webapps/app")
- delete("$cuba.tomcat.dir/webapps/app-portal")
- delete("$cuba.tomcat.dir/webapps/app-front")
- }
- task restart(dependsOn: ['stop', ':app-core:deploy', ':app-portal:deploy'], description: 'Redeploys applications and restarts local Tomcat') {
- doLast {
- ant.waitfor(maxwait: 6, maxwaitunit: 'second', checkevery: 2, checkeveryunit: 'second') {
- not {
- socket(server: 'localhost', port: '8787')
- }
- }
- start.execute()
- }
- }
- task wrapper(type: Wrapper) {
- gradleVersion = '4.3.1'
- }
- apply from: 'extra.gradle'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement