Java 7 |使用Proguard 4.8进行混淆

时间:2013-01-29 14:41:39

标签: java maven obfuscation proguard

我正试图用Proguard 4.8在java 7中混淆我的项目。

这是我的maven插件配置:

            <plugin>
            <groupId>com.pyx4me</groupId>
            <artifactId>proguard-maven-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>proguard</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <proguardVersion>4.8</proguardVersion>
                <obfuscate>true</obfuscate>

                <options>
                    <option>-ignorewarnings</option>
                    <option>-dontshrink</option>
                    <option>-dontoptimize</option>
                    <option>-allowaccessmodification</option>
                    <option>-keep class !ua.com.sintez.exceptions.** { *; }</option>
                </options>
                <injar>${project.build.finalName}.jar</injar>
                <outjar>${project.build.finalName}-proguard.jar</outjar>
                <outputDirectory>${project.build.directory}</outputDirectory>
                <libs>
                    <lib>${java.home}/lib/rt.jar</lib>
                    <lib>${java.home}/lib/jsse.jar</lib>
                </libs>
                <addMavenDescriptor>false</addMavenDescriptor>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>net.sf.proguard</groupId>
                    <artifactId>proguard</artifactId>
                    <version>4.8</version>
                    <scope>runtime</scope>
                </dependency>
            </dependencies>
        </plugin>

我试图只混淆一个包“ua.com.mycompany.exceptions”以查看它是否有效。 该软件包不包含任何与JPA有关的内容。 persistence.xml就位,所有实体都在那里。但是当我启动程序时,我收到以下错误:

        The collection of metamodel types is empty. Model classes may not have been found during entity search for Java SE and some Java EE container managed persistence units.<br/> 
java.lang.IllegalArgumentException: Unknown entity bean class: class ua.com.mycompany.entity.Currency, please verify that this class has been marked with the @Entity annotation.<br/> 
java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: Exception Description: Problem compiling [select count(p) from Product as p]. 
The abstract schema type 'Product' is unknown.

所以我有以下问题:

  1. 该错误可能是什么原因?
  2. proguard配置错了吗?
  3. 我也得到了大量的这个:Note: duplicate definition of library class ...和许多像这样的警告:Warning:net.sf.jasperreports.compilers.JavaScriptEvaluator: can't find referenced class org.mozilla.javascript.Context
    是否可以,如果是,我该如何压制它?

0 个答案:

没有答案