在Grails中创造耳朵 [英] create ear in grails

查看:91
本文介绍了在Grails中创造耳朵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Grails支持创建战争。但是有没有什么命令可以通过grails创建一个ear?

解决方案

Grails中没有直接的支持,但是这个Gant脚本会执行工作。简单地添加到 scripts / dir并调用为 grails ear



脚本最初由 Graeme发送邮件列表

  includeTargets<< grailsS​​cript(_ GrailsWar)

target(ear:从Grails WAR创建EAR文件){
war()
event(StatusUpdate,[Building EAR文件])
generateApplicationXml()
def warDest = new File(warName).parentFile
def earFile =$ {projectTargetDir} / $ {contextRoot} .ear
ant.ear(destfile:earFile,appxml:appXml,update:true){
fileset(dir:warDest,包括:* .war)
}
event(StatusFinal, [完成创建EAR $ earFile])
}
target(defineContextRoot:定义上下文根){
contextRoot =$ {grailsAppName} $ {grailsAppVersion?' - '+ grailsAppVersion:''}
}
target(generateApplicationXml:生成一个application.xml文件){
depends(defineContextRoot)
def warDest = new File(warName)
appXml =$ {projectTargetDir} /application.xml
新文件(appXml).write\
<?xml version =1.0encoding =UTF-8 ?>
< application
xmlns = http://java.sun.com/xml/ns/j2ee
xmlns:xsi =http://www.w3.org/ 2001 / XMLSchema-instance
xsi :schemaLocation =http:// java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/ application_1_4.xsd
version = 1.4\" >
< display-name> $ {grailsAppName}< / display-name>

< module>
< web>
< web-uri> $ {warDest.name}< / web-uri>
< context-root> $ {contextRoot}< / context-root>
< / web>
< / module>

< / application>

}

setDefaultTarget(ear)


grails supports creation of war. But is there any command to create an ear through grails?

There's no direct support in Grails, but this Gant script will do the job. Simply added to scripts/ dir and invoked as grails ear.

Script originally posted by Graeme on mailing list

includeTargets << grailsScript("_GrailsWar")

target(ear: "Creates an EAR file from a Grails WAR") {
    war()   
    event("StatusUpdate", ["Building EAR file"])
    generateApplicationXml()
    def warDest = new File(warName).parentFile
    def earFile = "${projectTargetDir}/${contextRoot}.ear"
    ant.ear(destfile:earFile, appxml:appXml, update:true) {
        fileset(dir:warDest, includes:"*.war")
    }
    event("StatusFinal", ["Done creating EAR $earFile"])
}
target(defineContextRoot:"defines the context root") {
    contextRoot = "${grailsAppName}${grailsAppVersion ? '-'+grailsAppVersion : ''}" 
}
target(generateApplicationXml:"Generates an application.xml file") {
    depends(defineContextRoot)
    def warDest = new File(warName)
    appXml = "${projectTargetDir}/application.xml"
    new File(appXml).write """\
<?xml version="1.0" encoding="UTF-8"?> 
<application 
xmlns=http://java.sun.com/xml/ns/j2ee
       xmlns:xsi="http://www.w3.org/ 2001/XMLSchema-instance" 
       xsi:schemaLocation="http:// java.sun.com/xml/ns/j2ee 
           http://java.sun.com/xml/ns/j2ee/ application_1_4.xsd" 
       version="1.4"> 
<display-name>${grailsAppName}</display-name> 

<module> 
    <web> 
        <web-uri>${warDest.name}</web-uri> 
        <context-root>${contextRoot}</context-root> 
    </web> 
 </module> 

</application>  
"""
}

setDefaultTarget(ear)

这篇关于在Grails中创造耳朵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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