cuba/build.gradle
2016-05-23 09:58:25 +04:00

756 lines
23 KiB
Groovy

/*
* Copyright (c) 2008-2016 Haulmont.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
buildscript {
ext.cubaVersion = '6.2-SNAPSHOT'
ext.cubaVersion = rootProject.hasProperty('buildVersion') ? rootProject['buildVersion'] : cubaVersion
println("CUBA Platform Version ${ext.cubaVersion}")
println("")
repositories {
mavenLocal()
maven {
credentials {
username System.getenv('HAULMONT_REPOSITORY_USER') ?: 'cuba'
password System.getenv('HAULMONT_REPOSITORY_PASSWORD') ?: 'cuba123'
}
url System.getenv('HAULMONT_REPOSITORY_URL') ?: 'https://repo.cuba-platform.com/content/groups/work'
}
}
dependencies {
classpath group: 'com.haulmont.gradle', name: 'cuba-plugin', version: cubaVersion
}
}
apply(plugin: 'base')
apply(plugin: 'maven')
apply(plugin: 'idea')
apply(plugin: 'cuba')
cuba {
artifact {
group = 'com.haulmont.cuba'
version = project.cubaVersion.replace('-SNAPSHOT', '')
isSnapshot = project.cubaVersion.endsWith('-SNAPSHOT')
}
ide {
vcs = 'Git'
copyright = '''Copyright (c) 2008-$today.year Haulmont.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.'''
}
}
def sharedLibModule = project(':cuba-shared-lib')
def globalModule = project(':cuba-global')
def coreModule = project(':cuba-core')
def clientModule = project(':cuba-client')
def guiModule = project(':cuba-gui')
def desktopModule = project(':cuba-desktop')
def portalModule = project(':cuba-portal')
def restApiModule = project(':cuba-rest-api')
def webAuthModule = project(':cuba-web-auth')
def webToolkitModule = project(':cuba-web-toolkit')
def webModule = project(':cuba-web')
def webModuleThemesModule = project(':cuba-web-themes')
def coreTestsModule = project(':cuba-core-tests')
def clientTestsModule = project(':cuba-client-tests')
apply from: "$rootProject.projectDir/lib.gradle"
def springVersion = '4.2.5.RELEASE'
def springSecurityVersion = '4.0.4.RELEASE'
def servletApi = 'org.apache.tomcat:tomcat-servlet-api:8.0.26'
def groovyArtifact = 'org.codehaus.groovy:groovy-all:2.4.4'
def poi = 'com.haulmont.thirdparty:poi:3.12.cuba.1'
def postgres = 'org.postgresql:postgresql:9.4-1201-jdbc41'
def hsqldb = 'org.hsqldb:hsqldb:2.3.3'
/* Shared web dependencies */
def commonsUpload = [group: 'commons-fileupload', name: 'commons-fileupload', version: '1.3.1']
configure([sharedLibModule, globalModule, coreModule, clientModule, guiModule,
webModule, desktopModule, portalModule, webAuthModule, restApiModule]) {
apply(plugin: 'java')
apply(plugin: 'idea')
apply(plugin: 'maven')
apply(plugin: 'checkstyle')
apply(plugin: 'findbugs')
apply(plugin: 'cuba')
dependencies {
compile('commons-logging:commons-logging:1.2')
compile(group: 'commons-lang', name: 'commons-lang', version: '2.6')
compile(group: 'commons-collections', name: 'commons-collections', version: '3.2.1')
compile('commons-io:commons-io:2.4')
compile('commons-codec:commons-codec:1.10')
compile('commons-cli:commons-cli:1.3.1')
compile('org.apache.commons:commons-pool2:2.4.2')
compile('org.apache.commons:commons-compress:1.9')
compile(group: 'dom4j', name: 'dom4j', version: '1.6.1')
compile('com.sun.mail:javax.mail:1.5.4')
compile('ch.qos.logback:logback-classic:1.1.3')
compile('org.slf4j:log4j-over-slf4j:1.7.12')
compile(group: 'org.perf4j', name: 'perf4j', version: '0.9.16')
compile('com.google.code.findbugs:jsr305:3.0.0')
compile('javax:javaee-api:7.0')
compile(groovyArtifact)
compile(group: 'antlr', name: 'antlr', version: '2.7.7')
compile(group: 'org.antlr', name: 'antlr-runtime', version: '3.5.2')
compile('com.google.guava:guava:18.0')
compile 'org.eclipse.persistence:javax.persistence:2.1.0'
compile 'org.eclipse.persistence:commonj.sdo:2.1.1'
compile 'org.glassfish:javax.json:1.0.4'
compile (eclipselink)
compile('org.freemarker:freemarker:2.3.23')
compile(group: 'aopalliance', name: 'aopalliance', version: '1.0')
compile(group: 'org.springframework', name: 'spring-core', version: springVersion)
compile(group: 'org.springframework', name: 'spring-beans', version: springVersion)
compile(group: 'org.springframework', name: 'spring-context', version: springVersion)
compile(group: 'org.springframework', name: 'spring-web', version: springVersion)
compile(group: 'com.esotericsoftware', name: 'kryo-shaded', version: '3.0.3')
compile(group: 'de.javakaffee', name: 'kryo-serializers', version: '0.37') {
exclude(group: 'com.esotericsoftware', module: 'kryo')
}
testCompile('org.jmockit:jmockit:1.15')
testCompile('junit:junit:4.12')
findbugs 'com.google.code.findbugs:findbugs:3.0.1'
}
task sourceJar(type: Jar) {
from file('src')
classifier = 'sources'
}
artifacts {
archives sourceJar
}
String checkstyleConfigDir = "${rootProject.projectDir}/config/checkstyle"
checkstyle {
configFile = new File("${checkstyleConfigDir}/checkstyle.xml".toString())
configProperties = [
'checkstyleConfigDir' : checkstyleConfigDir
]
reportsDir = new File("${buildDir}/checkstyle".toString())
}
checkstyleMain << {
def checkstyleDir = "${project.buildDir}/checkstyle".toString()
ant.xslt('in': "$checkstyleDir/main.xml",
out: "$checkstyleDir/$project.name-checkstyle.html",
style: "$checkstyleConfigDir/checkstyle.xsl")
}
findbugs {
toolVersion = "2.0.3"
ignoreFailures = true
omitVisitors = ['FindDoubleCheck']
}
findbugsMain {
reports {
xml.enabled = false
html {
enabled = true
destination "${project.buildDir}/findbugs/$project.name-findbugs.html"
}
}
}
jar {
manifest {
attributes("Implementation-Version": cubaVersion)
}
}
}
// configure web toolkit modules
configure(webToolkitModule) {
apply(plugin: 'java')
apply(plugin: 'idea')
apply(plugin: 'maven')
apply(plugin: 'cuba')
task sourceJar(type: Jar) {
from file('src')
classifier = 'sources'
}
artifacts {
archives sourceJar
}
}
configure(sharedLibModule) {
dependencies {
jdbc(postgres)
jdbc(hsqldb)
}
}
configure(globalModule) {
dependencies {
compile(group: 'org.json', name: 'json', version: '20140107')
compile('com.google.code.gson:gson:2.5')
provided(servletApi)
}
task generateReleaseTimestamp(type: CubaReleaseTimeStamp) {
releaseTimeStampPath = "$buildDir/classes/main/com/haulmont/cuba/core/global/release.timestamp"
releaseNumberPath = "$buildDir/classes/main/com/haulmont/cuba/core/global/release.number"
}
task enhance(type: CubaEnhancing)
task filterDummyEntities {
ext.srcFile = file('src/cuba-persistence.xml')
ext.dstDir = file("$buildDir/tmp/filtered")
ext.dstFile = new File(ext.dstDir, "cuba-persistence.xml")
inputs.file srcFile
outputs.file dstFile
doLast {
dstDir.mkdirs()
List lines = srcFile.readLines()
def result = lines.findAll{ !it.contains('.entity.dummy.') }.join('\n')
dstFile.write(result)
}
}
jar {
exclude '**/entity/dummy/*'
exclude { it.file == file("$buildDir/resources/main/cuba-persistence.xml") }
from "$buildDir/tmp/filtered"
}
jar.dependsOn filterDummyEntities
sourceJar {
exclude '**/entity/dummy/*'
exclude {
it.file.name == 'cuba-persistence.xml' && sourceSets.main.java.srcDirs.contains(it.file.parentFile)
}
from "$buildDir/tmp/filtered"
}
sourceJar.dependsOn filterDummyEntities
}
configure(coreModule) {
configurations {
dbscripts
}
dependencies {
compile(globalModule)
compile(sharedLibModule)
compile 'javax.validation:validation-api:1.1.0.Final'
compile(group: 'com.haulmont.thirdparty', name: 'xstream', version: '1.4.2.20120702')
runtime(group: 'xpp3', name: 'xpp3_min', version: '1.1.4c')
runtime(group: 'xmlpull', name: 'xmlpull', version: '1.1.3.1')
compile(group: 'org.ocpsoft.prettytime', name: 'prettytime-nlp', version: '3.2.5.Final')
compile('org.jgroups:jgroups:3.6.7.Final')
compile('org.aspectj:aspectjrt:1.8.6')
compile('org.aspectj:aspectjweaver:1.8.6')
compile('org.mybatis:mybatis:3.2.7')
compile('org.mybatis:mybatis-spring:1.2.3')
compile(group: 'org.springframework', name: 'spring-context-support', version: springVersion)
compile(group: 'org.springframework', name: 'spring-orm', version: springVersion)
compile(group: 'org.springframework', name: 'spring-tx', version: springVersion)
compile(group: 'org.springframework', name: 'spring-webmvc', version: springVersion)
compile(poi) // POI is actually not required by core, but remains here to simplify dependencies for reports project
provided(servletApi)
jdbc(postgres)
jdbc(hsqldb)
testCompile('org.apache.commons:commons-dbcp2:2.1.1')
testRuntime(servletApi)
testRuntime(hsqldb)
testRuntime(postgres)
}
test {
scanForTestClasses = false
includes = ['**/*Test.class']
jvmArgs '-XX:-UseSplitVerifier'
}
assembleDbScripts {
moduleAlias = '10-cuba'
}
task deploy(dependsOn: assemble, type: CubaDeployment) {
appName = 'cuba-core'
appJars('cuba-global', 'cuba-core')
}
def hsqlDbName = 'cubadb'
task startDb(description: 'Starts local HSQLDB server', type: CubaHsqlStart) {
dbName = hsqlDbName
}
task stopDb(description: 'Stops local HSQLDB server', type: CubaHsqlStop) {
dbName = hsqlDbName
}
task removeDb(description: 'Removes local HSQL database', type: Delete) {
delete new File("$rootProject.projectDir/data")
}
task killDb(description: 'Kill local HSQLDB server process running on port 9001', type: CubaKillProcess) {
port = 9001
}
task createDb(dependsOn: assembleDbScripts, description: 'Creates local HSQL database', type: CubaDbCreation) {
dbms = 'hsql'
dbName = hsqlDbName
dbUser = 'sa'
dbPassword = ''
}
}
configure(coreTestsModule) {
apply(plugin: 'java')
apply(plugin: 'maven')
apply(plugin: 'cuba')
buildDir = file('../build/core-tests')
sourceSets {
main {
java {
srcDir '.'
include 'com/haulmont/cuba/core/CubaTestCase.java'
include 'com/haulmont/cuba/testsupport/*.java'
include '*'
}
resources {
srcDir '.'
}
}
}
dependencies {
compile(coreModule)
compile('org.apache.commons:commons-dbcp2:2.1.1')
compile('org.jmockit:jmockit:1.15')
compile('junit:junit:4.12')
}
task sourceJar(type: Jar) {
from file('.')
include 'com/haulmont/cuba/core/CubaTestCase*.class'
include 'com/haulmont/cuba/core/CubaTestCase*.java'
include 'com/haulmont/cuba/testsupport/*'
include '*'
classifier = 'sources'
}
artifacts {
archives sourceJar
}
}
configure(clientModule) {
dependencies {
compile(globalModule)
compile('org.apache.httpcomponents:httpclient:4.5')
}
}
configure(clientTestsModule) {
apply(plugin: 'java')
apply(plugin: 'maven')
apply(plugin: 'cuba')
buildDir = file('../build/client-tests')
sourceSets {
main {
java {
srcDir '.'
}
resources {
srcDir '.'
}
}
}
dependencies {
compile(clientModule)
compile('org.jmockit:jmockit:1.15')
compile('junit:junit:4.12')
}
task sourceJar(type: Jar) {
from file('.')
classifier = 'sources'
}
artifacts {
archives sourceJar
}
}
configure(guiModule) {
dependencies {
compile(clientModule)
compile(poi)
compile(groovyArtifact)
testCompile(clientModule.sourceSets.test.output)
}
task enhance(type: CubaEnhancing)
test {
scanForTestClasses = false
includes = ['**/*Test.class']
exclude 'com/haulmont/cuba/gui/components/*ComponentTest.class'
exclude 'com/haulmont/cuba/gui/components/*FieldTest.class'
}
}
configure(webModule) {
configurations {
themes
}
dependencies {
compile(sharedLibModule)
compile(guiModule)
compile(webAuthModule)
compile(restApiModule)
compile(commonsUpload)
compile(group: 'org.springframework', name: 'spring-webmvc', version: springVersion)
compile(vaadinShared) {
exclude(group: 'com.vaadin.external.google', module: 'guava')
}
compile(group: 'com.vaadin.external.google', name: 'guava-vaadin-shaded', version: '16.0.1.vaadin1')
compile(vaadinServer) {
exclude(group: 'com.vaadin', module: 'vaadin-sass-compiler')
}
/* Vaadin addons */
compile(group: 'com.haulmont.thirdparty', name: 'popupbutton', version: '2.5.2.cuba.3')
compile(group: 'com.haulmont.thirdparty', name: 'aceeditor', version: '0.8.15')
compile(group: 'org.vaadin.addons', name: 'contextmenu', version: '4.5')
compile(group: 'org.vaadin.addons', name: 'dragdroplayouts', version: '1.2.2.cuba.2')
provided(servletApi)
themes(vaadinThemes)
testCompile(clientModule.sourceSets.test.output)
testCompile(guiModule.sourceSets.test.output)
testRuntime(servletApi)
}
task enhance(type: CubaEnhancing)
jar {
with copySpec {
from sourceSets.main.allJava
include "com/haulmont/cuba/web/toolkit/ui/client/**"
}
}
task buildScssThemes(type: CubaWebScssThemeCreation) {
themes = ['halo', 'havana']
// compress = true
// sprites = true
// cleanup = true
}
assemble.dependsOn buildScssThemes
task deployThemes(type: CubaDeployThemeTask, dependsOn: buildScssThemes) {
}
task buildHalo(type: CubaWebScssThemeCreation) {
themes = ['halo']
// compress = true
// sprites = true
// cleanup = true
}
task deployHalo(type: Copy, dependsOn: buildHalo) {
from file("$webModule.buildDir/web/VAADIN/themes/halo")
into "${cuba.tomcat.dir}/webapps/cuba/VAADIN/themes/halo"
exclude '**/web.xml'
}
task buildHavana(type: CubaWebScssThemeCreation) {
themes = ['havana']
// compress = true
// sprites = true
// cleanup = true
}
task deployHavana(type: Copy, dependsOn: buildHavana) {
from file("$webModule.buildDir/web/VAADIN/themes/havana")
into "${cuba.tomcat.dir}/webapps/cuba/VAADIN/themes/havana"
exclude '**/web.xml'
}
def webOutDir = file("$buildDir/web")
task webArchive(dependsOn: buildScssThemes, type: Zip) {
from file('web')
from webOutDir
exclude '**/web.xml', '**/app.properties'
classifier = 'web'
}
artifacts {
archives webArchive
}
task deploy(dependsOn: assemble, type: CubaDeployment) {
appName = 'cuba'
appJars('cuba-global', 'cuba-client', 'cuba-gui', 'cuba-web', 'cuba-web-auth', 'cuba-rest-api')
}
}
configure(webModuleThemesModule) {
apply(plugin: 'java')
apply(plugin: 'maven')
apply(plugin: 'cuba')
buildDir = file('../build/scss-themes')
sourceSets {
main {
java {
srcDir '.'
}
resources {
srcDir '.'
}
}
}
dependencies {
compile(vaadinThemes)
}
}
configure(webAuthModule) {
dependencies {
compile(globalModule)
compile(group: 'org.springframework', name: 'spring-tx', version: springVersion)
compile(group: 'org.springframework.ldap', name: 'spring-ldap-core', version: '2.0.2.RELEASE') {
exclude(group: 'org.slf4j', module: 'jcl-over-slf4j') // removed because it defines its own Log4j LogFactory via JDK services mechanism
}
provided(servletApi)
}
}
configure(webToolkitModule) {
dependencies {
compile(webModule)
compile(vaadinClient)
compile(vaadinCompiler)
runtime(servletApi)
}
task buildWidgetSet(type: CubaWidgetSetBuilding) {
widgetSetClass = 'com.haulmont.cuba.web.toolkit.ui.WidgetSet'
// Strict
strict = true
// Debug flags:
printCompilerClassPath = false
logLevel = 'INFO'
// Parallel thread count
workers = 2
// Performance and widgetset size:
style = 'OBF' // 'OBF' or 'PRETTY' or 'DETAILED'
disableCastChecking = false
optimize = 9
draft = false
// Compiler JVM
xmx = '-Xmx512m'
xss = '-Xss8m'
xxMPS = '-XX:MaxPermSize=256m'
}
task buildDebugWidgetSet(type: CubaWidgetSetBuilding) {
widgetSetsDir = "$project.buildDir/web-debug/VAADIN/widgetsets"
widgetSetClass = 'com.haulmont.cuba.web.toolkit.ui.WidgetSet'
// Performance and widgetset size:
style = 'PRETTY'
}
task debugWidgetSet(type: CubaWidgetSetDebug) {
widgetSetClass = 'com.haulmont.cuba.web.toolkit.ui.WidgetSet'
}
jar {
from sourceSets.main.allJava
}
task webArchive(dependsOn: buildWidgetSet, type: Zip) {
from file("$buildDir/web")
classifier = 'web'
}
task webDebugArchive(dependsOn: buildDebugWidgetSet, type: Zip) {
from file("$buildDir/web-debug")
classifier = 'debug'
}
artifacts {
archives webArchive
if (!cuba.artifact.isSnapshot) {
archives webDebugArchive
}
}
task deploy(dependsOn: buildWidgetSet) << {
delete {
"$cuba.tomcat.dir/webapps/cuba/VAADIN/widgetsets"
}
copy {
from "$buildDir/web"
into "$cuba.tomcat.dir/webapps/cuba"
}
}
task cleanWidgetSet(dependsOn: clean) {
}
}
configure(desktopModule) {
apply(plugin: 'application')
mainClassName = 'com.haulmont.cuba.desktop.App'
dependencies {
compile(guiModule)
compile(group: 'com.miglayout', name: 'miglayout-swing', version: '4.2')
compile(group: 'com.fifesoft', name: 'rsyntaxtextarea', version: '2.5.6')
compile(group: 'com.haulmont.thirdparty', name: 'glazedlists', version: '1.9.20110801')
compile(group: 'com.haulmont.thirdparty', name: 'swingx-core', version: '1.6.5-1.cuba.0')
assemble.dependsOn = [classes]
testCompile(clientModule.sourceSets.test.output)
testCompile(guiModule.sourceSets.test.output)
testRuntime(servletApi)
}
installApp {
into("$buildDir/app/" + applicationName)
}
task desktopInstall(dependsOn: assemble) << {
jar.execute()
startScripts.execute()
installApp.execute()
}
task desktopDist(dependsOn: assemble) << {
distZip.execute()
}
task desktopStart(dependsOn: desktopInstall) << {
run.execute()
}
}
configure(restApiModule) {
dependencies {
compile(globalModule)
compile(clientModule)
compile(sharedLibModule)
provided(servletApi)
compile(group: 'org.springframework', name: 'spring-webmvc', version: springVersion)
compile(group: 'org.springframework', name: 'spring-context-support', version: springVersion)
compile(group: 'org.json', name: 'json', version: '20140107')
compile(groovyArtifact)
testCompile(clientModule.sourceSets.test.output)
}
}
configure(portalModule) {
dependencies {
compile(globalModule)
compile(clientModule)
compile(sharedLibModule)
compile(restApiModule)
provided(servletApi)
compile(group: 'org.springframework', name: 'spring-webmvc', version: springVersion)
compile(group: 'org.springframework.security', name: 'spring-security-core', version: springSecurityVersion)
compile(group: 'org.springframework.security', name: 'spring-security-web', version: springSecurityVersion)
compile(group: 'org.springframework.security', name: 'spring-security-config', version: springSecurityVersion)
compile(group: 'org.springframework.security', name: 'spring-security-taglibs', version: springSecurityVersion)
compile(group: 'org.springframework', name: 'spring-context-support', version: springVersion)
compile(group: 'org.json', name: 'json', version: '20140107')
compile(groovyArtifact)
compile(group: 'org.springframework', name: 'spring-tx', version: springVersion)
compile(group: 'org.springframework', name: 'spring-jdbc', version: springVersion)
compile(group: 'org.thymeleaf', name: 'thymeleaf', version: '3.0.0.RELEASE')
compile(group: 'org.thymeleaf', name: 'thymeleaf-spring4', version: '3.0.0.RELEASE')
testCompile(clientModule.sourceSets.test.output)
}
test {
scanForTestClasses = false
includes = ['**/*Test.class']
}
}
task restart(dependsOn: ['stop', ':cuba-core:deploy', ':cuba-web:deploy', ':cuba-web-toolkit:deploy'],
description: 'Redeploys applications and restarts local Tomcat') << {
ant.waitfor(maxwait: 6, maxwaitunit: 'second', checkevery: 2, checkeveryunit: 'second') {
not {
socket(server: 'localhost', port: '8787')
}
}
start.execute()
}