LoginSignup
6
7

More than 5 years have passed since last update.

PlantUMLをインストールしようぜ

Last updated at Posted at 2017-04-10

設計図がほしい、という素朴な要件により PlantUML をインストールすることにする。

「AtomとPlantUMLで爆速UMLモデリング」Qiita
http://qiita.com/nakahashi/items/3d88655f055ca6a2617c

「PlantUMLを自動変換してLiveプレビューしてくれるAtom拡張 PlantUML-Viewer がイイ!」pierre3のブログ
http://pierre3.hatenablog.com/entry/2015/08/23/220217

Chocolatey をインストール

[Install Chocolatey Now]ボタンをクリックする。

コマンド・プロンプトを開けとか 書いてるな。
Windows10 のタスクバーにある「何でも聞いてください」に「cmd」と打ち込んで Enterキーを押す。
だが これは管理者モードなのだろうか?

「管理者権限でコマンドプロンプトを起動するショートカット」Qiita
http://qiita.com/takuya0301/items/df6cde3bbaf9e13ef8f0

  • Windows キー + X
  • A キー
  • Alt + Y

おおーっ!

@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

コマンド・プロンプトに こんな文字列を打ち込んでいいんだろうか?

Webサイトからコマンドをコピーして、コマンド・プロンプトの上で 右クリックして 貼り付け。

ふむ……、なんか動いているな。ワーニングがいっぱい出たけど。

Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\WINDOWS\system32>@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       2017/04/10     22:37                chocInstall
Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.5.
Downloading 7-Zip commandline tool prior to extraction.
Extracting C:\Users\TAKAHA~1\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\TAKAHA~1\AppData\Local\Temp\chocolatey\chocInstall...
Installing chocolatey on this machine
Creating ChocolateyInstall as an environment variable (targeting 'Machine')
  Setting ChocolateyInstall to 'C:\ProgramData\chocolatey'
WARNING: It's very likely you will need to close and reopen your shell
  before you can use choco.
Restricting write permissions to Administrators
We are setting up the Chocolatey package repository.
The packages themselves go to 'C:\ProgramData\chocolatey\lib'
  (i.e. C:\ProgramData\chocolatey\lib\yourPackageName).
A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin'
  and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'.

Creating Chocolatey folders if they do not already exist.

WARNING: You can safely ignore errors related to missing log files when
  upgrading from a version of Chocolatey less than 0.9.9.
  'Batch file could not be found' is also safe to ignore.
  'The system cannot find the file specified' - also safe.
chocolatey.nupkg file not installed in lib.
 Attempting to locate it from bootstrapper.
PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding...
警告: Not setting tab completion: Profile file does not exist at
'C:\Users\Takahashi\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps
1'.
Chocolatey (choco.exe) is now ready.
You can call choco from anywhere, command line or powershell by typing choco.
Run choco /? for a list of functions.
You may need to shut down and restart powershell and/or consoles
 first prior to using choco.
Ensuring chocolatey commands are on the path
Ensuring chocolatey.nupkg is in the lib folder



C:\WINDOWS\system32>

Chocolatey のインストールは成功したように見えるがどうか?

C:\WINDOWS\system32>quit
'quit' は、内部コマンドまたは外部コマンド、
操作可能なプログラムまたはバッチ ファイルとして認識されていません。

C:\WINDOWS\system32>bye
'bye' は、内部コマンドまたは外部コマンド、
操作可能なプログラムまたはバッチ ファイルとして認識されていません。

C:\WINDOWS\system32>exit

さて次は……。

コマンド・プロンプトを 1回閉じるのは やったので、再び 管理者権限で コマンドプロンプトを起動。

choco

と打鍵。

Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\WINDOWS\system32>choco
Chocolatey v0.10.5
Please run 'choco -?' or 'choco <command> -?' for help menu.

C:\WINDOWS\system32>

うーむ。

JDK

最新版は何だろうか? いつもバージョンアップして 古いデータを残しまくってくれるので Java はインストールしたくないんだが。

cinst jdk8 -y

へー。 cinst なんていうコマンドが存在したのかだぜ。

C:\WINDOWS\system32>cinst jdk8 -y
Chocolatey v0.10.5
Installing the following packages:
jdk8
By installing you accept licenses for the packages.
Progress: Downloading jdk8 8.0.121... 100%

jdk8 v8.0.121 [Approved]
jdk8 package files install completed. Performing other installation steps.
Downloading JDK from http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-windows-x64.exe
Installing jdk8...
jdk8 has been installed.
PATH environment variable does not have C:\Program Files\Java\jdk1.8.0_121\bin in it. Adding...
Environment Vars (like PATH) have changed. Close/reopen your shell to
 see the changes (or in powershell/cmd.exe just type `refreshenv`).
 The install of jdk8 was successful.
  Software installed to 'C:\Program Files\Java\jdk1.8.0_121\'

Chocolatey installed 1/1 packages. 0 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

C:\WINDOWS\system32>

JDK8 は多分入ったのだろう。

Graphviz

cinst graphviz -y

なんか インストールに長時間かかりそう……。終わったら記事の続きを書く。

C:\WINDOWS\system32>cinst graphviz -y
Chocolatey v0.10.5
Installing the following packages:
graphviz
By installing you accept licenses for the packages.
Progress: Downloading Graphviz 2.38.0.1... 100%

Graphviz v2.38.0.1 [Approved]
graphviz package files install completed. Performing other installation steps.
Downloading Graphviz
  from 'http://www.graphviz.org/pub/graphviz/stable/windows/graphviz-2.38.msi'
WARNING: C:\Users\Takahashi\AppData\Local\Temp\chocolatey\Graphviz\2.38.0.1\graphviz-2.38.msi is of content type text/plain; charset=UTF-8
Progress: 97% - Saving 33.42 MB of 34.17 MB                                    Chocolatey timed out waiting for the command to finish. The timeout
 specified (or the default value) was '2700' seconds. Perhaps try a
 higher `--execution-timeout`? See `choco -h` for details.
The install of graphviz was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\Graphviz\tools\chocolateyInstall.ps1'.
 See log for details.

Chocolatey installed 0/1 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures
 - graphviz (exited -1) - Error while running 'C:\ProgramData\chocolatey\lib\Graphviz\tools\chocolateyInstall.ps1'.
 See log for details.

C:\WINDOWS\system32>

泣けてくるほっほ。

タイムアウトで 途中で失敗したらしい。 もう一度 おなじコマンド叩くか……。

cinst graphviz -y
C:\WINDOWS\system32>cinst graphviz -y
Chocolatey v0.10.5
Installing the following packages:
graphviz
By installing you accept licenses for the packages.
Progress: Downloading Graphviz 2.38.0.1... 100%

Graphviz v2.38.0.1 [Approved]
graphviz package files install completed. Performing other installation steps.
File appears to be downloaded already. Verifying with package checksum to determine if it needs to be redownloaded.
Error - hashes do not match. Actual value was 'A57F704EB6C36D91611CA7AF84CCBA6A3952CD2D8E4D254E07BF11DA84A5B669'.
Downloading Graphviz
  from 'http://www.graphviz.org/pub/graphviz/stable/windows/graphviz-2.38.msi'
WARNING: C:\Users\Takahashi\AppData\Local\Temp\chocolatey\Graphviz\2.38.0.1\graphviz-2.38.msi is of content type text/plain; charset=UTF-8
Progress: 100% - Completed download of C:\Users\Takahashi\AppData\Local\Temp\chocolatey\Graphviz\2.38.0.1\graphviz-2.38.msi (34.17 MB).
Download of graphviz-2.38.msi (34.17 MB) completed.
Hashes match.
Installing Graphviz...
Graphviz has been installed.
 The install of graphviz was successful.
  Software installed as 'msi', install location is likely default.

Chocolatey installed 1/1 packages. 0 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

C:\WINDOWS\system32>

今度は いけただろうか。

ATOM

「ATOM 1.0 リリースおめでたう記念に最初からインストールし直してみた」Qiita
http://qiita.com/spiegel-im-spiegel/items/5c6dafcece9e7118877a

[Download Windows 64-bit Installer]をクリックしてみる。

インストーラーを ダウンロードできたので 開いて実行した。

かといって apm というコマンドが使えるわけでもないのか。

うん? ATOM をインストールすると、パスが通って apm コマンドが使えるようになるって?
じゃあ コマンド・プロンプトを 再起動する必要があるじゃないか?

管理者権限のコマンド・プロンプトを再起動した。

Plant UML Viewer

apm install plantuml-viewer

よし、apm コマンドが動く。
進捗が分からないが ほっておこう。

C:\WINDOWS\system32>apm install plantuml-viewer
Installing plantuml-viewer to C:\Users\Takahashi\.atom\packages done

C:\WINDOWS\system32>

インストールでけた。

Plant UML 言語

apm install language-plantuml
C:\WINDOWS\system32>apm install language-plantuml
Installing language-plantuml to C:\Users\Takahashi\.atom\packages done

C:\WINDOWS\system32>

インストールでけた。

文字化け対策

atom

と コマンド・プロンプトに打鍵すると Atom のウィンドウが出てくる。

メイン・メニューから [File]-[Settings] と進む。

[Core] - [File Encoding] と進む。
最初から Unicode(UTF-8) に設定されていた。このままでいい。

[Editor] - [Font Family] でフォントも設定できるようだが、フォント名が分からないので そのまま空欄にした。

これで もうセットアップ できたのだろうか?

Atomの画面上には、UML図のようなものは どこにも出てこない。

Atom で Plant UML ファイルを新規作成する

Atom のウィンドウの右下隅に

CRLF UTF-8 Plain Text

と並んでいるところがあるので、Plain Text を PlantUML に変更してみる。

メイン・メニューから [View] - [Panes] - [Split Right] と選択し、画面右側に 欄を出す。
新しく出した欄を 右クリックして、[Toggle plantuml-viewer] をクリック。
これで UML図が出てきた。

図を描いてみよう

「PlantUML Cheat Sheet」Qiita
http://qiita.com/ogomr/items/0b5c4de7f38fd1482a48

コピペ貼り付けする。

20170411a5.png

よし、セットアップはでけた。 あとは使いながら覚えていこう。

文字化け対策

20170413a3b1.png

文字化けしている。設定が必要なのか。

「AtomのMarkdown Previewで日本語が文字化けする」Yura YuLife
http://yura2.hateblo.jp/entry/2015/08/02/Atom%E3%81%AEMarkdown_Preview%E3%81%A7%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%81%8C%E6%96%87%E5%AD%97%E5%8C%96%E3%81%91%E3%81%99%E3%82%8B

Atom のメニューから、[File] - [Stylesheet...] と進む。

そうこうしている内に クラッシュしたのか PlantUML が表示されなくなった。
スタイルシートを編集するのは止める。

plantuml-viewer にも 文字コード設定 があるのか。
[File] - [Settings] - [Packages] - [plantuml-viewer] - [Charset] と進み、

utf-8

と打鍵。

20170413a4b1.png

これで直った。


いくつか使ってみた例を、次の記事に載せている。
http://qiita.com/muzudho1/items/d5d30619bf7f4102f7f1#_reference-27a8be0631e9a4fb6f1f

6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7