The ProGuard Maven plugin and Java 7

8,582 views
Skip to first unread message

Morten Sabroe Mortensen

unread,
Feb 28, 2012, 12:39:46 PM2/28/12
to pyx4me-users

I have had a real hard time to get the ProGuard Maven plugin operate
with Java 7 and ProGuard 4.7 (which is the first to support Java 7;
the 4.7 version is about two month old).

Should you happen to have had some of the same problems then here
follows some hints which may help you to get past the same problem
too.

----

Using the plugin in a direct manner with POM settings specifying
ProGuard version 4.7 like -

---
<plugin>
<groupId>com.pyx4me</groupId>
<artifactId>proguard-maven-plugin</artifactId>
...
<configuration>
<proguardVersion>4.7</proguardVersion>
...
---

- makes the plugin pick version 4.4 since "proguard-4.4.jar" at the
time of writing is the newest version in the main, public Maven
repository (I wonder why versions 4.5, 4.6, 4.7 are not yet readily
available - hardly many modern people beoynd class file shrinking
destined for J2ME care for obfuscation!). This ends up in the older
ProGuard version to complain about the newer class file major version
number like -

---
[proguard] Reading library jar [C:\Program Files\Java\jdk1.7.0\jre\lib
\rt.jar]
[proguard] java.io.IOException: Can't read [C:\Program Files\Java
\jdk1.7.0\jre\lib\rt.jar] (Can't process class [com/or
acle/net/Sdp$1.class] (Unsupported version number [51.0] for class
format))
---

The solution is to make ProGuard 4.7 available. I downloaded this
version directly and imported it in my local Maven repository like
this -

---
mvn install:install-file -Dfile=C:\Download\ProGuard
\proguard4.7\proguard4.7\lib\proguard.jar -DgroupId=net.sf.proguard -
DartifactId=proguard -Dversion=4.7 -Dpackaging=jar -DgeneratePom=true
---

Then I put in a dependency in my POM file like this -

---
<plugin>
<groupId>com.pyx4me</groupId>
<artifactId>proguard-maven-plugin</artifactId>
...
<configuration>
<proguardVersion>4.7</proguardVersion>
...
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard</artifactId>
<version>4.7</version>
</dependency>
</dependencies>

</plugin>
...
---

- and then Java 7 works with ProGuard 4.7 and the not too new plugin
from around 2009 or so.

I hope this can help some of you - I was around compiling the plugin
from scratch and doing a lot af debugging on this subject before I
found the cause of things happening.

I guess another possibility is to circumvent the ProGuard-plugin and
use it from Ant directly through the Ant-plugin. But that is hardly
the point of having a ProGuard Maven plugin.

Manfred Moser

unread,
Feb 29, 2012, 12:41:30 PM2/29/12
to pyx4me...@googlegroups.com
Just in case you are wondering... newer proguard versions are not in
central because the author does not do it and nobody else stepped up
to do it.

Many developers use it as part of the Android Maven Plugin however but
we have integrated proguard directly and can load it dynamically from
the Android SDK, from a dependency and we might look into pushing a
new proguard version to central.

And Java 7 has not appeared for us yet since the Android build does
not support it..

manfred

> --
> You received this message because you are subscribed to the Google Groups "pyx4me-users" group.
> To post to this group, send email to pyx4me...@googlegroups.com.
> To unsubscribe from this group, send email to pyx4me-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/pyx4me-users?hl=en.
>

Daniel Serodio

unread,
Aug 24, 2012, 6:04:52 PM8/24/12
to pyx4me...@googlegroups.com
I see there are "proguard-base" JARs for 4.5 up to 4.8 at Maven Central. Isn't "proguard-base" the same as the previous "proguard" JAR?


Regards,
Daniel Serodio

Manfred Moser

unread,
Aug 28, 2012, 1:47:41 AM8/28/12
to pyx4me...@googlegroups.com
Yes... latest version got uploaded after I posted the message below
and I figured out who did the uploads and contacted them on github ..

manfred
> To view this discussion on the web visit
> https://groups.google.com/d/msg/pyx4me-users/-/iT9jw0k8FtMJ.

Daniel Serodio

unread,
Aug 29, 2012, 9:54:26 AM8/29/12
to pyx4me...@googlegroups.com
Right after I'd sent that e-mail, I tried adding a dependency on proguard-base:4.8 but it didn't work. I had to download the "proguard 4.8" distribution ZIP and use "mvn install:install-file" on proguard.jar and add a dependency on proguard:4.8 instead.

Regards,
Daniel Serodio

Jaime Hablutzel Egoavil

unread,
Oct 12, 2012, 10:35:36 PM10/12/12
to pyx4me...@googlegroups.com
A patch has been published for the plugin so it does support from proguard 4.5 onwards (because of a change in the layout of maven repository). 


Projects administrators... maybe it is time to release a new version of the plugin?

Anyway, if you can't wait download trunk from subversion, build it and with one plugin configuration like the following you should be using the 4.8 version (with support for JDK7)

         <plugin>
                <groupId>com.pyx4me</groupId>
                <artifactId>proguard-maven-plugin</artifactId>
                <version>2.1.0-SNAPSHOT</version>
          ...
                <configuration>
                    <proguardVersion>4.8</proguardVersion>
                ...
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>net.sf.proguard</groupId>
                        <artifactId>proguard-base</artifactId>
                        <version>4.8</version>
                    </dependency>
                </dependencies>
            </plugin>

Farrukh Najmi

unread,
Mar 5, 2013, 6:53:20 PM3/5/13
to pyx4me...@googlegroups.com
I am trying to upgrade my project to JDK 7 proguard-maven-plugin has not yet released the simple safe patch mentioned by Jaime below.

Vlad and Michael you are listed as the project team. Could you please let us know what to expect and if you need any help to make a release happen with this fix.

Thanks for a great plugin.

Bernd S

unread,
Apr 10, 2013, 9:46:25 PM4/10/13
to pyx4me...@googlegroups.com
FYI, there is a fork on github. The artifact is already in Maven Central. I'm using it like this:

            <plugin>
                <groupId>com.github.wvengen</groupId>
                <artifactId>proguard-maven-plugin</artifactId>
                <version>2.0.6</version>

                <dependencies>
                    <dependency>
                        <groupId>net.sf.proguard</groupId>
                        <artifactId>proguard-base</artifactId>

                        <version>4.9</version>
                        <scope>runtime</scope>
                    </dependency>
                </dependencies>
                <!-- configuration + executions skipped -->
            </plugin>
Reply all
Reply to author
Forward
0 new messages