Not able to copy jboss-deployment-structure.xml file into war

Hi Everyone,

I am trying to build war file for Wildfly using gradle.
As suggested in the documentation i have added below task to gradle file but the jboss-deployment-structure.xml is not getting copied to war file.

task buildWar(type: CubaWarBuilding) {
singleWar = false
appProperties = [‘cuba.automaticDatabaseUpdate’: true]
appHome = ‘/home/rioc/app_home’
doLast = {
copy {
from ‘jboss-deployment-structure.xml’
into “${project.buildDir}/buildWar/core/war/META-INF/”
copy {
from ‘jboss-deployment-structure.xml’
into “${project.buildDir}/buildWar/web/war/META-INF/”

This jboss-deployment file is needed for war file deployment in wildfly. currently i am having classcastexception for slf4j loggers.

Could you please help me in resolving the issue.

Thank you.

I tried to reproduce your problem:

task buildWar(type: CubaWarBuilding) {
    appProperties = ['cuba.automaticDatabaseUpdate': true]
    appHome = '../app_home'
    singleWar = false
    doLast {
        copy {
            from "jboss-deployment-structure.xml"
            into "${project.buildDir}/buildWar/core/war/META-INF/"
        copy {
            from "jboss-deployment-structure.xml"
            into "${project.buildDir}/buildWar/web/war/META-INF/"

The result of the task is buildWar:

├── buildWar
│   ├── core
│   │   └── war
│   │       └── META-INF
│   │           └── jboss-deployment-structure.xml
│   └── web
│       └── war
│           └── META-INF
│               └── jboss-deployment-structure.xml
├── distributions
│   └── war
│       ├── app-core.war
│       └── app.war
└── tmp

You wrote doLast = { but right - doLast { without =
Try please.

1 Like

Hi Aleksey,

Thanks for your reply.

I was able to copy buildwar directory but i want the jboss-deployment file to be packaged in app-core.war file as i am deploying them in wildfly on the server.

Hello @paddu.bits

Unfortunately our CubaWarBuilding task doesn’t allow you to specify any external dependency. So I suggest you to use straightforward solution - unpack WAR, copy config, pack again:

task buildWar(type: CubaWarBuilding) {

def warDist = "$buildDir/distributions/war"

task unpack(type: Copy) {
    def appCoreWar = file("$warDist/app-core.war")

    from zipTree(appCoreWar)
    into file("$warDist/app-core/")
unpack.mustRunAfter buildWar

task copyJbossConf(type: Copy) {
    from file('jboss-deployment-structure.xml')
    into "$warDist/app-core/META-INF"
copyJbossConf.mustRunAfter unpack

task pack(type: Zip) {
    from fileTree("$warDist/app-core/")
    archiveName "app-core.war"
pack.mustRunAfter copyJbossConf

task jbossWar(description: 'Copies jboss config into WAR', dependsOn: [buildWar, unpack, copyJbossConf, pack])

Thanks for the update.
I am currently doing the same. I just wanted to check if this can be done as part of cubawarbuilding task.

We’ll think about how task works and probably will copy all files from META-INF into WAR.