I would not replace tokens in Java code at all.
I would have a properties file with placeholders.
The processResources
task is prepared to do some filtering or placeholder replacement.
The code would then read the value from the properties file, or from one class that reads the properties file.