yGuard in Maven


<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <dependencies>
    <dependency>
      <groupId>yguard</groupId>
      <artifactId>yguard</artifactId>
      <version>2.1.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="Main"/>
                  </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>

你可能感兴趣的:(yGuard in Maven)