Skip to content

Instantly share code, notes, and snippets.

@raydive
Created April 15, 2014 23:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raydive/10788095 to your computer and use it in GitHub Desktop.
Save raydive/10788095 to your computer and use it in GitHub Desktop.
ちまちまとStashプラグインの作成をしているので、その手始めのところをまとめてみました。

Atlassian製品プラグイン作成事始め

  • ここ何週間かStashのプラグインを作成するにあたり、まずその開発環境構築にちょっとつまづいたところがあったので、そのつまづきを共有するためにこの文章があります
  • プラグインを作成するためのチュートリアルがここにありますが、

Atlassian Plugin SDKのインストール

StashやConfluenceなどAtlassian製品のプラグインを作成するにあたりまずはSDKをインストールする必要があります。

  • まずJDKがインストールされていること
    • Atlassian SDKはJDK version6に依存しているということだが、今のところJDK7でも問題ない模様
  • 開発中Atlassianの製品により、使用するポートが決まっているので使用できるか確認しておくこと

SDKのインストール

  • Windows
    • ここからインストーラーがダウンロードできるので、提示される手順に従いインストール
    • 簡単
  • Linuxだと各ディストリビューションのパッケージ管理システムで提供されているので、それに従ってインストール
    • Ubuntuを例に上げる
sudo sh -c 'echo "deb https://sdkrepo.atlassian.com/debian/ stable contrib" >>/etc/apt/sources.list'
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B07804338C015B73
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install atlassian-plugin-sdk
  • Macだとインストーラーとbrewでインストールできる。brewの場合は以下のコマンドを叩いて、atlassianのレポジトリをbrewの管理下に置く。
brew tap atlassian/tap
brew install atlassian/tap/atlassian-plugin-sdk

インストール後

インストールされると以下の様なatlas-*コマンドが扱えるようになる。

>>$ atlas-
atlas-clean                            atlas-create-bamboo-plugin-module      atlas-create-fecru-plugin              atlas-create-jira4-plugin              atlas-create-stash-plugin              atlas-integration-test                 atlas-remote-test                      atlas-update
atlas-cli                              atlas-create-confluence-plugin         atlas-create-fecru-plugin-module       atlas-create-jira5-plugin              atlas-create-stash-plugin-module       atlas-mvn                              atlas-ruin                             atlas-version
atlas-clover                           atlas-create-confluence-plugin-module  atlas-create-home-zip                  atlas-create-plugin                    atlas-debug                            atlas-package                          atlas-run
atlas-compile                          atlas-create-crowd-plugin              atlas-create-jira-plugin               atlas-create-refapp-plugin             atlas-help                             atlas-release                          atlas-run-standalone
atlas-create-bamboo-plugin             atlas-create-crowd-plugin-module       atlas-create-jira-plugin-module        atlas-create-refapp-plugin-module      atlas-install-plugin                   atlas-release-rollback                 atlas-unit-test

見れば分かる通りAltrassian製品毎にプロジェクト作成のコマンドがあり、これらを叩いてプロジェクトのひな形を作る。

プロジェクト作成

例にStashプラグインを作成する。

  • まずatlas-create-stash-pluginを叩く
atlas-create-stash-plugin
  • 上記コマンドを叩くと、対話的にプロジェクトを作成していきます。
  • 作成完了すると、以下のようにディレクトリとファイルが生成されます。
>>$ ll
total 168
drwxr-xr-x  13 arata  staff    442  4 12 20:55 ./
drwxr-xr-x   3 arata  staff    102  3 29 16:41 ../
-rw-r--r--   1 arata  staff  43612  3 29 17:19 .classpath
-rw-r--r--   1 arata  staff    707  4  2 23:56 .project
drwxr-xr-x   4 arata  staff    136  4  2 23:56 .settings/
-rw-r--r--   1 arata  staff    310  3 29 16:41 LICENSE
-rw-r--r--   1 arata  staff    625  3 29 16:41 README
-rw-r--r--   1 arata  staff   4401  3 29 16:41 pom.xml
drwxr-xr-x   4 arata  staff    136  3 29 16:41 src/
drwxr-xr-x  11 arata  staff    374  3 29 23:53 target/
-rw-r--r--   1 arata  staff    436  3 29 19:10 test.txt
  • pom.xmlがあるのが見えますが、Mavenで管理されています。xmlファイル面倒くさいです。
  • 特にコードを書いてませんが、このままatlas-runコマンドを叩くことでテスト開発用のStashが起動してアクセスできるようになります。
    • 標準出力に流れるログを見ると、Mavenに書いた依存関係に従ってライブラリ等をダウンロードしているようなので、初回起動はめちゃめちゃ時間がかかります。
    • 2回めからも起動時間はそんなにはやくないです。
    • dockerでアレコレ環境作る必要なかった!

開発環境

  • Mavenで管理されているので、EclipseにMavenプラグインを入れたりもしくはMavenが扱えるNetbeansやIntelliJで扱うなどしてIDEで開発することも可能
    • VimやEmacsももちろん(扱いやすさは置いておく)
  • SDKのモジュールがバグっていることがあるので、注意
    • 作業はじめた当初、jarファイルの依存関係が誤っていて素のプロジェクトすら動かなかった
  • Javaが面倒くさい感
    • 記述量多い
    • IDEの補完必須
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment