I have the following in my gradle build file. My problem is that log4j.properties is being added as an ejb module in application.xml, despite my attempt to remove it from the xml per the thread here:
http://forums.gradle.org/gradle/topics/ear_plugin_inserts_unneeded_ejb_modules_in_the_application_xml_ear_descriptor
apply plugin: 'ear'
ear {
deploymentDescriptor {
applicationName = 'ourapp'
displayName = 'ourapp'
initializeInOrder = true
//This doesn't work:
withXml { xml ->
xml.asNode().module.removeAll { it.ejb.text.equals('log4j.properties') }
}
}
//Add log4j.properties to ear root
from('../../lib/log4j.properties', 'log4jProperties')
}
dependencies
{
deploy 'javax:javax.jnlp:1.2'
deploy 'com.oracle:ojdbc6:1.6.0'
earlib 'org.apache:apache-log4j:1.2.16'
}
How can I get the gradle to exclude log4j.properties from application.xml?
EDIT
This is causing a failure to start up in my application server (JBoss 6.0.0) because it doesn't know what to do with log4j.properties. I can work around it by manually creating my application.xml file, but that makes for another thing that has to be maintained. Any assistance would be welcome!
This code works for me. You need to protect the 'remove' method with an 'if' block because the closure is called multiple times. I found that the first time its called, log4jNode is set to 'null'.
withXml {
def log4jNode = asNode().module.find { it.ejb.text() == 'log4j.properties' }
if (log4jNode) {
asNode().remove( log4jNode )
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With