I find that filesMatching under war task works but does not work when in webInf as shown in the following code:
war {
from ('src/test/webapp') {
filesMatching('WEB-INF/web.xml') { // filesMatching work
expand([
'cxf': cxf
])
}
}
webInf {
from ('src/test/resources') {
filesMatching('hibernate.cfg.xml') { // filesMatching does not work
expand([
'hibernate': hibernate
])
}
}
into 'classes'
}
}
Take the sample webApplication/customized from gradle-1.10 samples. Change the empty file src/additionalWebInf/additional.xml to have ${variable1} in it and also change the build.gradle webInf method like below:
webInf { // adds a file-set to the WEB-INF dir.
from(‘src/additionalWebInf’) {
filesMatching(‘additional.xml’) {
expand([
‘variable1’: ‘value1’
])
}
}
}
Run gradle war. You can find that ${variable} is not replaced with value1 in the built war.
The issue is that the destination path is used, so the effective path is actually ‘WEB-INF/additional.xml’. I’ve raised this internally for discussion as to whether this is the right behaviour.