Hi Everyone,
We have a EAR project With Customized application.xml, I have a gradle script to build the EAR which in turn generates default application.xml. But i want to use my customized application.xml in the source code.
How can i tell gradle to use my customized application.xml for the EAR project.
jeankst
(KST)
October 4, 2018, 2:03pm
2
My story:
Attempt#1 the naive newbie approach
ear {
deploymentDescriptor {
readFrom "${buildDir}/application.xml"
}
}
ear.dependsOn "buildApplicationXml"
task buildApplicationXml() {
doLast {
// generate "${buildDir}/application.xml"
}
}
=> Failed: file does not exist at evaluation time, so you silently get the automatically generated one instead
…
Attempt#957 ConfigurableFileCollection
ear {
deploymentDescriptor {
readFrom files("${buildDir}/application.xml") {
builtBy "buildDeploymentApplication"
}.singleFile
}
}
task buildApplicationXml() {
doLast {
// generate "${buildDir}/application.xml"
}
}
=> Failed: gradle still check the file at evaluation time, so error: does not exist
Attempt#958 so… you said you won’t eat my application.xml?
ear {
exclude "application.xml"
}
ear.dependsOn "buildApplicationXml"
ear.finalizedBy "includeApplicationXml"
task buildApplicationXml() {
doLast {
// generate "${buildDir}/META-INF/application.xml"
}
}
task includeDeploymentApplication {
doLast {
ant.jar(update: "true", destfile: "${buildDir}/libs/${project.ear.archiveName}") {
fileset(dir: "${buildDir}", includes: "META-INF/application.xml")
}
}
}
=>
Do let me know if you have found a better solution than my brute force “hack”…
Regards,
Jean.