Skip to content

Commit 1cbb171

Browse files
committed
updated Maven examples for new yGuard Maven Plugin
1 parent d7ca1dd commit 1cbb171

10 files changed

Lines changed: 407 additions & 390 deletions

File tree

docs/setup.md

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Depending on your build system, you will use [`AntRun`](http://maven.apache.org/
66
Download the bundle from the [Github release page](https://github.com/yWorks/yguard/releases/latest). After downloading and extracting the `jar` files, place them in a path near to your build script. You may use absolute paths, but our examples expect the jar file to lie in the same directory as your build file. Once extracted, you can use the `yguard` element like so:
77

88
```xml
9-
<property name="version" value="4.1.1"/>
9+
<property name="version" value="5.0.0"/>
1010

1111
<target name="yguard">
1212
<taskdef name="yguard" classname="com.yworks.yguard.YGuardTask" classpath="${projectDir}/yguard-${version}.jar"/>
@@ -17,41 +17,35 @@ Download the bundle from the [Github release page](https://github.com/yWorks/ygu
1717
```
1818

1919
### Setup using `Maven`
20-
You can use `yGuard` directly from `Maven` central. Add the `yGuard` dependency to your `POM`:
20+
Use the [yGuard Maven Plugin](https://github.com/yWorks/yguard-maven-plugin) to run `yGuard` from `Maven`:
2121

2222
```xml
23-
<dependency>
24-
<groupId>com.yworks</groupId>
25-
<artifactId>yguard</artifactId>
26-
<version>4.1.1</version>
27-
<scope>compile</scope>
28-
</dependency>
29-
```
30-
31-
Once declared, you can use the `antrun` plugin to define the `yGuard` task like so:
32-
```xml
33-
<plugin>
34-
<artifactId>maven-antrun-plugin</artifactId>
35-
<version>1.8</version>
36-
<executions>
23+
<build>
24+
[...]
25+
<plugins>
26+
[...]
27+
<plugin>
28+
<groupId>com.yworks.maven.plugins</groupId>
29+
<artifactId>yguard-maven-plugin</artifactId>
30+
<version>1.0.0</version>
31+
<executions>
3732
<execution>
38-
<phase>package</phase>
39-
<goals>
40-
<goal>run</goal>
41-
</goals>
42-
<id>obfuscate</id>
43-
<configuration>
44-
<tasks>
45-
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
46-
<taskdef name="yguard" classname="com.yworks.yguard.YGuardTask" classpath="${runtime_classpath}"/>
47-
<yguard>
48-
<!-- see the yGuard task documentation for information about the <yguard> element-->
49-
</yguard>
50-
</tasks>
51-
</configuration>
33+
<goals>
34+
<goal>run</goal>
35+
</goals>
5236
</execution>
53-
</executions>
54-
</plugin>
37+
</executions>
38+
<configuration>
39+
<yguardVersion>5.0.0</yguardVersion>
40+
<yguard>
41+
<!-- see the yGuard task documentation for information about the <yguard> element -->
42+
</yguard>
43+
</configuration>
44+
</plugin>
45+
[...]
46+
</plugins>
47+
[...]
48+
</build>
5549
```
5650

5751
### Setup using `Gradle`
@@ -64,7 +58,7 @@ repositories {
6458
}
6559
6660
dependencies {
67-
compileOnly 'com.yworks:yguard:4.1.1'
61+
compileOnly 'com.yworks:yguard:5.0.0'
6862
}
6963
7064
task yguard {

examples/annotation/pom.xml

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,77 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
1+
<project
2+
xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
35
<modelVersion>4.0.0</modelVersion>
6+
47
<groupId>com.yworks.example</groupId>
58
<artifactId>annotation</artifactId>
69
<packaging>jar</packaging>
710
<version>1.0-SNAPSHOT</version>
811
<name>annotation</name>
912
<url>http://maven.apache.org</url>
13+
1014
<properties>
1115
<maven.compiler.source>1.7</maven.compiler.source>
1216
<maven.compiler.target>1.7</maven.compiler.target>
1317
<mainclass>com.yworks.example.HelloWorld</mainclass>
1418
</properties>
19+
1520
<dependencies>
16-
<dependency>
17-
<groupId>com.yworks</groupId>
18-
<artifactId>yguard</artifactId>
19-
<version>5.0.0</version>
20-
<scope>compile</scope>
21-
</dependency>
2221
<dependency>
2322
<groupId>com.yworks</groupId>
2423
<artifactId>annotation</artifactId>
2524
<version>5.0.0</version>
2625
</dependency>
2726
</dependencies>
27+
2828
<build>
2929
<plugins>
3030
<plugin>
3131
<artifactId>maven-antrun-plugin</artifactId>
32-
<version>1.8</version>
32+
<version>3.2.0</version>
3333
<executions>
3434
<execution>
35+
<id>prepare-obfuscation</id>
3536
<phase>package</phase>
36-
<goals>
37-
<goal>run</goal>
38-
</goals>
39-
<id>obfuscate</id>
4037
<configuration>
41-
<tasks>
42-
<property
43-
name="project.jar"
44-
value="${project.build.directory}/${project.build.finalName}.jar"/>
45-
<property
46-
name="project.jar.unobf"
47-
value="${project.build.directory}/${project.build.finalName}_unobf.jar"/>
38+
<target name="prepare-obfuscation">
4839
<move
49-
file="${project.jar}"
50-
tofile="${project.jar.unobf}"
40+
file="${project.build.directory}/${project.build.finalName}.jar"
41+
tofile="${project.build.directory}/${project.build.finalName}_unobf.jar"
5142
verbose="true"/>
52-
53-
<property
54-
name="runtime_classpath"
55-
refid="maven.runtime.classpath"/>
56-
<taskdef
57-
name="yguard"
58-
classname="com.yworks.yguard.YGuardTask"
59-
classpath="${runtime_classpath}"/>
60-
<yguard>
61-
<inoutpair in="${project.jar.unobf}" out="${project.jar}" />
62-
63-
<rename logfile="${project.build.directory}/${project.build.finalName}_renamelog.xml"/>
64-
</yguard>
65-
</tasks>
43+
</target>
6644
</configuration>
45+
<goals>
46+
<goal>run</goal>
47+
</goals>
6748
</execution>
6849
</executions>
6950
</plugin>
51+
<plugin>
52+
<groupId>com.yworks.maven.plugins</groupId>
53+
<artifactId>yguard-maven-plugin</artifactId>
54+
<version>1.0.0</version>
55+
<executions>
56+
<execution>
57+
<goals>
58+
<goal>run</goal>
59+
</goals>
60+
</execution>
61+
</executions>
62+
<configuration>
63+
<yguardVersion>5.0.0</yguardVersion>
64+
<yguard>
65+
<inoutpair
66+
in="${project.build.directory}/${project.build.finalName}_unobf.jar"
67+
out="${project.build.directory}/${project.build.finalName}.jar"/>
68+
69+
<rename logfile="${project.build.directory}/${project.build.finalName}_renamelog.xml">
70+
<property name="digests" value="none"/>
71+
</rename>
72+
</yguard>
73+
</configuration>
74+
</plugin>
7075
</plugins>
7176
</build>
7277
</project>

examples/application/pom.xml

Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,80 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4+
45
<groupId>com.yworks.example</groupId>
56
<artifactId>application</artifactId>
67
<packaging>jar</packaging>
78
<version>1.0-SNAPSHOT</version>
89
<name>application</name>
910
<url>http://maven.apache.org</url>
11+
1012
<properties>
1113
<maven.compiler.source>1.7</maven.compiler.source>
1214
<maven.compiler.target>1.7</maven.compiler.target>
1315
<mainclass>com.yworks.example.HelloWorld</mainclass>
1416
</properties>
15-
<dependencies>
16-
<dependency>
17-
<groupId>com.yworks</groupId>
18-
<artifactId>yguard</artifactId>
19-
<version>5.0.0</version>
20-
<scope>compile</scope>
21-
</dependency>
22-
</dependencies>
17+
2318
<build>
2419
<plugins>
20+
<plugin>
21+
<groupId>org.apache.maven.plugins</groupId>
22+
<artifactId>maven-jar-plugin</artifactId>
23+
<version>2.4</version>
24+
<configuration>
25+
<archive>
26+
<manifest>
27+
<mainClass>${mainclass}</mainClass>
28+
</manifest>
29+
</archive>
30+
</configuration>
31+
</plugin>
2532
<plugin>
2633
<artifactId>maven-antrun-plugin</artifactId>
27-
<version>1.8</version>
34+
<version>3.2.0</version>
2835
<executions>
2936
<execution>
37+
<id>prepare-obfuscation</id>
3038
<phase>package</phase>
31-
<goals>
32-
<goal>run</goal>
33-
</goals>
34-
<id>obfuscate</id>
3539
<configuration>
36-
<tasks>
37-
<property
38-
name="project.jar"
39-
value="${project.build.directory}/${project.build.finalName}.jar"/>
40-
<property
41-
name="project.jar.unobf"
42-
value="${project.build.directory}/${project.build.finalName}_unobf.jar"/>
40+
<target name="prepare-obfuscation">
4341
<move
44-
file="${project.jar}"
45-
tofile="${project.jar.unobf}"
42+
file="${project.build.directory}/${project.build.finalName}.jar"
43+
tofile="${project.build.directory}/${project.build.finalName}_unobf.jar"
4644
verbose="true"/>
47-
48-
<property
49-
name="runtime_classpath"
50-
refid="maven.runtime.classpath"/>
51-
<taskdef
52-
name="yguard"
53-
classname="com.yworks.yguard.YGuardTask"
54-
classpath="${runtime_classpath}"/>
55-
<yguard>
56-
<inoutpair in="${project.jar.unobf}" out="${project.jar}" />
57-
58-
<rename logfile="${project.build.directory}/${project.build.finalName}_renamelog.xml">
59-
<keep>
60-
<method name="void main(java.lang.String[])" class="${mainclass}"/>
61-
</keep>
62-
</rename>
63-
</yguard>
64-
</tasks>
45+
</target>
6546
</configuration>
47+
<goals>
48+
<goal>run</goal>
49+
</goals>
6650
</execution>
6751
</executions>
6852
</plugin>
6953
<plugin>
70-
<groupId>org.apache.maven.plugins</groupId>
71-
<artifactId>maven-jar-plugin</artifactId>
72-
<version>2.4</version>
54+
<groupId>com.yworks.maven.plugins</groupId>
55+
<artifactId>yguard-maven-plugin</artifactId>
56+
<version>1.0.0</version>
57+
<executions>
58+
<execution>
59+
<goals>
60+
<goal>run</goal>
61+
</goals>
62+
</execution>
63+
</executions>
7364
<configuration>
74-
<archive>
75-
<manifest>
76-
<mainClass>${mainclass}</mainClass>
77-
</manifest>
78-
</archive>
65+
<yguardVersion>5.0.0</yguardVersion>
66+
<yguard>
67+
<inoutpair
68+
in="${project.build.directory}/${project.build.finalName}_unobf.jar"
69+
out="${project.build.directory}/${project.build.finalName}.jar"/>
70+
71+
<rename logfile="${project.build.directory}/${project.build.finalName}_renamelog.xml">
72+
<property name="digests" value="none"/>
73+
<keep>
74+
<method name="void main(java.lang.String[])" class="${mainclass}"/>
75+
</keep>
76+
</rename>
77+
</yguard>
7978
</configuration>
8079
</plugin>
8180
</plugins>

0 commit comments

Comments
 (0)