当前位置: 首页 > 工具软件 > yGuard > 使用案例 >

yGuard in Maven

卫开济
2023-12-01


<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>
 类似资料:

相关阅读

相关文章

相关问答