Replacing a token in a java file for compiling

I want to replace a token within a .java file with gradle specifically this I discovered this solution (my attempt) however for lack of a better term its ‘not working’ (I cannot see the changes in the final result). Any ideas?