I have been trying ProGuard for last 3-4 days. Since the command line call is going to be pretty lengthy, I am trying with proguardgui.
After I came to know that by default, annotations are removed after obfuscation, I tried -keep option but the output jar did not work.
So next I tried disabling all the processing steps like Shrinking, Obfuscating, Optimizing and generated the jar, still dis not work! I confirmed that the output jar has spring mvc annotation by decompiling classes in output jar.
If I have disabled all the processing steps the output jar should be same as input jar, but I see that when I deploy input jar, annotations are detected, and when I deploy output jar, they don't.
Friends, Your help is sincerely appreciated. If required, I will post the sample code and dependencies to recreated this issue. Thanks! --Nealesh
2015/01/08: Here are the steps I am following:
- My jar is say xyz.jar located in C:/test directory.
- Deploy xyz.jar with the MVC web app.
- Confirm that error log shows:
INFO: Refreshing WebApplicationContext for namespace 'TestDataImport-servlet': startup date [Sun Jan 04 19:37:45 IST 2015]; root of context hierarchy Jan 04, 2015 7:37:45 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/TestDataImport-servlet.xml] Jan 04, 2015 7:37:46 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod INFO: Mapped "{[/dataimportcontroller/setconfig],methods=[POST],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public java.lang.String com.dn.controller.DataImportController.setconfig(java.lang.String[]) Jan 04, 2015 7:37:46 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod INFO: Mapped "{[/dataimportcontroller/insertRegion],methods=[POST],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public void com.dn.controller.DataImportController.insertRegion(java.lang.String) Jan 04, 2015 7:37:47 PM org.springframework.web.servlet.view.ContentNegotiatingViewResolver initServletContext
- This implies that the annotation are detected and the annotated method can be called over http.
- Start Proguardgui.
- On input/Output tab select Add Input and choose the jar file to be obfuscated.
- On input/Output tab select Add Output directry and name of the output jar, in my case C:/temp/xyzob.jar.
- Click next to go to “Shrinking” tab
- Uncheck “Shrink ” check box and click next to go to “Obfuscation” tab.
- Uncheck “Obfuscate” check box and click next to go to “Optimise” tab.
- Uncheck “Optimise” check box and click next to go to “Information” tab.
- Uncheck “Preverify” checkbox and click next to go to “Process” tab.
- Click “Process”.
- Use Decompiler and confirm that the annotations are preserved in the output jar.
- Replace the xyz.jar with xyzob.jar in the mvc web app.
- Redeploy web app.
- The log is shown as follows.
INFO: Refreshing WebApplicationContext for namespace 'TestDataImport-servlet': startup date [Sun Jan 04 19:33:39 IST 2015]; root of context hierarchy Jan 04, 2015 7:33:39 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/TestDataImport-servlet.xml] Jan 04, 2015 7:33:41 PM org.springframework.web.servlet.view.ContentNegotiatingViewResolver initServletContext
- INFO: Mapped messages are not present, which mean annotations are not detected.
- My issue is, if I am unchecking all the options, the input and output jars should have same content.