plantuml-generator is a project which consists of a utility module which can be used to generate PlantUML class diagrams from existing java classes and its maven plugin frontend.
With the help of this project you can generate class diagrams for your project documentation on the fly during each maven build or via the utility module.
The artifact plantuml-generator-util contains a Utility class with the name PlantUMLClassDiagramGenerator which can be used to generate a PlantUML diagram text out of existing java classes. All you have to do is to provide a list of package names which should be scanned for java classes, a classloader which is able to find and read these packages and some toggles to hide information in the resulting Plant UML class diagram. After you created the generator object simply call the method generateDiagramText and you’ll get the Plant UML class diagram as text.
List<String> scanpackages = new ArrayList<>();
scanpackages.add("de.elnarion.test.domain.t0005");
List<String> hideClasses = new ArrayList<>();
PlantUMLClassDiagramGenerator generator =
new PlantUMLClassDiagramGenerator(this.getClass().getClassLoader(),
scanpackages, hideClasses, false, false);
String result = generator.generateDiagramText();
You can use this String as input for the PlantUML tools or as part of your "living" documentation (for example with asciidoc)
To use this utility library you need to add the plantuml-generator-util.jar to your classpath.
If you use maven as build tool this is easy, just add the following dependency:
<dependency>
<groupId>de.elnarion.util</groupId>
<artifactId>plantuml-generator-util</artifactId>
<version>0.9.1</version>
</dependency>
to your pom.xml
If you want to use the plantuml-generator-maven-plugin for class diagram generation, you need to configure this plugin as any normal maven plugin as part of your build and add this plugin specific configuration:
-
outputDirectory - the target folder where the diagram file is written; defaults to target/generated-docs
-
outputFilename - the file name of the diagram generated by this plugin; required
-
hideFields - simple toggle to hide field information in the Plant UML diagram; optional
-
hideMethods - simple toggle to hide method information in the Plant UML diagram; optional
-
scanPackages - a string list of all packages which should be used to generate the class diagram; required
-
hideClasses - a string list of all classes which should be hidden in the resultign class diagram; optional
<plugin>
<artifactId>plantuml-generator-maven-plugin</artifactId>
<groupId>de.elnarion.maven</groupId>
<version>0.9.1</version>
<executions>
<execution>
<id>generate-simple-diagram</id>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-test-sources</phase>
<configuration>
<outputFilename>testdiagram1.txt</outputFilename>
<scanPackages>
<scanPackage>
some.package.to.process
</scanPackage>
</scanPackages>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>plantuml-generator-maven-plugin</artifactId>
<groupId>de.elnarion.maven</groupId>
<version>0.9.1</version>
<executions>
<execution>
<id>generate-simple-diagram</id>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-test-sources</phase>
<configuration>
<outputDirectory>/tmp</outputDirectory>
<outputFilename>testdiagram1.txt</outputFilename>
<scanPackages>
<scanPackage>
some.package.to.process
</scanPackage>
<scanPackage>
second.package.to.process
</scanPackage>
</scanPackages>
<hideFields>true</hideFields>
<hideMethods>true</hideMethods>
<hideClasses>
<hideClass>
some.package.to.process.TestClass
</hideClass>
<hideClass>
second.package.to.process.TestClass2
</hideClass>
</hideClasses>
</configuration>
</execution>
</executions>
</plugin>
This software is licensed under the Apache Licence, Version 2.0. Note that plantuml-generator has several dependencies which are not licensed under the Apache License. Note that using plant-uml-generator comes without any (legal) warranties.
This project uses sematic versioning. For more information refer to semver.
This plugin has a dedicated Changelog.
Latest and greatest source of plantuml-generator can be found on GitHub. Fork it!