Gradle:ear deploymentDescriptor - 从application.xml中排除模块 [英] Gradle: ear deploymentDescriptor - Exclude module from application.xml

查看:284
本文介绍了Gradle:ear deploymentDescriptor - 从application.xml中排除模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的gradle构建文件中有以下内容。我的问题是log4j.properties被添加为application.xml中的ejb模块,尽管我尝试从这里的每个线程的xml中删除它:

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

//这不起作用:
withXml {xml - >
xml.asNode()。module.removeAll {it.ejb.text.equals('log4j.properties')}
}
}
//将log4j.properties添加到('../../ lib / log4j.properties','log4jProperties')
}


依赖关系
{
deploy'javax:javax.jnlp:1.2'
deploy'com.oracle:ojdbc6:1.6.0'

earlib'org.apache:apache-log4j:1.2.16 '
}

如何获取gradle从application.xml中排除log4j.properties ?



编辑

这会导致我的应用程序无法启动服务器(JBoss 6.0.0),因为它不知道如何处理log4j.properties。我可以通过手动创建我的application.xml文件来解决这个问题,但是这会导致需要维护的另一件事。任何协助都将受到欢迎!

解决方案

这段代码适用于我。您需要使用'if'块来保护'remove'方法,因为多次调用闭包。我发现它第一次被调用,log4jNode被设置为'null'。

  withXml {
def log4jNode = asNode()。module.find {it.ejb.text()=='log4j.properties'}
if(log4jNode){
asNode()。remove(log4jNode)
}
}


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 )
    }
}

这篇关于Gradle:ear deploymentDescriptor - 从application.xml中排除模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆