Error create project cuba


buildscript {
ext.cubaVersion = ‘7.2.19’
repositories {
maven {
url ‘Index of /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 = ‘petclinic’

def globalModule = project(“:${modulePrefix}-global”)
def coreModule = project(“:${modulePrefix}-core”)
def webModule = project(“:${modulePrefix}-web”)
def webThemesModule = project(“:${modulePrefix}-web-themes”)
def guiModule = project(“:${modulePrefix}-gui”)

def servletApi = ‘javax.servlet:javax.servlet-api:3.1.0’

apply(plugin: ‘cuba’)

cuba {
artifact {
group = ‘com.haulmont.sample.petclinic’
version = ‘2.0’
isSnapshot = false
}
}

dependencies {
appComponent(“com.haulmont.cuba:cuba-global:$cubaVersion”)
appComponent(‘com.haulmont.addon.restapi:restapi-global:7.2.2’)
appComponent(‘com.haulmont.addon.helium:helium-global:0.3.1’)

}
def hsql = ‘org.hsqldb:hsqldb:2.4.1’

configure([globalModule, coreModule, webModule, guiModule]) {
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) {
entitiesEnhancing {
main {
enabled = true
}
}
}

configure(coreModule) {

configurations {
    jdbc
    dbscripts
}

dependencies {
    compile(globalModule)
    compileOnly(servletApi)
    jdbc(hsql)
    testRuntime(hsql)
}

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 startDb(type: CubaHsqlStart) {
    dbName = 'petclinic'
}

task createDb(dependsOn: assembleDbScripts, description: 'Creates local database', type: CubaDbCreation) {
    dbms = 'hsql'
    host = 'localhost'
    dbName = 'petclinic'
    dbUser = 'sa'
    dbPassword = ''
}

task updateDb(dependsOn: assembleDbScripts, description: 'Updates local database', type: CubaDbUpdate) {
    dbms = 'hsql'
    host = 'localhost'
    dbName = 'petclinic'
    dbUser = 'sa'
    dbPassword = ''
}

}

configure(guiModule) {
dependencies {
compile(globalModule)
}

task deployConf(type: Copy) {
    from file('src')
    include "com/haulmont/sample/petclinic/**"
    into "$cuba.tomcat.dir/conf/${modulePrefix}"
}

}

configure(webModule) {
configurations {
webcontent
}

dependencies {
    compileOnly(servletApi)
    compile(guiModule)
}

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/haulmont/sample/petclinic/**"
    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

}

configure(webThemesModule) {
apply(plugin: ‘java’)
apply(plugin: ‘maven’)
apply(plugin: ‘cuba’)

appModuleType = 'web-themes'

buildDir = file('../build/scss-themes')

sourceSets {
    main {
        java {
            srcDir '.'
        }
        resources {
            srcDir '.'
        }
    }
}

}

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”], 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.10.1’
}

link source code :GitHub - cuba-guides/cuba-petclinic-i18n-messages: CUBA Petclinic example: Localization of CUBA applications
Help me! I run without error!

Hi
Thanks for your feedback!

You need to update gradle wrapper version to 5.6.4
Open <project_root>/gradle/gradle-wrapper.properties file and change gradle version in distributionUrl property. E.g.:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip

Also you need to delete wrapper task that defined in the end of build.gradle file

It seems that CUBA version in your project was manually changed from 7.1.X to 7.2.X.
Please always use Studio to change CUBA version. It performs all necessary migrations, including gradle version update.

1 Like