Created
June 6, 2017 18:58
-
-
Save hjst/4f2f2c2ca9bd550e50c7f06cb17775b2 to your computer and use it in GitHub Desktop.
Makefile for use with PlantUML diagrams
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PLANTUML_JAR_URL = https://sourceforge.net/projects/plantuml/files/plantuml.jar/download | |
DIAGRAMS_SRC := $(wildcard diagrams/*.plantuml) | |
DIAGRAMS_PNG := $(addsuffix .png, $(basename $(DIAGRAMS_SRC))) | |
DIAGRAMS_SVG := $(addsuffix .svg, $(basename $(DIAGRAMS_SRC))) | |
# Default target first; build PNGs, probably what we want most of the time | |
png: plantuml.jar $(DIAGRAMS_PNG) | |
# SVG are nice-to-have but don't need to build by default | |
svg: plantuml.jar $(DIAGRAMS_SVG) | |
# clean up compiled files | |
clean: | |
rm -f plantuml.jar $(DIAGRAMS_PNG) $(DIAGRAMS_SVG) | |
# If the JAR file isn't already present, download it | |
plantuml.jar: | |
curl -sSfL $(PLANTUML_JAR_URL) -o plantuml.jar | |
# Each PNG output depends on its corresponding .plantuml file | |
diagrams/%.png: diagrams/%.plantuml | |
java -jar plantuml.jar -tpng $^ | |
# Each SVG output depends on its corresponding .plantuml file | |
diagrams/%.svg: diagrams/%.plantuml | |
java -jar plantuml.jar -tsvg $^ | |
# Quirk of GNU Make: https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html | |
.PHONY: png svg clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Assumptions
(dnf|apt|yum) install make
or install the Apple developer tools on Mac(dnf|apt|yum) install graphviz
orbrew install graphviz
on Macdnf install java-1.8.0-openjdk
on Fedora.plantuml
extension and live in thediagrams/
directory relative to this MakefileExample usage
Note: you'll probably want to add
plantuml.jar
to your.gitignore
file.