Java Gradle ear插件-截取复制的每个库文件
我有下面的build.gradle,它生成一个EAR文件,其中包含一个BeanJAR,并在APP-INF/lib中包含该jar的所有依赖项Java Gradle ear插件-截取复制的每个库文件,java,gradle,ear,Java,Gradle,Ear,我有下面的build.gradle,它生成一个EAR文件,其中包含一个BeanJAR,并在APP-INF/lib中包含该jar的所有依赖项 apply plugin: 'ear' dependencies { deploy(group: 'com.mycompany', name: 'MyServiceBean', version: '1.0.1') earlib project(path:':MyServiceBean', configuration: 'compile')
apply plugin: 'ear'
dependencies {
deploy(group: 'com.mycompany', name: 'MyServiceBean', version: '1.0.1')
earlib project(path:':MyServiceBean', configuration: 'compile')
}
ear {
libDirName 'APP-INF/lib'
deploymentDescriptor {
initializeInOrder = true
displayName = "MyServiceEAR"
description = "Description of the application."
}
eachFile { fcd ->
//this only prints out files in the root of the EAR
println "Copying file: " + fcd.name
}
}
APP-INF/lib中的一些文件包含特定于环境的值,而不是我的计划,我们现在无法更改继承的代码。创建EAR文件时,我要做的是
在复制APP-INF/lib时,循环遍历进入APP-INF/lib的每个jar
提取那个jar文件
用特定于环境的值替换某些文件中的占位符
重新打包那个jar文件
继续将新文件放入APP-INF/lib。
我知道如何重新打包,但我不知道如何循环进入APP-INF/lib的文件
apply plugin: 'ear'
dependencies {
deploy(group: 'com.mycompany', name: 'MyServiceBean', version: '1.0.1')
earlib project(path:':MyServiceBean', configuration: 'compile')
}
ear {
libDirName 'APP-INF/lib'
deploymentDescriptor {
initializeInOrder = true
displayName = "MyServiceEAR"
description = "Description of the application."
}
eachFile { fcd ->
//this only prints out files in the root of the EAR
println "Copying file: " + fcd.name
}
}
我的eachFile闭包只打印出EAR根目录中的文件名,即application.xml和MyServiceBean.jar
如何循环遍历APP-INF/lib目录中的每个文件
谢谢 我认为您可以通过使用ziptree来实现这一点,看看GitHub上的示例项目,例如。?