Skip to content

Commit 9d7dea7

Browse files
committed
Added Plant UML JAR to generate SVG output
1 parent a23b98a commit 9d7dea7

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

pom.xml

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
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/xsd/maven-4.0.0.xsd">
23
<modelVersion>4.0.0</modelVersion>
34

45
<groupId>io.github.kicksolutions</groupId>
@@ -72,6 +73,7 @@
7273
<version.swagger-parser>1.0.33</version.swagger-parser>
7374
<version.mustache>0.8.18</version.mustache>
7475
<version.junit>3.8.1</version.junit>
76+
<version.net.sourceforge.plantuml>7999</version.net.sourceforge.plantuml>
7577
</properties>
7678

7779
<dependencyManagement>
@@ -92,23 +94,27 @@
9294
<artifactId>compiler</artifactId>
9395
<version>${version.mustache}</version>
9496
</dependency>
97+
<dependency>
98+
<groupId>net.sourceforge.plantuml</groupId>
99+
<artifactId>plantuml</artifactId>
100+
<version>${version.net.sourceforge.plantuml}</version>
101+
</dependency>
95102
</dependencies>
96103
</dependencyManagement>
97104

98105
<modules>
99106
<module>swagger2puml-core</module>
100107
</modules>
101-
108+
102109
<build>
103110
<sourceDirectory>src/main/java</sourceDirectory>
104111
<plugins>
105112
<plugin>
106113
<groupId>org.apache.maven.plugins</groupId>
107114
<artifactId>maven-compiler-plugin</artifactId>
108-
<version>3.1</version>
109115
<configuration>
110-
<source>1.7</source>
111-
<target>1.7</target>
116+
<source>${maven.compiler.source}</source>
117+
<target>${maven.compiler.target}</target>
112118
</configuration>
113119
</plugin>
114120
<plugin>
@@ -125,7 +131,7 @@
125131
</plugin>
126132
</plugins>
127133
</build>
128-
134+
129135
<profiles>
130136
<!-- Activate using the release property: mvn clean install -Prelease -->
131137
<profile>

swagger2puml-core/pom.xml

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
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/xsd/maven-4.0.0.xsd">
23
<modelVersion>4.0.0</modelVersion>
34

45
<parent>
@@ -11,10 +12,10 @@
1112
<artifactId>swagger-plantuml-core</artifactId>
1213
<version>0.0.1-SNAPSHOT</version>
1314
<description>Core POM to generate Plant UML from Swagger</description>
14-
15+
1516
<packaging>jar</packaging>
1617
<name>swagger2plantuml-core</name>
17-
18+
1819
<dependencies>
1920
<dependency>
2021
<groupId>junit</groupId>
@@ -29,5 +30,9 @@
2930
<groupId>com.github.spullara.mustache.java</groupId>
3031
<artifactId>compiler</artifactId>
3132
</dependency>
33+
<dependency>
34+
<groupId>net.sourceforge.plantuml</groupId>
35+
<artifactId>plantuml</artifactId>
36+
</dependency>
3237
</dependencies>
3338
</project>

swagger2puml-core/src/main/java/com/kicksolutions/swagger/plantuml/Swagger2PlantUML.java

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.kicksolutions.swagger.plantuml;
22

33
import java.io.File;
4+
import java.io.IOException;
45
import java.util.logging.Level;
56
import java.util.logging.Logger;
67

@@ -81,16 +82,28 @@ private void transformSwagger2Puml(String specFile,String output,boolean generat
8182
LOGGER.info("Processing File --> "+ specFile);
8283
pumlPath = codegen.generatePuml();
8384
LOGGER.info("Sucessfully Create PUML !!!");
85+
86+
generateUMLDiagram(pumlPath, targetLocation);
8487
}
8588
catch(Exception e){
8689
LOGGER.log(Level.SEVERE, e.getMessage(),e);
87-
System.exit(1);
90+
throw new RuntimeException(e);
8891
}
89-
}
90-
else{
92+
}else{
9193
LOGGER.severe(USAGE);
9294
}
9395

9496
LOGGER.exiting(LOGGER.getName(), "transformSwagger2Puml");
9597
}
98+
99+
/**
100+
*
101+
* @param pumlLocation
102+
* @param targetLocation
103+
* @throws IOException
104+
* @throws InterruptedException
105+
*/
106+
private void generateUMLDiagram(String pumlLocation,File targetLocation) throws IOException, InterruptedException{
107+
net.sourceforge.plantuml.Run.main(new String[]{"-tsvg","-o",targetLocation.getAbsolutePath(),"-I",pumlLocation});
108+
}
96109
}

0 commit comments

Comments
 (0)