buildscript { ext.cubaVersion = '7.2.1' repositories { mavenLocal() maven { url 'https://dl.bintray.com/cuba-platform/main' } maven { url 'https://mvnrepository.com/artifact/com.opencsv/opencsv' } jcenter() } dependencies { classpath "com.haulmont.gradle:cuba-plugin:$cubaVersion" } } def springVersion = '5.2.3.RELEASE' def springComponentsVersion = '2.2.4.RELEASE' def servletApi = 'javax.servlet:javax.servlet-api:3.1.0' def postgres = 'org.postgresql:postgresql:42.2.8' def hsqldb = 'org.hsqldb:hsqldb:2.5.0' def modulePrefix = 'app' def globalModule = project(":${modulePrefix}-global") def coreModule = project(":${modulePrefix}-core") def webModule = project(":${modulePrefix}-web") def frontModule = project(":${modulePrefix}-front") apply(plugin: 'cuba') cuba { artifact { group = 'com.groupstp.dispatching' version = '0.1' isSnapshot = true } tomcat { dir = "$project.rootDir/deploy/tomcat" } } dependencies { appComponent("com.haulmont.cuba:cuba-global:$cubaVersion") appComponent("com.haulmont.addon.restapi:restapi-global:7.2.0") appComponent('com.haulmont.addon.admintools:cuba-at-global:1.5.0.BETA1') // appComponent("com.groupstp.fias:fias-global:0.1-SNAPSHOT") } configure([globalModule, coreModule, webModule]) { apply(plugin: 'java') apply(plugin: 'maven') apply(plugin: 'cuba') dependencies { testCompile('junit:junit:4.12') } task sourceJar(type: Jar) { from file('src') classifier = 'sources' } artifacts { archives sourceJar } } configure(globalModule) { dependencies { runtime('javax.xml.bind:jaxb-api:2.3.1') runtime('org.glassfish.jaxb:jaxb-runtime:2.3.1') compile('com.opencsv:opencsv:4.0') implementation "org.mapstruct:mapstruct:1.3.1.Final" annotationProcessor "org.mapstruct:mapstruct-processor:1.3.1.Final" compile group: 'org.springframework', name: 'spring-websocket', version: springVersion compile group: 'org.springframework', name: 'spring-messaging', version: springVersion compile group: 'org.springframework.amqp', name: 'spring-rabbit', version: springComponentsVersion compile group: 'org.springframework.amqp', name: 'spring-amqp', version: springComponentsVersion compile group: 'org.springframework.data', name: 'spring-data-redis', version: springComponentsVersion compile group: 'redis.clients', name: 'jedis', version: '3.1.0' compile group: 'com.squareup.retrofit2', name: 'retrofit', version: '2.7.2' compile group: 'com.squareup.retrofit2', name: 'converter-gson', version: '2.7.2' compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.10.3' } entitiesEnhancing { main { enabled = true } } } configure(coreModule) { configurations { jdbc dbscripts } dependencies { compile(globalModule) compileOnly(servletApi) jdbc(postgres) testRuntime(postgres) jdbc(hsqldb) } 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 = 'dbsmart' dbName = 'dispatching' dbUser = dbPassword = } task updateDb(dependsOn: assembleDbScripts, description: 'Updates local database', type: CubaDbUpdate) { dbms = 'postgres' host = 'dbsmart' dbName = 'dispatching' dbUser = dbPassword = } } 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 "com/groupstp/dispatching/**" 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') } } configure(frontModule) { apply(plugin: 'cuba') apply(plugin: 'idea') apply(plugin: 'war') apply(plugin: 'maven') buildDir = 'build-gradle' def frontAppDir = "${modulePrefix}-front" def mainBuildDir = 'build' task buildFrontend(type: NpmTask, dependsOn: npmInstall) { args = ['run', 'build'] inputs.files fileTree('./') { exclude 'build' } outputs.dir "build" } buildFrontend.onlyIf { !binding.hasVariable('skipBuildFrontend') } assemble.dependsOn buildFrontend task deploy(type: Copy, dependsOn: [assemble]) { from file(mainBuildDir) into "$cuba.tomcat.dir/webapps/$frontAppDir" } war { from file(mainBuildDir) } } 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}-front") } task restart(dependsOn: ['stop', ":${modulePrefix}-core:deploy", ":${modulePrefix}-web: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 task buildUberJar(type: CubaUberJarBuilding) { coreJettyEnvPath = 'modules/core/web/META-INF/jetty-env.xml' singleJar = true appProperties = ['cuba.automaticDatabaseUpdate': true] polymerBuildDir = '.' logbackConfigurationFile = 'etc/uber-jar-logback.xml' }igurationFile = 'etc/uber-jar-logback.xml' }