I want to extract file "default.jasperreports.properties" from depended jasperreports.jar and put it in zip distribution with new name "jasperreports.properties"
Sample gradle build:
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'
}
How to get FileTree in extractFileFromJar() from dependency jasperreports-2.0.5.jar?
In script above I use
FileTree tree = zipTree('someFile.zip')
but want to use somethink like (wrong, but human readable)
FileTree tree = configurations.runtime.filter("jasperreports").singleFile.zipTree
PS: Try to call
def extractFileFromJar(String fileName) {
configurations.runtime.files.each { file -> println file} //it's not work
...
but it doesn't work with exception
You can't change a configuration which is not in unresolved state!