In my application mofule-info.class is needed to compile project into one jar and then package it using jpackage for deployment, so I really need it to be there obfuscated.
I did try solution you mentioned, but keeping module-info is not working as after obfuscation all the opens and exports paths stay un-obfuscated and looses all the references to the whole module.
My only solution to that for now (which is pretty ugly) is following Gradle script:
- Build project without proguard and save module-info.class somewhere outside build directory
- Create input.map for proguard which includes all exports and opens from module-info.java
- Open module-info.class (binary) and replace parts of compiled names of exports and opens to names from the input.map (names have to be exactly the length of the original as it is already compiled file)
- Build obfuscated jar with proguard and unpack classes to the build directory overwriting original ones
- Overwrite module-info.class with the one that was manipulated in step 3
- Build the project using obfuscated classes and module-info.class
- jLink and jPackage to distribution
It works well as long as you don’t change your module-info.java very often, but once I do any changes I have to go to manual labour of manipulating already compiled class file.
This is the only way I can get application obfuscated and packaged. If there is any other, please do tell. If only proguard could use in.map to obfuscate module-info.java, that would be great and saved me a lot of hassle and time with manipulating already compiled class file.
If you have any ideas to make this process better I would appreciate.