Class diagram generator

The artifact plantuml-generator-util contains a Utility class with the name PlantUMLClassDiagramGenerator which can be used to generate a PlantUML class 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 (can be filtered with a blacklist regular expression),

    • a whitelist regular expression to filter classes in the classpath of the given classloader

  • add additional configuration to the PlantUMLClassDiagramConfig object via the PlantUMLClassDiagramConfigBuilder to customize the diagram

After you created the generator object with a PlantUMLClassDiagramConfig object simply call the method generateDiagramText and you’ll get the PlantUML class diagram as text.

For more options to customize the diagram text and corresponding examples have a look at the configuration documentation.

Since Version 2.4.1 the util is able to use the original method parameter names if the classes are compiled with parameter information enabled (https://openjdk.org/jeps/118):

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven-compiler-plugin.version}</version>
            <configuration>
                <!-- plugin version < 3.6.2 -->
                <compilerArgument>-parameters</compilerArgument>
                <!-- Or, if you use the plugin version >= 3.6.2 -->
                <parameters>true</parameters>
                <testCompilerArgument>-parameters</testCompilerArgument>
                <source>${java.version}</source>
                <target>${java.version}</target>
            </configuration>
        </plugin>
    </plugins>
</build>