在 grails 中创建耳朵

发布于 2024-10-15 21:50:29 字数 43 浏览 5 评论 0原文

grails 支持制造战争。但是有没有通过grails创建耳朵的命令呢?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

断桥再见 2024-10-22 21:50:30

Grails 中没有直接支持,但这个 Gant 脚本可以完成这项工作。只需添加到 scripts/ 目录并作为 grails Ear 调用即可。

脚本最初由 Graeme 在邮件列表上发布

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)

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)
羞稚 2024-10-22 21:50:30

这是一个很晚的答案,但现在 grails maven 插件非常好。因此,您可以在 grails maven 插件产生的战争中构建一个耳朵。

This is a very late answer, but nowadays the grails maven plugin is pretty good. So you could just build an ear out of the war produced by the grails maven plugin.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文