1

我有如下插件配置:

<project>
    ...
    <build>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration> 
                        <outputDirectory>${project.build.directory}/libs</outputDirectory>
                        <overWriteReleases>true</overWriteReleases>
                        <overWriteSnapshots>true</overWriteSnapshots>
                        <overWriteIfNewer>true</overWriteIfNewer>
                    </configuration>
                </execution>
            </executions> 
        </plugin>
        <plugin>
            <groupId>com.pyx4me</groupId>
            <artifactId>proguard-maven-plugin</artifactId>
            <version>2.1.0-SNAPSHOT</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>proguard</goal>
                    </goals>
                </execution>
            </executions>   
            <configuration>
                <proguardVersion>4.8</proguardVersion>
                <obfuscate>true</obfuscate>
                <includeDependency>true</includeDependency> 
                <injar>${project.artifactId}-${project.version}.jar</injar>
                <outjar>${project.artifactId}-${project.version}-obf.jar</outjar> 
                <outputDirectory>${project.build.directory}</outputDirectory> 
                <maxMemory>256m</maxMemory>             
                <options>
                    <option>-keepclasseswithmembers class **, !some.specific.package.** { *; }</option>
                    <option>-keep public class some.specific.package.Main { public *; public static *; }</option>
                    <option>-allowaccessmodification</option>
                    <option>-dontskipnonpubliclibraryclasses</option>
                    <option>-dontskipnonpubliclibraryclassmembers</option>
                    <option>-dontwarn org.apache.log4j.**</option>
                </options>
                <libs>
                    <lib>${java.home}/lib/rt.jar</lib>
                    <lib>${java.home}/lib/javaws.jar</lib>
                    <lib>${javafx_home}/lib/jfxrt.jar</lib>
                </libs>    
            </configuration>

            <dependencies>
                <dependency>
                    <groupId>net.sf.proguard</groupId>
                    <artifactId>proguard-base</artifactId>
                    <version>4.8</version>
                </dependency>
            </dependencies>
        </plugin>
    </build>
...
</project>

我想混淆some.specific.packagejar 的特定包及其依赖项(在复制之前)。有可能做到吗?

4

1 回答 1

4

您是否尝试过带有否定(!)的命令-keeppackagenames要混淆的包?我尝试了以下操作,结果只是包org.neo4j.cineasts.domain被混淆了。见下文:

<configuration>
                <proguardVersion>4.8</proguardVersion>
                <obfuscate>true</obfuscate>
                <includeDependency>true</includeDependency>
                <injar>${project.artifactId}-${project.version}.jar</injar>
                <outjar>${project.artifactId}-${project.version}-obf.jar</outjar>
                <outputDirectory>${project.build.directory}</outputDirectory>
                <maxMemory>256m</maxMemory>
                <options>
                    <option>-keep public class org.neo4j.cineasts.controller.** { public *; public static *; }</option> 
                    <option>-keeppackagenames !org.neo4j.cineasts.domain</option>
                    <option>-allowaccessmodification</option>
                    <option>-dontskipnonpubliclibraryclasses</option>
                    <option>-dontskipnonpubliclibraryclassmembers</option>
                </options>
                <libs>
                    <lib>C:/devtools/Java/jdk1.6.0_29_64/jre/lib/rt.jar</lib>
                    <lib>C:/devtools/Java/jdk1.6.0_29_64/jre/lib/javaws.jar</lib>
                </libs>
            </configuration>

最好的,迈克尔

于 2012-12-14T16:22:54.557 回答