Kengo's blog

Technical articles about original projects, JVM, Static Analysis and TypeScript.

Deploying Maven's site to GitHub Pages

 Are you using Maven's site feature? How about GitHub Pages? If you're using both of them, GitHub's site-maven-plugin helps you to host your site on Pages.
 MavenのsiteとGitHub Pagesを使っている方に朗報です。GitHub社がsiteをPagesにデプロイするMavenプラグインを公開しており、とても簡単に利用することができます。


 At first, write <plugin>...</plugin> in your pom.xml.

    <message>Building site for ${project.version}</message>

 Next, open your '~/.m2/settings.xml' and create new <profile>. You have to write your GitHub's userName and password as plain text.


How to use

 What you need is just commanding `mvn site`. The gh-pages branch will be created at your remote repository. I recommend to add to command line argument to test your setting at first.
 使い方はとても簡単、`mvn site`を叩くだけです。リモートリポジトリにgh-pagesブランチが作成されます。最初はオプションを引数に追加して、設定がきちんとできていることを確認するといいでしょう。

 If your build fails, check that your pom.xml contains information of your repository like project.scm.developerConnection. Please read official document to know details of configurations.

 This plugin doesn't support multi-module site, but very useful to host simple project. I used this plugin to host my maven-jsr305-plugin's site. Enjoy!