Skip to content

Commit ad22c94

Browse files
committed
turning into mvn plugin
1 parent 89bb1ee commit ad22c94

File tree

4 files changed

+80
-4
lines changed

4 files changed

+80
-4
lines changed

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
11
# Java2PlantUML
2+
3+
4+
```xml
5+
<project>
6+
...
7+
<build>
8+
...
9+
<plugins>
10+
...
11+
<plugin>
12+
<artifactId>java2PlantUML-maven-plugin</artifactId>
13+
<version>1.0-SNAPSHOT</version>
14+
<configuration>
15+
<goalPrefix>java2PlantUML</goalPrefix>
16+
</configuration>
17+
</plugin>
18+
</plugins>
19+
</build>
20+
</project>
21+
```

pom.xml

+16-1
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,30 @@
55
<modelVersion>4.0.0</modelVersion>
66

77
<groupId>com.github.juanmf</groupId>
8-
<artifactId>Java2PlantUML</artifactId>
8+
<artifactId>java2PlantUML-maven-plugin</artifactId>
99
<version>1.0-SNAPSHOT</version>
10+
<packaging>maven-plugin</packaging>
1011

1112
<dependencies>
1213
<dependency>
1314
<groupId>org.reflections</groupId>
1415
<artifactId>reflections</artifactId>
1516
<version>0.9.10</version>
1617
</dependency>
18+
19+
<dependency>
20+
<groupId>org.apache.maven</groupId>
21+
<artifactId>maven-plugin-api</artifactId>
22+
<version>3.0</version>
23+
</dependency>
24+
25+
<!-- dependencies to annotations -->
26+
<dependency>
27+
<groupId>org.apache.maven.plugin-tools</groupId>
28+
<artifactId>maven-plugin-annotations</artifactId>
29+
<version>3.4</version>
30+
<scope>provided</scope>
31+
</dependency>
1732
</dependencies>
1833

1934
</project>

src/main/java/com/github/juanmf/java2plant/Parser.java

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.github.juanmf.java2plant;
22

33
import com.github.juanmf.java2plant.render.Filter;
4-
import com.github.juanmf.java2plant.render.Filters;
54
import com.github.juanmf.java2plant.render.PlantRenderer;
65
import com.github.juanmf.java2plant.structure.Aggregation;
76
import com.github.juanmf.java2plant.structure.Extension;
@@ -14,8 +13,19 @@
1413
import org.reflections.util.ConfigurationBuilder;
1514
import org.reflections.util.FilterBuilder;
1615

17-
import java.lang.reflect.*;
18-
import java.util.*;
16+
import java.lang.reflect.Constructor;
17+
import java.lang.reflect.Field;
18+
import java.lang.reflect.Method;
19+
import java.lang.reflect.Modifier;
20+
import java.lang.reflect.ParameterizedType;
21+
import java.lang.reflect.Type;
22+
import java.util.Collection;
23+
import java.util.Collections;
24+
import java.util.HashSet;
25+
import java.util.LinkedList;
26+
import java.util.List;
27+
import java.util.Map;
28+
import java.util.Set;
1929

2030
/**
2131
* Iterates over all types available at runtime, under given package, creating:
@@ -28,6 +38,7 @@
2838
*
2939
3040
*/
41+
3142
public class Parser {
3243

3344
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.github.juanmf.java2plant.goals;
2+
3+
import com.github.juanmf.java2plant.Parser;
4+
import com.github.juanmf.java2plant.render.Filters;
5+
import org.apache.maven.plugin.AbstractMojo;
6+
import org.apache.maven.plugin.MojoExecutionException;
7+
import org.apache.maven.plugin.MojoFailureException;
8+
import org.apache.maven.plugins.annotations.Mojo;
9+
import org.apache.maven.plugins.annotations.Parameter;
10+
11+
/**
12+
13+
*/
14+
@Mojo(name = "parse")
15+
public class Parse extends AbstractMojo {
16+
17+
/**
18+
* The package to parse for Types and Associations
19+
*/
20+
@Parameter(property = "parse.thePackage", defaultValue = "com.github.juanmf.java2plant.structure")
21+
private String thePackage;
22+
23+
public void execute() throws MojoExecutionException, MojoFailureException {
24+
try {
25+
System.out.println(Parser.parse(thePackage, Filters.FILTER_ALLOW_ALL));
26+
} catch (ClassNotFoundException e) {
27+
throw new MojoExecutionException("Something went wrong", e);
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)