[英]Gradle deploy project to ear
我有以下結構的項目
--MyPrj.ear
--APP-INF
--src
--lib
--META-INF
--application.xml
--weblogic-application.xml
--WEB_MAIN
--assets
--WEB-INF
--conf
--web.xml
--weblogic.xml
我想以下面的結構部署到PRJ.ear文件:
--MyPrj.ear
--APP-INF
--classes
--lib
--META-INF
--application.xml
--weblogic-application.xml
--WEB_MAIN
--assets
--WEB-INF
--conf
--web.xml
--weblogic.xml
這是我的耳朵配置:
ear {
baseName 'PRJ'
appDirName 'APP-INF/src'
libDirName 'APP-INF/lib'
ear{
into("META-INF"){
from("META-INF") {
exclude 'application.xml'
}
}
into("WEB_MAIN") {
from ("WEB_MAIN")
}
}
deploymentDescriptor {
webModule 'WEB_MAIN', '/'
applicationName = "PRJ"
}
}
我的實際結果:
--MyPrj.ear
--APP-INF
--lib
--com
--META-INF
--application.xml
--weblogic-application.xml
--WEB_MAIN
--assets
--WEB-INF
--conf
--web.xml
--weblogic.xml
無法生成APP-INF/classes
我將從一個觀察開始:構建腳本中的兩個ear
實例都指向同一個任務。 沒有必要兩次引用ear
,即into
聲明可以達到一級。
首先,將文件夾APP-INF/src
為源集。 這將導致編譯的類被添加到EAR的根目錄,因此您必須排除這些。 然后你必須告訴ear
任務將已編譯的類復制到EAR中的APP-INF/classes
目錄:
// Make sure the source files are compiled.
sourceSets {
main {
java {
srcDir 'APP-INF/src'
}
}
}
ear {
baseName 'PRJ'
libDirName 'APP-INF/lib'
into("META-INF") {
from("META-INF") {
exclude 'application.xml'
}
}
into("WEB_MAIN") {
from("WEB_MAIN")
}
deploymentDescriptor {
webModule 'WEB_MAIN', '/'
applicationName = "PRJ"
}
// Exclude the compiled classes from the root of the EAR.
// Replace "com/javathinker/so/" with your package name.
eachFile { copyDetails ->
if (copyDetails.path.startsWith('com/javathinker/so/')) {
copyDetails.exclude()
}
}
// Copy the compiled classes to the desired directory.
into('APP-INF/classes') {
from(compileJava.outputs)
}
// Remove empty directories to keep the EAR clean.
includeEmptyDirs false
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.