Proguard configuration on a Enterprise Java Applic

2019-08-05 04:27发布

问题:

I'm trying to use proguard in a Maven project this is a obfuscate plugin, when I run it I have an error:

Failed to execute goal com.pyx4me:proguard-maven-plugin:2.0.4:proguard (default) on project MavenEnterpriseApp-ear: Obfuscation failed (result=1) -> [Help 1]

when I run maven with -e or -X I have:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.pyx4me:proguard-maven-plugin:2.0.4:proguard (default) on project MavenEnterpriseApp-ear: 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.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)

My plugin configuration is:

<plugin>
    <groupId>com.pyx4me</groupId>
    <artifactId>proguard-maven-plugin</artifactId>
    <version>2.0.4</version>
    <executions>
        <execution>
            <phase>prepare-package</phase>
            <goals>
                <goal>proguard</goal>
            </goals>
        </execution>
    </executions>               
    <configuration>
        <obfuscate>true</obfuscate>
        <includeDependency>false</includeDependency> 
        <injar>${project.artifactId}-v${project.version}.ear</injar>
        <outjar>${project.artifactId}-v${project.version}-obf.ear</outjar> 
        <outputDirectory>${project.build.directory}</outputDirectory> 
        <maxMemory>256m</maxMemory>

    </configuration>
   </plugin>

As you can see I'm trying to ofuscate the ear. In the official page:

injar: Specifies the input jar name (or wars, ears, zips) of the application to be processed. You may specify a classes directory e.g. 'classes'. This way plugin will processed the classes instead of jar. You would need to bind the execution to phase 'compile' or 'process-classes' in this case.

The project is an a Maven Enterise Application project, basically I have 2 sub project one with JPA and EJB3 resources and the other is an a web project with jsf the structure is. When I run Maven I obtain an ear, in this I have 2 binaries a jar and a war. I have three questions:

First) In what pom I suppose to insert it? now I'm using the pom into the EAR project as you can see:

Second)I can obfuscatean an ear?

Third) If the second is false: how can I obfuscate specificlly the ears? I'm trying to specify the jars but I recive the same error ever:

Failed to execute goal com.pyx4me:proguard-maven-plugin:2.0.4:proguard (default) on project MavenEnterpriseApp-ear: Obfuscation failed (result=1) -> [Help 1]

回答1:

Try to change phase of proguard from "prepare-package" into "process-classes", change injar option into "classes", and let me know if it does not work.

HTH.