Java obfuscate

there are lots tools about the java obfuscate. I know two.

(1)proguard

(2)yguard

the proguard support ant, maven. I use maven as the project and build tools. so I want use the maven proguard plugin, but It is not easy to use. so I use yguard.

in your pom.xml, you can  add:

    <plugin>
            <groupId>net.sf.mgp</groupId>
            <artifactId>maven-unclasses-plugin</artifactId>
            <version>0.0.2</version>
        </plugin>
        <plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <dependencies>
    <dependency>
      <groupId>yguard</groupId>
      <artifactId>yguard</artifactId>
      <version>2.3.0</version>
      <scope>system</scope>
      <systemPath>lib/yguard.jar</systemPath>
    </dependency>
  </dependencies>
  <executions>
    <execution>
      <phase>package</phase>
      <configuration>
        <tasks>
          <property refid="maven.compile.classpath"
            name="mvn.classpath"></property>
          <!-- <echo message="Using Maven Classpath: ${mvn.classpath}" /> -->
          <taskdef name="yguard"
            classname="com.yworks.yguard.YGuardTask"/>
          <yguard>
            <!-- Input file and output file is the same. -->
            <inoutpair
              in="${project.build.directory}/${project.build.finalName}.${project.packaging}"
              out="${project.build.directory}/${project.build.finalName}.jar"/>
            <!-- Obfuscate classes plus string references. -->
            <rename
              logfile="${project.build.directory}/yguard.log.xml"
              replaceClassNameStrings="true">
              <!-- Keep the only class to be used for easy running and its public method main(). -->
              <keep>
                  <class classes="public" methods="public">
                  <patternset>
                    <include name=”xx.xxx.xxx.util.ConnectionUtil"/>
                  </patternset>
                </class>
              </keep>
            </rename>
            <!-- There are some external libraries used - Maven knows details. -->
            <externalclasses>
              <pathelement path="${mvn.classpath}"/>
            </externalclasses>
          </yguard>
        </tasks>
      </configuration>
      <goals>
        <goal>run</goal>
      </goals>
    </execution>
  </executions>
</plugin>


It is very cool!!!.

你可能感兴趣的:(Java obfuscate)