buildscript { ext.cubaVersion = '7.1.1' repositories { mavenLocal() maven { url "https://repo1.maven.org/maven2" } maven { credentials { username 'admin' password 'wW@910126' } url 'http://36.156.141.252:8081/repository/nexus-group/' } maven { credentials { username 'AmmHdV' password 'yL3Az7escp' } url 'https://repo.rdc.aliyun.com/repository/11435-release-01n3IU/' } maven { credentials { username 'AmmHdV' password 'yL3Az7escp' } url 'https://repo.rdc.aliyun.com/repository/11435-snapshot-lPgJ1L/' } maven { url 'https://nexus.cuba-platform.cn/repository/cuba/' } 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 modulePrefix = 'svms' def globalModule = project(":${modulePrefix}-global") def coreModule = project(":${modulePrefix}-core") def webModule = project(":${modulePrefix}-web") def portalModule = project(":${modulePrefix}-portal") def servletApi = 'javax.servlet:javax.servlet-api:3.1.0' apply(plugin: 'cuba') apply(plugin: 'idea') cuba { artifact { group = 'cn.daidaiba.plugin.svms' version = '0.1' isSnapshot = false } ide { vcs = 'Git' copyright = '''Copyright (c) 2018-$today.year DaiDaiBa.''' } } dependencies { appComponent("com.haulmont.cuba:cuba-global:$cubaVersion") appComponent("com.haulmont.reports:reports-global:$cubaVersion") appComponent("com.haulmont.charts:charts-global:$cubaVersion") appComponent("com.haulmont.addon.dashboardchart:dashboardchart-global:1.2.0") appComponent('com.haulmont.addon.imap:imap-global:1.4.0') appComponent('com.haulmont.addon.restapi:restapi-global:7.1.0') appComponent("cn.daidaiba.plugin.attachable:attachable-global:0.8") appComponent("cn.daidaiba.plugin.template:templates-global:1.2.25") appComponent("cn.daidaiba.plugin.script:script-global:0.3") appComponent("cn.daidaiba.plugin.scheduler:scheduler-global:0.8.1") appComponent("cn.daidaiba.plugin.dashboardwidgets:dashboardwidgets-global:0.2.22") appComponent("cn.daidaiba.plugin.workflow:workflow-global:0.20.6") appComponent("cn.daidaiba.plugin.sequence:sequence-global:0.18") appComponent("cn.daidaiba.plugin.localization:localization-global:0.8.2") appComponent('com.haulmont.addon.dashboard:dashboard-global:3.1.3') appComponent('com.haulmont.addon.helium:helium-global:0.1.0') appComponent('cn.cuba.trans:transcn-global:7.1.1') appComponent("cn.daidaiba.plugin.notify:notify-global:1.0.7") } def postgres = 'org.postgresql:postgresql:9.4.1212' configure([globalModule, coreModule, webModule, portalModule, portalModule]) { apply(plugin: 'java') apply(plugin: 'groovy') apply(plugin: 'maven') apply(plugin: 'cuba') apply(plugin: 'idea') sourceSets { main { groovy { srcDirs = ["src"] } // new config java.outputDir = new File(project.buildDir, "classes/main") groovy.outputDir = new File(project.buildDir, "classes/main") } test { groovy { srcDirs = ["test"] } // new config java.outputDir = new File(project.buildDir, "classes/test") groovy.outputDir = new File(project.buildDir, "classes/test") } } sourceSets.main.output.classesDirs.setFrom(new File(project.buildDir, "classes/main")) sourceSets.test.output.classesDirs.setFrom(new File(project.buildDir, "classes/test")) dependencies { compile 'com.alibaba:fastjson:1.2.47' compile 'cn.hutool:hutool-all:4.6.3' compile 'org.gavaghan:geodesy:1.1.3' compile 'org.mongodb:mongo-java-driver:3.0.4' compile 'com.itextpdf:itextpdf:5.2.0' compile 'com.itextpdf:itext-asian:5.2.0' testCompile('junit:junit:4.12') testCompile('org.spockframework:spock-core:1.1-groovy-2.4') testCompile('org.junit.jupiter:junit-jupiter-api:5.5.2') testCompile('org.junit.jupiter:junit-jupiter-engine:5.5.2') testCompile('org.junit.vintage:junit-vintage-engine:5.5.2') } test { useJUnitPlatform() } } configure(globalModule) { dependencies { if (!JavaVersion.current().isJava8()) { runtime('javax.xml.bind:jaxb-api:2.3.1') runtime('org.glassfish.jaxb:jaxb-runtime:2.3.1') } } entitiesEnhancing { main { enabled = true } } jar { manifest { attributes('App-Component-Id': cuba.artifact.group) attributes('App-Component-Version': cuba.artifact.version + (cuba.artifact.isSnapshot ? '-SNAPSHOT' : '')) } } } configure(coreModule) { configurations { jdbc dbscripts } dependencies { compile(globalModule) compileOnly(servletApi) jdbc(postgres) testRuntime(postgres) } task cleanConf(description: 'Cleans up conf directory', type: Delete) { delete "$cuba.appHome/${modulePrefix}-core/conf" } task deploy(dependsOn: [assemble, cleanConf], type: CubaDeployment) { appName = "${modulePrefix}-core" appJars(modulePrefix + '-global', modulePrefix + '-core') } task createDb(dependsOn: assembleDbScripts, description: 'Creates local database', type: CubaDbCreation) { dbms = 'postgres' host = '39.104.53.163' dbName = 'svms_rel1' dbUser = 'postgres' dbPassword = 'root' } task updateDb(dependsOn: assembleDbScripts, description: 'Updates local database', type: CubaDbUpdate) { dbms = 'postgres' host = '39.104.53.163' dbName = 'svms_rel1' dbUser = 'postgres' dbPassword = 'root' } } configure(webModule) { configurations { webcontent } dependencies { compileOnly(servletApi) compile(globalModule) } task webArchive(type: Zip) { from file("$buildDir/web") from file('web') classifier = 'web' } artifacts { archives webArchive } task deployConf(type: Copy) { from file('src') include "cn/daidaiba/plugin/svms/**" into "$cuba.appHome/${modulePrefix}/conf" } task clearMessagesCache(type: CubaClearMessagesCache) { appName = "${modulePrefix}" } deployConf.dependsOn clearMessagesCache task cleanConf(description: 'Cleans up conf directory', type: Delete) { delete "$cuba.appHome/${modulePrefix}/conf" } task deploy(dependsOn: [assemble, cleanConf], type: CubaDeployment) { appName = "${modulePrefix}" appJars(modulePrefix + '-global', modulePrefix + '-web') } task buildScssThemes(type: CubaWebScssThemeCreation) task deployThemes(type: CubaDeployThemeTask, dependsOn: buildScssThemes) assemble.dependsOn buildScssThemes task themesJar(type: Jar) { from file('themes') classifier = 'themes' } artifacts { archives themesJar } } configure(portalModule) { dependencies { compileOnly(servletApi) compile(globalModule) } def webappName = "${modulePrefix}-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(modulePrefix + '-global', modulePrefix + '-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' 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: ":${modulePrefix}-web:cleanConf") { delete("$cuba.tomcat.dir/shared") delete("$cuba.tomcat.dir/webapps/${modulePrefix}-core") delete("$cuba.tomcat.dir/webapps/${modulePrefix}") delete("$cuba.tomcat.dir/webapps/${modulePrefix}-portal") } task restart(dependsOn: ['stop', ":${modulePrefix}-core:deploy", ":${modulePrefix}-web:deploy", ":${modulePrefix}-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') } } } } restart.finalizedBy start apply from: 'extra.gradle' task buildWar(type: CubaWarBuilding) { coreContextXmlPath = 'modules/core/web/META-INF/prod-context.xml' appProperties = ['cuba.automaticDatabaseUpdate': 'true', 'cuba.logDir': '${catalina.base}/logs'] logbackConfigurationFile = 'etc/logback.xml' singleWar = false includeContextXml = true includeJdbcDriver = true }