🧩
New! Render PlantUML diagrams directly inside GitHub with our official browser extension — No server. No tokens. No tracking. Zero permissions but clipboard. — Try it out and let us know what you think!

Groovy API Client Code

Since calling Java from Groovy is pretty simple, the only thing to do is to copy PlantUML.jar file to the classpath (for example, ../Groovy/Groovy-1.7.6/lib directory).

The following script print the current PlantUML version, and encode a URL:

println net.sourceforge.plantuml.version.Version.version() println
net.sourceforge.plantuml.code.TranscoderUtil.getDefaultTranscoder().encode("Bob->Alice:hello")

If you want to generate an image from a description:

s = new net.sourceforge.plantuml.SourceStringReader("@startuml\nBob->Alice:hello\n@enduml")
FileOutputStream file = new FileOutputStream("c:/testGroovy2.png")
s.generateImage(file);
file.close()