My aim is to build an exploded ear using this code:
task explodedEar(type: Sync) {
group = "build"
into "${ear.destinationDirectory.get().asFile.absolutePath}/exploded/${ear.archiveFileName.get()}"
with ear
}
ear.dependsOn explodedEar
Using this approach the ear is exploded. But the two war files (web, webservices) are simply copied to the exploded directory without being exploded themselves.
How can I achieve that the exploded ear contains the exploded (e.g. unpacked) war files?
I have to explain it to you why I’m trying to do that.
We are currently not able to use hot deploying (Update Resources) with IntelliJ.
So we have to restart the application server after each change in e.g xhtml (JSF) or CSS file.
I found a solution for the ear plugin. With the following code I get the ear plugin to use the exploded war file.
war build.gradle
apply plugin: "war"
configurations {
exploded
}
dependencies {
...
}
war {
from "/WebContent"
}
task explodeWar(type: Sync) {
into "$buildDir/libs/${war.archiveFile.get().asFile.getName()}"
with war
}
war.dependsOn explodeWar
artifacts {
exploded file("$buildDir/libs/exploded"), { builtBy explodeWar }
}
war {
archiveBaseName = 'yourWar'
from 'src/main'
}
task explodedWar(type: Sync) {
into "${buildDir}/libs/exploded/yourWar.war"
with war
}
then in my ear task, I check for a command line argument to determine if it is exploded or not:
def isDeployment = project.getProperties().get("isDeployment")
if (isDeployment) {
into ("") {
from war
}
} else {
into ("yourWar.war") {
from explodedWar
}
}
currently I have one build.gradle file but I am trying to seperate it into multiple projects