obfuscate war

735 views
Skip to first unread message

PaulR

unread,
Mar 9, 2012, 12:54:28 AM3/9/12
to pyx4me-users
Hi,

This has probably been asked several times before. But from all the
posts I've seen, I haven't found someone do it successfully.

What I have is a web application that packages into a WAR with other
JAR dependencies. What I want to do is obfuscate my java classes (and
not the classes in the JAR dependencies). Can anyone give me a
working pom snippet for this? I currently have:
[code]
<plugin>
<groupId>com.pyx4me</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<obfuscate>true</obfuscate>
<includeDependency>false</includeDependency>
<injar>${project.artifactId}.war</injar>
<outjar>${project.artifactId}-obf.war</outjar>
<outputDirectory>${project.build.directory}</
outputDirectory>
<maxMemory>1024m</maxMemory>
<libs>
<!-- Java Runtime -->
<lib>${java.home}/lib/rt.jar</lib>
</libs>
<options>
<option>-ignorewarnings</option>
<option>-allowaccessmodification</option>
<option>-dontskipnonpubliclibraryclasses</option>
<option>-dontskipnonpubliclibraryclassmembers</
option>
</options>
</configuration>
</plugin>
[/code]

And running mvn proguard:proguard -X, I get a failed build with the
message:
[proguard] You might consider explicitly keeping the mentioned
classes an
d/or
[proguard] their implementations (using '-keep').
[proguard] Note: there were 64 accesses to class members by means of
introspect
ion.
[proguard] You may need to specify additional library jars
(using '-li
braryjars'),
[proguard] You should consider explicitly keeping the mentioned
class mem
bers
[proguard] (using '-keep' or '-keepclassmembers').
[proguard] or perhaps the '-dontskipnonpubliclibraryclasses'
option.
[proguard] Warning: there were 320 instances of library classes
depending on pr
ogram classes.
[proguard] You must avoid such dependencies, since the
program classes
will
[proguard] Ignoring unused library classes...
[proguard] Original number of library classes: 16924
[proguard] Final number of library classes: 1502
[proguard] be processed, while the library classes will
remain unchang
ed.
[proguard] Printing kept classes, fields, and methods...
[proguard] Warning: there were 20855 unresolved references to program
class mem
bers.
[proguard] Your input classes appear to be inconsistent.
[proguard] You may need to recompile them and try again.
[proguard] Alternatively, you may have to specify the
options
[proguard] '-dontskipnonpubliclibraryclasses' and/or
[proguard] '-dontskipnonpubliclibraryclassmembers'.
[proguard] java.io.IOException: You have to specify '-keep' options
for the shr
inking step.
[proguard] at proguard.ProGuard.printSeeds(ProGuard.java:242)
[proguard] at proguard.ProGuard.execute(ProGuard.java:95)
[proguard] at proguard.ProGuard.main(ProGuard.java:499)
[INFO]
------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 18.987s
[INFO] Finished at: Fri Mar 09 16:53:04 EST 2012
[INFO] Final Memory: 4M/106M
[INFO]
------------------------------------------------------------------------
[ERROR] Failed to execute goal com.pyx4me:proguard-maven-plugin:
2.0.4:proguard (
default-cli) on project opinionwatch-web: Obfuscation failed
(result=1) -> [Help
1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to
execute goal c
om.pyx4me:proguard-maven-plugin:2.0.4:proguard (default-cli) on
project opinionw
atch-web: Obfuscation failed (result=1)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:217)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:84)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:59)
at
org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBu
ild(LifecycleStarter.java:183)
at
org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:
320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:
156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:290)
at
org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:230)
at
org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
at
org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Obfuscation
failed (r
esult=1)
at
com.pyx4me.maven.proguard.ProGuardMojo.proguardMain(ProGuardMojo.java
:633)
at
com.pyx4me.maven.proguard.ProGuardMojo.execute(ProGuardMojo.java:486)

at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:101)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:209)
... 19 more


Sorry for the long post.

Hope someone can help, thanks!
Reply all
Reply to author
Forward
0 new messages