我想从依赖的 jasperreports.jar 中提取文件“default.jasperreports.properties”并将其放入新名称“jasperreports.properties”的 zip 分发中
示例 gradle 构建:
apply plugin: 'java'
task zip(type: Zip) {
from 'src/dist'
// from configurations.runtime
from extractFileFromJar("default.jasperreports.properties");
rename 'default.jasperreports.properties', 'jasperreports.properties'
}
def extractFileFromJar(String fileName) {
// configurations.runtime.files.each { file -> println file} //it's not work
// not finished part of build file
FileTree tree = zipTree('someFile.zip')
FileTree filtered = tree.matching {
include fileName
}
}
repositories {
mavenCentral()
}
dependencies {
runtime 'jasperreports:jasperreports:2.0.5'
}
如何从依赖项 jasperreports-2.0.5.jar 中获取 extractFileFromJar() 中的 FileTree?
在上面的脚本中我使用
FileTree tree = zipTree('someFile.zip')
但想使用 somethink like(错误,但人类可读)
FileTree tree = configurations.runtime.filter("jasperreports").singleFile.zipTree
PS:试着打电话
def extractFileFromJar(String fileName) {
configurations.runtime.files.each { file -> println file} //it's not work
...
但它不适用于异常
您不能更改未处于未解决状态的配置!