Can I specify a different token begin and end string for ReplaceTokens?

(kiran_anantha) #1


I want to use @@ (double @) as the delimiter for my tokens (ex: @@version@@). Can I specify this in ReplaceTokens? Something like this?

filter(ReplaceTokens, delimiter: ‘@@’, tokens: [copyright: ‘2009’, version: ‘2.3.1’])

Thanks, Kiran

(Luke Daley) #2

ReplaceTokens is from Ant:

You can set ‘beginToken’ and ‘endToken’, but they are single chars for some bizarre reason.

(kiran_anantha) #3

Oh, I see. If I want to replace tokens in files, is there an alternative to ReplaceTokens in gradle?

(Luke Daley) #4

The class you give to ‘filter()’ is anything that implements Java’s ‘FilteredInputStream’. If you need to use ‘@@’ as delimiters, you’re probably going to have to write your own impl.

(kiran_anantha) #5

OK, thanks. Isn’t ReplaceTokens a type of I take it a sub type of FilterReader will also work?

(Luke Daley) #6

Yes it will. I meant ‘FilterReader’ when I said ‘FilteredInputStream’.