Variables not allowed in filter?


(tulsoba) #1

Using gradle 1.6. I am trying to filter some variables in a .properties file that must be located in the root of a war archive. The properties file contains:

buildNo=@buildNo@
version=@version@

In the build script I have:

import org.apache.tools.ant.filters.ReplaceTokens
war {
  from 'war'
  def vv = "$project.version"
    // Works
    println "$vv"
    // Fails
  filter(ReplaceTokens, tokens: ['version': "$vv"])
  // Fails
  //filter(ReplaceTokens, tokens: ['version':
'$vv'])
    // works
  //filter(ReplaceTokens, tokens: ['version': "mumbojumbo"])
    }

Is it not possible to use properties in a filter?


(tulsoba) #2

I figured that I should just use: project.version without any quotes etc. Is it possible to specify that ReplaceTokens should update/delete the file if it already exists with values?


(Tye Howard) #3

You could just specify that the ‘war’ task delete the file as part of a ‘doFirst’ closure. Alternatively, you could run ‘gradle clean war’ which should rebuild everything from scratch. You might also try using the ‘–rerun-tasks’ gradle option.