1

I have a Java / Spring MVC web app in a WAR file.

The WAR file will be downloaded by corporate customers, so I need to obfuscate the classes in the WAR. The obfuscater I'm using (Allatori) nicely obfuscates all of the classes in the /classes folder in the WAR.

The problem is, the JSPs (which are uncompiled) are referencing the Java classes by their original (unobfuscated) names.

I'm thinking if the JSPs were compiled and in the /classes folder, the obfuscater would get those too.

My question is ... is there a way to compile the JSPs at build time and have them included in the /classes folder?

AndySummers2020
  • 411
  • 1
  • 6
  • 14

1 Answers1

1

You can use The Apache Sling JSPC Maven Plugin which does exactly what you need.

Arvind Kumar Avinash
  • 71,965
  • 6
  • 74
  • 110
  • Oh, wow! Thanks for the help! I'll look at it right away and report back. – AndySummers2020 Jul 10 '20 at 14:47
  • Hi -- when I add that plugin to my pom.xml and run it, I'm getting this error: `Caused by: java.lang.IllegalStateException: basedir .../myproject/src/main/scripts does not exist` ... this is because my JSPs live in folder `/src/main/webapp/WEB-INF/jsp` ... do you happen to know how to tell maven (or this new plugin) where to look for my JSPs? – AndySummers2020 Jul 10 '20 at 15:04
  • 1
    Unfortunately, I haven't used it myself but since I knew about it, I suggested it to you. Please check https://sling.apache.org/components/jspc-maven-plugin/jspc-mojo.html and https://html.developreference.com/article/13224961/How+to+eliminate+org+apache+jsp+from+the+output+path+of+the+Apache+Sling+jspc-maven-plugin%3F if you find something helpful there. – Arvind Kumar Avinash Jul 10 '20 at 15:10