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

Hello,

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

ReplaceTokens is from Ant: http://api.dpml.net/org/apache/ant/1.7.0/org/apache/tools/ant/filters/ReplaceTokens.html

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

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

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.

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

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