Integration with Ant build tool
Using Ant and PlantUML together is a good way to automatically generate your diagrams from scripts. You can then build your documentation and your software at the same time.
Back to top Antタスクを書く
Ant のbuild.xml
ファイルに、次のような内容を書く必要があります:
<project name="OwnTaskExample" default="main" basedir=".">
<!-- task definition -->
<taskdef name="plantuml" classname="net.sourceforge.plantuml.ant.PlantUmlTask" classpath="plantuml.jar" />
<!-- process ./src files -->
<target name="main">
<plantuml dir="./src" />
</target>
</project>
このAnt タスクは、与えられたディレクトリ(この例では./src
)にある、すべての.c 、.h 、.cpp 、.tex 、.html 、.htm 、.java ファイルから、@startXYZ
を探して.png
画像を生成します。
Writing an Ant Task
You must have something like this into your Ant build.xml
file:
<project name="OwnTaskExample" default="main" basedir=".">
<!-- task definition -->
<taskdef name="plantuml" classname="net.sourceforge.plantuml.ant.PlantUmlTask" classpath="plantuml.jar" />
<!-- process ./src files -->
<target name="main">
<plantuml dir="./src" />
</target>
</project>
The Ant task processes all .c , .h , .cpp , .tex , .html , .htm or .java of the provided directory (./src
in this example). It looks for @startXYZ
and generates .png
images.
Back to top 出力ディレクトリ
output
タグを使って、すべての生成された画像の出力先ディレクトリを指定することもできます。
<!-- Put images in c:/images directory -->
<target name="main">
<plantuml dir="./src" output="c:/images" />
</target>
Output Directory
You can also specify a output directory for all generated images, using
output
tag.
<!-- Put images in c:/images directory -->
<target name="main">
<plantuml dir="./src" output="c:/images" />
</target>
Back to top ディレクトリを再帰的に処理する
Ant 標準のfileset
やfilelist を使うこともできます。
例えば、c:/src
とサブディレクトリに対して、Test.java
で終わるファイルを除いて処理を行い、画像をd:/images
に出力する場合、次のようにします:
<target name="main">
<plantuml output="d:/images" >
<fileset dir="c:/src">
<include name="**/*.java" />
<exclude name="**/*Test.java" />
</fileset>
</plantuml>
</target>
Recurse through directories
You can also use Ant standard fileset
or filelist .
For example, if you want to process all java file in c:/src
and subdirectories, (except files ending by Test.java
), and generate images into d:/images
, you can use:
<target name="main">
<plantuml output="d:/images" >
<fileset dir="c:/src">
<include name="**/*.java" />
<exclude name="**/*Test.java" />
</fileset>
</plantuml>
</target>
Back to top SVG、EPSのサポート
Ant タスクの定義でformat="svg"
またはformat="eps"
を使うことができます。
<target name="main">
<plantuml dir="./src" format="svg" />
</target>
SVG or EPS Support
You can also use format="svg"
or format="eps"
in the Ant task definition.
<target name="main">
<plantuml dir="./src" format="svg" />
</target>
Back to top 設定ファイル
設定ファイルを指定すると、それぞれの図の前にインクルードされます。
<target name="main">
<plantuml dir="./src" config="./config.cfg" />
</target>
Configuration file
You can also provide a configuration file which will be included before each diagram.
<target name="main">
<plantuml dir="./src" config="./config.cfg" />
</target>
Back to top その他のパラメータ
パラメータ
デフォルト
説明
nbthread
1
処理を行うスレッド数
graphvizDot
dot実行可能ファイルのパス
format
png
生成する画像の形式:xmi, xmi:argo, xmi:start, eps, svg, txt, utxt
verbose
false
true
で、詳細なログを出力
config
すべての図の前にインクルードされる設定ファイル
charset
ファイル読み込み時に使用する文字コード
output
生成した画像を出力するディレクトリ
dir
処理対象の入力ディレクトリ(代わりに<fileset>/<filelist>
を使うこともできます)
failonerror
false
true
で、文法エラー発生時に処理を停止する
checkonly
false
true
で、画像を生成せずにファイルの文法チェックのみを行う
overwrite
false
true
で、読み込み専用のファイルを上書きする
enablestats
false
true
で、統計情報を有効化する
htmlstats
false
true
で、統計情報をplantuml-stats.htmlに出力する
xmlstats
false
true
で、統計情報をplantuml-stats.xmlに出力する
realtimestats
false
true
で、統計情報を処理終了時ではなく、リアルタイムに生成する
Other parameters
Parameter
Default
Description
nbthread
1
Number of thread for processing
graphvizDot
Path of the dot executable
format
png
Format for image generation: xmi, xmi:argo, xmi:start, eps, svg, txt, utxt
verbose
false
true
for more logs
config
File config to include before all diagrams
charset
Charset to use when reading files
output
Output directory for generated images
dir
Input directory to process (You can use <fileset>/<filelist>
instead)
failonerror
false
true
to fail the build if some syntax error occurs
checkonly
false
true
if you want to only check the syntax of files without generating images
overwrite
false
true
if you want overwrite read-only files
enablestats
false
true
to enable statistics
htmlstats
false
true
to output general statistics in file plantuml-stats.html
xmlstats
false
true
to output general statistics in file plantuml-stats.xml
realtimestats
false
true
to generate statistics on the fly rather than at the end