Skip to content

Instantly share code, notes, and snippets.

@mikroskeem
Created September 24, 2016 11:46
Show Gist options
  • Save mikroskeem/8a6ecaa21742ee18686fc07563b6459a to your computer and use it in GitHub Desktop.
Save mikroskeem/8a6ecaa21742ee18686fc07563b6459a to your computer and use it in GitHub Desktop.
Obfuscate with yGuard in Maven
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<property refid="maven.compile.classpath" name="mvn.classpath"></property>
<taskdef name="yguard" classname="com.yworks.yguard.YGuardTask"
classpath="lib/yguard.jar"/>
<yguard>
<inoutpair in="${project.build.directory}/${project.build.finalName}.jar"
out="${project.build.directory}/${project.build.finalName}.jar" />
<rename logfile="${project.build.directory}/yguard.log.xml"
replaceClassNameStrings="true">
<property name="obfuscation-prefix" value="new.target.package"/>
<keep>
<class classes="private" methods="private" fields="private">
<patternset>
<include name="class.to.keep"/>
</patternset>
</class>
</keep>
</rename>
<externalclasses>
<pathelement path="${mvn.classpath}" />
</externalclasses>
</yguard>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment