另请参阅 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》频道 >>