Please refer to https://plugins.gradle.org/plugin/com.github.roroche.plantuml
Using the plugins DSL:
plugins {
id "com.github.roroche.plantuml" version "{latest_version}" // (1)
}
-
The plugin ID with the latest version.
Using legacy plugin application:
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/" // (1)
}
}
dependencies {
classpath "com.github.roroche:plantuml-gradle-plugin:{latest_version}" // (2)
}
}
apply plugin: "com.github.roroche.plantuml" // (3)
-
Declare the repository where to look for the plugin.
-
Declare the dependency to the plugin.
-
Apply the plugin.
Maybe you would have to configure the plugin management with repositories where to look for plugins:
pluginManagement {
repositories {
gradlePluginPortal() // (1)
}
}
-
Include the official Gradle plugin portal.
classDiagram { // (1)
packageName = "com.github.roroche" // (2)
outputFile = project.file('diagrams/class_diagram.plantuml') // (3)
// outputFile = new File("${projectDir}/diagrams/class_diagram.plantuml") // (4)
ignoredClasses = [ // (5)
"com.github.roroche.plantuml.diagrams.Diagram\$Simple",
"com.github.roroche.plantuml.diagrams.Diagram\$Wrap",
"com.github.roroche.plantuml.classes.Classes\$Simple",
"com.github.roroche.plantuml.classes.Classes\$Wrap"
]
}
-
The name of the extension.
-
The name of the package to scan.
-
The file where to print the class diagram.
-
Equivalent declaration to use explicit variable
${projectDir}
. -
The classes to be ignored while building the class diagram (an array of strings).
Here is the output of the plugin applied to itself (cf. previous Configuration).
link:diagrams/class_diagram.plantuml[role=include]
@startuml class "BuildClassDiagramTask" { extension : ClassDiagramExtension metaClass : MetaClass execute() getProperty(String) : Object invokeMethod(String, Object) : Object } class "ClassDiagram" class "ClassDiagramExtension" { packageName : String outputFile : File ignoredClasses : List<String> metaClass : MetaClass getProperty(String) : Object invokeMethod(String, Object) : Object setProperty(String, Object) } interface "Classes" { list() : List<Class<?>> } class "ClsFiltered" { ignored : Classes list() : List<Class<?>> } class "ClsInPackage" { packageName : String packageUrls : Collection<URL> reflections : Reflections list() : List<Class<?>> } class "ClsWithLog" { logger : Logger list() : List<Class<?>> } class "ClsWithNames" { names : List<String> list() : List<Class<?>> } interface "CustomTask" { execute() } interface "Diagram" { content() : String print(File) } class "DiagramWithLog" { logger : Logger print(File) } class "PlantUmlPlugin" { metaClass : MetaClass apply(Project) apply(Object) getProperty(String) : Object invokeMethod(String, Object) : Object setProperty(String, Object) } "BuildClassDiagramTask" --> "ClassDiagramExtension" : extension "Classes" <-> "ClsFiltered" : /ignored "Classes" <|-- "ClsInPackage" "Classes" <|-- "ClsWithLog" "Classes" <|-- "ClsWithNames" "CustomTask" <|-- "BuildClassDiagramTask" "Diagram" <|-- "ClassDiagram" "Diagram" <|-- "DiagramWithLog" @enduml
It’s possible to associate this plugin with this pretty good one: https://framagit.org/avaiss/plantuml-gradle-plugin
Here is the example of the configuration applied for this project:
plugins { id "org.fmiw.plantuml" version "0.1" // (1) } plantuml { options { outputDir = project.file('diagrams') // (2) } diagrams { classes { sourceFile = project.file('diagrams/class_diagram.plantuml') // (3) } } } generateDiagramClasses.dependsOn(buildClassDiagram) // (4)
-
Declare the dependency.
-
Configure the output directory where to store SVG files.
-
Configure the source file to provide to the plugin.
-
Force the
buildClassDiagram
task to be performed before executing thegenerateDiagramClasses
one.
Built on top of awesome libraries:
Icons made by Eucalyp from www.flaticon.com