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.
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.
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"
destinationDir(file("$warDist/"))
}
pack.mustRunAfter copyJbossConf
task jbossWar(description: 'Copies jboss config into WAR', dependsOn: [buildWar, unpack, copyJbossConf, pack])