Filter with TokenFilter.DeleteCharacters produces Invalid filter specification

(alex shubert) #1

Let’s imagine we have properties file with jdbc.url=${jdbc.url} As far as ReplaceTokens can’t operate on any tokens longer than 1 char ( {jdb.url} will work. Same with ${…} will not) we have to strip ‘$’ somehow. DeleteCharacters looks suitable but then I do

filter(TokenFilter.DeleteCharacters, chars: '\$')

it leads to

Caused by: org.gradle.api.InvalidUserDataException: Error - Invalid filter specification for$DeleteCharacters

Any ideas what is going on? Thanks

Ofc, I can replace this call by filter {line -> line.replace ‘abc’, ‘’} but looking for explanation.

(René Groeschke) #2

TokenFilter.DeleteCharacters implements TokenFilter.Filter and gradle does not support this kind of filter. I think the expand() method can solve your problem. here’s an example:

task myCopy(type:Copy){
 expand(jdbcUrl: "http://myCompany:8081/...")

regards, René

(alex shubert) #3

Thanks for answer, your approach works fine, just like mine.

(René Groeschke) #4

maybe I phrased it badly. The problem is not that TokenFilter.DeleteCharacters implements TokenFilter.Filter, but that it does not extend from Have a look at the javadoc of the filter method for the details:

regards, René

(alex shubert) #5

Most stupid question ever. I read that FilterReader about 5 times, I knew that DeleteCharacter doesn’t inherit it and checked hierachy about 7 times but I was looking for interfaces only. It even didn’t came into my head that someone can use particular classes and not the interface to distinct the classes…

Thanks for explanation.

(Gábor Guta) #6

Can the TokenFilter class be used as wrapper???

Can someone help with the syntax? filter(TokenFilter (TokenFilter.ReplaceRegex , pattern: ~/lib/store/store/, replace: ‘lib/store/store.min’))