Obfuscate variable names on single files

I’d like to replace all the variable, function and class names in single .java files with generic names (such as VAR_0, VAR_1 etc…). It seems like proguard could support my usecase if I was to replace the SimpleNameFactory class. I may be missing something obvious, but I did not find how to run proGuard to obfuscate all the variable names in single java files.
Is there any easy way to obfuscate single java files ? These files are syntactically correct but they can use imports from other files and cannot always be compiled in isolation. I’d like to obfuscate them in isolation without having to compile an entire project.

Thanks !

Hi Broz,

I’m a bit confused on the use case here, could you please elaborate on it? Normally you would want to obfuscate your entire project and not just one class. If ProGuard would rename methods or variables only in one class file, it will result in compile-time issues in case these methods, variables are used somewhere else in your code.

When integrating ProGuard in your project, name obfuscation is typically applied to all code besides the classes, methods and fields that match one of your -keep rules.