Gradle Ear 插件


当前第2页 返回上一页

另请参阅 Ear。

自定义

下面是一个示例,展示了最重要的自定义选项:

ear 插件的自定义

build.gradle

apply plugin: 'ear'
apply plugin: 'java'
repositories { mavenCentral() }
dependencies {
    //following dependencies will become the ear modules and placed in the ear root
    deploy project(':war')
    //following dependencies will become ear libs and placed in a dir configured via libDirName property
    earlib group: 'log4j', name: 'log4j', version: '1.2.15', ext: 'jar'
}
ear {
    appDirName 'src/main/app'  // use application metadata found in this folder
    libDirName 'APP-INF/lib'  // put dependency libraries into APP-INF/lib inside the generated EAR;
                                // also modify the generated deployment descriptor accordingly
    deploymentDescriptor {  // custom entries for application.xml:
//      fileName = "application.xml"  // same as the default value
//      version = "6"  // same as the default value
        applicationName = "customear"
        initializeInOrder = true
        displayName = "Custom Ear"  // defaults to project.name
        description = "My customized EAR for the Gradle documentation"  // defaults to project.description
//      libraryDirectory = "APP-INF/lib"  // not needed, because setting libDirName above did this for us
//      module("my.jar", "java")  // wouldn't deploy since my.jar isn't a deploy dependency
//      webModule("my.war", "/")  // wouldn't deploy since my.war isn't a deploy dependency
        securityRole "admin"
        securityRole "superadmin"
        withXml { provider -> // add a custom node to the XML
            provider.asNode().appendNode("data-source", "my/data/source")
        }
    }
}  

你还可以使用 Ear 任务提供的自定义选项,如 from 和 metaInf。

使用自定义的描述符文件

假设你已经有了 application.xml ,并且想要使用它而不是去配置 ear.deploymentDescriptor 代码段。去把 META-INF/application.xml 放在你的源文件夹里的正确的位置(请查看 appDirName 属性)。这个已存在的文件的内容将会被使用,而 ear.deploymentDescriptor 里的显示配置则会被忽略。


标签:Gradle

返回前面的内容

相关阅读 >>

Gradle 标准的 Gradle 插件

Gradle 使用 Gradle 图形用户界面

Gradle findbugs 插件

Gradle Gradle 命令行的基本使用

Gradle groovy 插件

Gradle pmd 插件

Gradle 构建基础

Gradle web 工程构建

Gradle 简介

Gradle 任务详述

更多相关阅读请进入《Gradle》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...