LoginSignup
5
4

More than 5 years have passed since last update.

epubcheck 4.0 α版をビルドして使ってみる

Last updated at Posted at 2014-06-05

わかってるひと向けの1行まとめ

githubにあるIDPF/epubcheckcontrib/nookブランチをmvn packageするとjarができる。

epubcheck最新版のソースについて

EPUB制作を真面目にしている人ならほとんど人が使ったことがあるかと思われるオープンソースのEPUBバリデータであるepubcheck。その開発は以前のGoogle Codeからgithubに移行し、現在も活発に行われています。

現在のmasterブランチは3.0.2になっていますが(2014年6月現在)、いろいろあってcontrib/nook ブランチというのが4.0になる予定で開発が進められています。

……実はこの4.0版、実装そのものというよりもテストのせいでビルドができない(localeに依存するテストがあったのでlocale依存で失敗する)場合があったのですが、先日その修正をしたpull requestが通ったので、これでビルドできるようになったはずです。めでたいですね。

というわけで、自分でepubcheck 4.0のα版をビルドして使うまでの手順をまとめておきます。

ビルドの準備

必要なものは以下です。

JavaとMavenは各自インストールしておいてください。

ソースを取得する

ふつうにgitでcloneして、contrib/nookブランチにします。

$ git clone https://github.com/IDPF/epubcheck.git epubcheck-4.0
$ cd epubcheck-4.0
$ git checkout contrib/nook

ビルドする

Mavenがインストールされていればmvnコマンドが使えるようになっているはずです。

epubcheck.jarを作るには以下のコマンドを実行するだけです。

$ mvn package

これで、target/epubcheck.jarというファイルができているはずです。

epubcheckを実行する

javaコマンドでふつうに実行できるはずです。ヘルプは以下のようになります。

$ java -jar target/epubcheck.jar --help
nookepubcheck v.4.0.0-alpha5-SNAPSHOT
When running this tool, the first argument should be the name (with the path)
 of the file to check.

If checking a non-epub file, the epub version of the file must
 be specified using -v and the type of the file using -mode.
 The default version is: 3.0.

Modes and versions supported: 
--mode opf -v 2.0
--mode opf -v 3.0
--mode xhtml -v 2.0
--mode xhtml -v 3.0
--mode svg -v 2.0
--mode svg -v 3.0
--mode nav -v 3.0
--mode mo  -v 3.0 // For Media Overlays validation
--mode exp  // For expanded EPUB archives

This tool also accepts the following options:
--save           = saves the epub created from the expanded epub
--out <file>     = output an assessment XML document file.
--json <file>    = output an assessment JSON document file
-m <file>        = same as --mode
-o <file>        = same as --out
-j <file>        = same as --json
--failonwarnings[+|-] = By default, the tool returns a 1 if errors are found in the file or 0 if no errors
                        are found.  Using --failonwarnings will cause the process to exit with a status of
                        1 if either warnings or errors are present and 0 only when there are no errors or warnings.
-f, --fatal      = include only fatal errors in the output
-e, --error      = include only error and fatal severity messages in ouput
-w, --warn       = include fatal, error, and warn severity messages in output
-u, --usage      = include ePub feature usage information in output
                    (default is OFF); if enabled, usage information will
                    always be included in the output file

-l, --listChecks [<file>] = list message ids and severity levels to the custom message file named <file>
                          or the console
-c, --customMessages [<file>] = override message severity levels as defined in the custom message file named <file>

-h, -? or --help = displays this help message

No file specified in the arguments. Exiting.
epubcheck completed

epubcheck v3に比べてオプションが増えてますね! -eとかはwarningは一時的に無視したい人には便利そうです。

javaコマンドを使わず、mvnコマンドで実行することもできます。-Dexec.argsオプションでチェックしたいEPUBファイルを、-Dexec.mainClassで実行するクラス(com.adobe.epubcheck.tool.Checker)を指定します。

$ mvn exec:java -Dexec.mainClass="com.adobe.epubcheck.tool.Checker" -Dexec.args="/foo/bar/sample.epub"
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building EpubCheck :: Validation Tool for EPUB 4.0.0-alpha5-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) @ epubcheck >>>
[INFO] 
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ epubcheck ---
[INFO] 
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) @ epubcheck <<<
[INFO] 
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ epubcheck ---
Validating against EPUB version 3.0 - custom validation
Validating using EPUB version 3.0 rules.
No errors or warnings detected.
epubcheck completed
5
4
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
5
4