Luc*_*Luc 7 java ear weblogic web-applications gradle
我有以下结构的项目
--MyPrj.ear
--APP-INF
--src
--lib
--META-INF
--application.xml
--weblogic-application.xml
--WEB_MAIN
--assets
--WEB-INF
--conf
--web.xml
--weblogic.xml
Run Code Online (Sandbox Code Playgroud)
我想以下面的结构部署到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
Run Code Online (Sandbox Code Playgroud)
这是我的耳朵配置:
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"
}
}
Run Code Online (Sandbox Code Playgroud)
我的实际结果:
--MyPrj.ear
--APP-INF
--lib
--com
--META-INF
--application.xml
--weblogic-application.xml
--WEB_MAIN
--assets
--WEB-INF
--conf
--web.xml
--weblogic.xml
Run Code Online (Sandbox Code Playgroud)
无法生成 APP-INF/classes
小智 3
我将从一个观察开始:ear构建脚本中的两个实例都引用相同的任务。无需引用ear两次,即into声明可以上升一级。
首先,将该文件夹添加APP-INF/src为源集。这将导致编译的类被添加到 EAR 的根目录中,因此您必须排除这些类。然后您必须告诉ear任务将编译的类复制到APP-INF/classesEAR 中的目录:
// 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
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3640 次 |
| 最近记录: |