How can I filter a single file and get it into a war?

(Oliver Kopp) #1

I’m trying to filter a single file during for the war task.

If I use the following, the file is filtered into the build directory, but the tokens are not replaced in the war file.

The tokens are encoded via ‘@version@’. If I enable ‘into buildDir’, gradle wants to copy a file “C:” as I’m on windows. If I enable “expand(…)”, gradle crashes as the it isn’t able to parse the file. The question is, how can I filter a single file and get the result into the packaged war?


processResources {

from(‘src/main/webapp/’) {

include ‘jsp/header.jsp’

//into buildDir

//expand(copyright: COPYRIGHT, version: VERSION_STRING)

filter(ReplaceTokens, tokens: [copyright: COPYRIGHT, version: VERSION_STRING])



(oliver.kopp) #2

I got one step further. The tokens get replaced, but only in the build directory. The tokens are NOT replaced in the WAR.