我正在做一个maven转换为gradle,并希望看到关于执行以下操作的最佳方式的意见.我目前在src/main/webapp下有多个文件.有些需要过滤,有些需要在另一个过滤.
理论上在src/main/webapp下我有一个包含html和二进制文件的目录foo,在webapp下有许多其他文件,包括html.我想只过滤foo/*.html文件.
在我的概念build.gradle中,我可以这样做:
war {
eachFile {
if(shouldFilter(it)) {
it.filter(ReplaceTokens, tokens: [key: 'value'])
}
}
}
def shouldFilter(input) {
input.path.contains('foo') && input.name.endsWith('.html')
}
Run Code Online (Sandbox Code Playgroud)
或将每个子集移动到默认情况下未复制的自己的目录中
war {
from('src/main/foo-pre-filter') {
into 'foo'
include '*.html'
filter(ReplaceTokens, tokens: [key: 'value'])
}
}
Run Code Online (Sandbox Code Playgroud)
还是我错过了另一种选择?
小智 16
如果我正确理解了这个问题,你可以使用filesMatching.另外,我会将其作为processResources任务的一部分,而不是war任务.它看起来像这样:
processResources {
filesMatching('foo/*.html') {
filter(ReplaceTokens, tokens: [key: 'value'])
}
}
Run Code Online (Sandbox Code Playgroud)
我意识到最初的问题是在2年前被问到的,所以这可能对提问者没有帮助,但也许它可能在将来帮助其他人.
| 归档时间: |
|
| 查看次数: |
4556 次 |
| 最近记录: |