无法在Cuba.Platform创建.war

时间:2017-12-04 09:00:26

标签: eclipse gradle web-deployment gradlew cuba-platform

我做了古巴的这个教程。平台:https://github.com/aleksey-stukalov/workshop/wiki

并在Eclipse IDE中开发了这个项目。

现在,我想部署项目,并使用此链接执行此操作:(使用gradle)

https://doc.cuba-platform.com/manual-latest/tomcat_war_deployment.html

但是,当我在gradlew buildWar命令中编写cmd时,我遇到以下问题:

gredlew buildWar失败:/

编辑:

当我用cmd写作时:gredlew buildWar --stacktrace
我得到了这个输出:

Caused by: org.gradle.api.file.UnableToDeleteFileException: Unable to delete directory: C:\Users\xxxx\Desktop\ersterTest\build\distributions\war
    at org.gradle.api.internal.file.delete.Deleter.handleFailedDelete(Deleter.java:109)
    at org.gradle.api.internal.file.delete.Deleter.doDeleteInternal(Deleter.java:86)
    at org.gradle.api.internal.file.delete.Deleter.delete(Deleter.java:66)
    at org.gradle.api.internal.file.delete.Deleter.delete(Deleter.java:47)
    at org.gradle.api.internal.file.DefaultFileOperations.delete(DefaultFileOperations.java:137)
    at org.gradle.api.internal.project.DefaultProject.delete(DefaultProject.java:790)
    at CubaWarBuilding.init(CubaWarBuilding.groovy:298)
    at CubaWarBuilding.build(CubaWarBuilding.groovy:172)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:141)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:632)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:615)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:95)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:76)
    … 70 more

BUILD FAILED

Total time: 6.15 secs

这是build.gradle:

buildscript {
    ext.cubaVersion = '6.7.3'
    repositories {

        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 globalModule = project(':app-global')
def coreModule = project(':app-core')
def guiModule = project(':app-gui')
def webModule = project(':app-web')

def servletApi = 'org.apache.tomcat:tomcat-servlet-api:8.0.26'
apply(plugin: 'idea')
apply(plugin: 'cuba')

cuba {
    artifact {
        group = 'com.company.erstertest'
        version = '0.1'
        isSnapshot = true
    }
    tomcat {
        dir = "$project.rootDir/deploy/tomcat"
    }
}

dependencies {
    appComponent("com.haulmont.cuba:cuba-global:$cubaVersion")

}

def hsql = 'org.hsqldb:hsqldb:2.2.9'

configure([globalModule, coreModule, guiModule, webModule]) {
    apply(plugin: 'java')
    apply(plugin: 'maven')
apply(plugin: 'idea')
apply(plugin: 'cuba')

    dependencies {
        testCompile('junit:junit:4.12')
    }

    task sourceJar(type: Jar) {
        from file('src')
        classifier = 'sources'
    }

    artifacts {
        archives sourceJar
    }
}

configure(globalModule) {
    task enhance(type: CubaEnhancing)


}

configure(coreModule) {

    configurations {
        jdbc
        dbscripts
    }

    dependencies {
        compile(globalModule)
        provided(servletApi)
        jdbc(hsql)
        testRuntime(hsql)

    }

    task cleanConf(description: 'Cleans up conf directory') {
        doLast {
            def dir = new File(cuba.tomcat.dir, '/conf/app-core')
            if (dir.isDirectory()) {
                ant.delete(includeemptydirs: true) {
                    fileset(dir: dir, includes: '**/*', excludes: 'local.app.properties')
                }
            }
        }
    }

    task deploy(dependsOn: [assemble, cleanConf], type: CubaDeployment) {
        appName = 'app-core'
        appJars('app-global', 'app-core')
    }

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

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

configure(guiModule) {
    dependencies {
        compile(globalModule)

    }

    task deployConf(type: Copy) {
        from file('src')
        include "com/company/erstertest/**"
        into "$cuba.tomcat.dir/conf/app"
    }
}

configure(webModule) {
    configurations {
        webcontent
    }

    dependencies {
        provided(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/company/erstertest/**"
        into "$cuba.tomcat.dir/conf/app"
    }

    task clearMessagesCache(type: CubaClearMessagesCache) {
        appName = 'app'
    }
    deployConf.dependsOn clearMessagesCache

    task cleanConf(description: 'Cleans up conf directory') {
        doLast {
            def dir = new File(cuba.tomcat.dir, '/conf/app')
            if (dir.isDirectory()) {
                ant.delete(includeemptydirs: true) {
                    fileset(dir: dir, includes: '**/*', excludes: 'local.app.properties')
                }
            }
        }
    }

    task deploy(dependsOn: [assemble, cleanConf], type: CubaDeployment) {
        appName = 'app'
        appJars('app-global', 'app-gui', 'app-web')
    }
}





task undeploy(type: Delete, dependsOn: ':app-web:cleanConf') {
    delete("$cuba.tomcat.dir/shared")
    delete("$cuba.tomcat.dir/webapps/app-core")
    delete("$cuba.tomcat.dir/webapps/app")
}

task restart(dependsOn: ['stop', ':app-core:deploy', ':app-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 = '3.4'
}

task buildWar(type: CubaWarBuilding) {
    appHome = './app_home'
    singleWar = false
    includeContextXml = true
    includeJdbcDriver = true
    appProperties = ['cuba.automaticDatabaseUpdate': true]
}

apply from: 'extra.gradle'

0 个答案:

没有答案