buildscript { ext.cubaVersion = '7.1.2' repositories { mavenLocal() maven { url 'xxxxxx' credentials { username('xxxxxx') password('xxxxxx') } } maven { url 'https://repo.cuba-platform.com/content/groups/work' credentials { username(rootProject.hasProperty('repoUser') ? rootProject['repoUser'] : 'cuba') password(rootProject.hasProperty('repoPass') ? rootProject['repoPass'] : 'xxxxxx') } } maven { url 'https://github.com/monitorjbl/excel-streaming-reader' credentials { username('SLF4j') } } maven { url 'https://repo.cuba-platform.com/content/groups/premium' credentials { username('180919001950') password('xxxxxx') } } maven { url 'https://repo.cuba-platform.com/content/groups/premium' credentials { username("180919001950") password("xxxxxx") } } maven { url 'https://repo.cuba-platform.com/content/groups/premium' credentials { username("${rootProject['premiumRepoUser']}") password("${rootProject['premiumRepoPass']}") } } } dependencies { classpath "com.haulmont.gradle:cuba-plugin:$cubaVersion" } } plugins { id 'org.hidetake.ssh' version '2.10.1' } def modulePrefix = 'ROOT' def globalModule = project(":${modulePrefix}-global") def coreModule = project(":${modulePrefix}-core") def guiModule = project(":${modulePrefix}-gui") def webModule = project(":${modulePrefix}-web") def webToolkitModule = project(":${modulePrefix}-web-toolkit") def servletApi = 'javax.servlet:javax.servlet-api:3.1.0' apply(plugin: 'cuba') cuba { artifact { group = 'com.company.enerstroymain' version = "0.5.0.0" isSnapshot = true } tomcat { dir = "$project.rootDir/deploy/tomcat" } } dependencies { appComponent("com.haulmont.cuba:cuba-global:$cubaVersion") appComponent("com.haulmont.reports:reports-global:$cubaVersion") appComponent("com.haulmont.fts:fts-global:$cubaVersion") appComponent("com.haulmont.charts:charts-global:$cubaVersion") appComponent("com.haulmont.bpm:bpm-global:$cubaVersion") appComponent("ru.sec2.reportsaver:reportSaver-core:1") appComponent("ru.sec2.documents:docs-global:1.1.1") appComponent('com.haulmont.addon.restapi:restapi-global:7.1.0') appComponent('com.haulmont.addon.maps:maps-global:1.1.0') } def postgres = 'org.postgresql:postgresql:42.2.4' configure([globalModule, coreModule, guiModule, webModule, webToolkitModule]) { apply(plugin: 'java') apply(plugin: 'maven') apply(plugin: 'cuba') dependencies { testCompile('junit:junit:4.12') implementation('ch.ethz.ganymed:ganymed-ssh2:262') } task sourceJar(type: Jar) { from file('src') classifier = 'sources' } artifacts { archives sourceJar } } 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 } } } configure(coreModule) { configurations { jdbc dbscripts } dependencies { compile(globalModule) compile files('src/libs/commons-imaging-1.0-SNAPSHOT.jar') compile files('src/libs/xlsx-streamer-2.1.0.jar') compile 'io.lettuce:lettuce-core:6.0.0.RELEASE' compileOnly(servletApi) jdbc(postgres) testRuntime(postgres) jdbc('mysql:mysql-connector-java:5.1.38') jdbc('mysql:mysql-connector-java:5.1.46') } task cleanConf(description: 'Cleans up conf directory') { doLast { def dir = new File(cuba.tomcat.dir, "/conf/${modulePrefix}-core") if (dir.isDirectory()) { ant.delete(includeemptydirs: true) { fileset(dir: dir, includes: '**/*', excludes: 'local.app.properties') } } } } 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 = 'xxxxxx' dbName = 'xxxxxx' dbUser = 'xxxxxx' dbPassword = 'xxxxxx' } task updateDb(dependsOn: assembleDbScripts, description: 'Updates local database', type: CubaDbUpdate) { dbms = 'postgres' host = 'xxxxxx' dbName = 'xxxxxx' dbUser = 'xxxxxx' dbPassword = 'xxxxxx' } } configure(guiModule) { dependencies { compile(globalModule) } task deployConf(type: Copy) { from file('src') include "com/company/enerstroymain/**" into "$cuba.tomcat.dir/conf/${modulePrefix}" } } configure(webModule) { configurations { webcontent } dependencies { compileOnly(servletApi) compile(guiModule) } jar { with copySpec { from sourceSets.main.allJava include "com/company/enerstroymain/web/toolkit/ui/client/**" } } task webArchive(type: Zip) { from file("$buildDir/web") from file('web') classifier = 'web' } artifacts { archives webArchive } task deployConf(type: Copy) { from file('src') include "com/company/enerstroymain/**" into "$cuba.tomcat.dir/conf/${modulePrefix}" } task clearMessagesCache(type: CubaClearMessagesCache) { appName = "${modulePrefix}" } deployConf.dependsOn clearMessagesCache task cleanConf(description: 'Cleans up conf directory') { doLast { def dir = new File(cuba.tomcat.dir, "/conf/${modulePrefix}") if (dir.isDirectory()) { ant.delete(includeemptydirs: true) { fileset(dir: dir, includes: '**/*', excludes: 'local.app.properties') } } } } task deploy(dependsOn: [assemble, cleanConf], type: CubaDeployment) { appName = "${modulePrefix}" appJars(modulePrefix + '-global', modulePrefix + '-gui', 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(webToolkitModule) { dependencies { compile(webModule) } jar { from sourceSets.main.allJava } task buildWidgetSet(type: CubaWidgetSetBuilding) { widgetSetClass = 'com.company.enerstroymain.web.toolkit.ui.AppWidgetSet' } task debugWidgetSet(type: CubaWidgetSetDebug) { widgetSetClass = 'com.company.enerstroymain.web.toolkit.ui.AppWidgetSet' } task webArchive(dependsOn: buildWidgetSet, type: Jar) { from file("$buildDir/web") classifier = 'client' } artifacts { archives webArchive } task deploy(dependsOn: webArchive, type: Copy) { from webArchive into "$cuba.tomcat.dir/webapps/${modulePrefix}/WEB-INF/lib" } } 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}") } task restart(dependsOn: ['stop', ":${modulePrefix}-core:deploy", ":${modulePrefix}-web:deploy", ":${modulePrefix}-web-toolkit: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() } } apply from: 'extra.gradle' remotes { webServer { host = 'xxxxxx' user = 'xxxxxx' port = xxxxxx password = 'xxxxxx' } } task deployYoda { File jarFile doFirst { println 'Try to send the new JAR' jarFile = new File('./build/distributions/uberJar/ROOT.jar'); } doLast { if (jarFile.isFile()) { ssh.run { session(remotes.webServer) { put from: './build/distributions/uberJar/ROOT.jar', into: '/home/yoda/RootNew.jar' execute 'sh /home/yoda/workscripts/killproc.sh' } } } else { println 'Error! ROOT.jar file does not exist' } } } task buildWar(type: CubaWarBuilding) { coreContextXmlPath = 'modules/core/web/META-INF/war-context.xml' webXmlPath = 'modules/web/web/WEB-INF/single-war-web.xml' appProperties = ['cuba.automaticDatabaseUpdate' : true, 'cuba.web.loginDialogDefaultUser' : '', 'cuba.web.loginDialogDefaultPassword': '', 'cuba.web.productionMode' : true, 'cuba.email.sendAllToAdmin' : false, 'cuba.webHostName' : 'xxxxxx' ] includeContextXml = true includeJdbcDriver = true appHome = 'app_home' } task buildUberJar(type: CubaUberJarBuilding) { doFirst { println 'Begin cleaning and building jar' File jarFile = new File('./build/distributions/uberJar/ROOT.jar'); if (jarFile.isFile()) { println 'Remove old jar' jarFile.delete() } println 'Generate new JAR' } singleJar = true logbackConfigurationFile = 'etc/uber-jar-logback.xml' coreJettyEnvPath = 'modules/core/web/META-INF/jetty-env.xml' appProperties = ['cuba.automaticDatabaseUpdate' : true, 'cuba.automaticDatabaseUpdate' : true, 'cuba.web.loginDialogDefaultUser' : '', 'cuba.web.loginDialogDefaultPassword': '', 'cuba.web.productionMode' : true, 'cuba.email.sendAllToAdmin' : false, 'cuba.webHostName' : 'xxxxxx'] }