More Related Content
Similar to Leiningen超速入門 (20)
More from Kiyotaka Kunihira (20)
Leiningen超速入門
- 2. 自己紹介
• @Kuchitama
• フリュー株式会社勤務
- www.furyu.jp
• 社会人1年と1ヶ月
• Java/Scala/AS3/Clojure
Leiningen超速入門
- 3. 自己紹介
キモ
• @Kuchitama イ 画像
• フリュー株式会社勤務 すい
ませ
晒し
て
- www.furyu.jp ん
• 社会人1年と1ヶ月
• Java/Scala/AS3/Clojure
Leiningen超速入門
- 4. 基本スタンス
• とにかく書いてみる
• まずは手を動かす
Leiningen超速入門
- 5. 目次
• Leiningenとは
• メリット
• 使ってみた
- プロジェクト作成
- 依存関係の解決
- テスト
- パッケージング
• まとめ
Leiningen超速入門
- 6. Leiningenとは
• ライニンゲン(独)らしい
• Clojureプロジェクトのビルドツール
• デファクトスタンダード
- jarの依存関係解決
• maven2リポジトリから取得
• Clojure未インストール環境でも動作
- Javaさえあれば!
Leiningen超速入門
- 7. メリット
• 超お手軽インストール
- ●nix
- windows
• 実行環境の構築
• Java資産の再利用
Leiningen超速入門
- 8. 使ってみよう
• インストール
• ライブラリ取得
• テスト
• パッケージング
Leiningen超速入門
- 9. 使ってみよう1
インストール
• For Unix/Linux
1.スクリプトをダウンロードし、パスを通す
https://raw.github.com/technomancy/leiningen/stable/
bin/lein
2.実行権限の設定
$ chmod a+x /YOUR_PATH/lein
3.self-updateの実行
下記コマンドを実行することで、インストール完了。
$ lein self-install
Leiningen超速入門
- 10. 使ってみよう2
プロジェクトの作成
• 次のコマンドを実行
• lein new [プロジェクト名]
$ lein new KyotoCljSample
• プロジェクトが作成される
Leiningen超速入門
- 11. 使ってみよう2
プロジェクトの作成
KyotoCljSample
README
project.clj
src
test
lib
Leiningen超速入門
- 12. 使ってみよう2
プロジェクトの作成
KyotoCljSample
README
project.clj
src
test
lib
Leiningen超速入門
- 13. 使ってみよう2
プロジェクトの作成
(defproject KyotoCljSample "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.3.0"]])
Leiningen超速入門
- 14. 使ってみよう2
プロジェクトの作成
(defproject KyotoCljSample "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.3.0"]
[org.clojure/clojure-contrib "1.2.0"]])
$lein deps
Leiningen超速入門
- 15. 使ってみよう2
プロジェクトの作成
KyotoCljSample
・・・
・・・
lib
clojure-1.3.0.jar
clojure-contrib-1.2.0.jar
Leiningen超速入門
- 17. 使ってみよう2
プロジェクトの作成
KyotoCljSample
README
project.clj
src
test
lib
Leiningen超速入門
- 18. 使ってみよう2
プロジェクトの作成
src
KyotoCljSample
core.clj
test KyotoCljSample
test core.clj
Leiningen超速入門
- 19. 使ってみよう2
プロジェクトの作成
(ns KyotoCljSample.core)
(def wrap-p-tag [str-seq]
; 与えられたシーケンスを<p></p>でくくる
(map #(format “<p>%s</p>” %) str-seq)
)
Leiningen超速入門
- 20. 使ってみよう2
プロジェクトの作成
KyotoCljSample/core.clj
(ns KyotoCljSample.core)
(def wrap-p-tag [str-seq]
; 与えられたシーケンスを<p></p>でくくる
(map #(format “<p>%s</p>” %) str-seq)
)
Leiningen超速入門
- 21. 使ってみよう2
プロジェクトの作成
core.clj
(ns KyotoCljSample.core)
(def wrap-p-tag [str-seq]
; 与えられたシーケンスを<p></p>でくくる
(map #(format “<p>%s</p>” %) str-seq)
)
Leiningen超速入門
- 22. 使ってみよう3
テスト実施
src
KyotoCljSample
core.clj
test KyotoCljSample
test core.clj
Leiningen超速入門
- 23. 使ってみよう3
テスト実施
test/core.clj
(ns KyotoCljSample.test.core
(:use [KyotoCljSample.core])
(:use [clojure.test]))
(deftest wrap-test ;; wrap-p-tagがちゃんと動くか
(is (= (wrap-p-tag ["Welcome" "Kyoto" "clj"])
["<p>Welcome</p>" "<p>Kyoto</p>" "<p>clj</p>"])
"ちゃんとくくれてない"))
Leiningen超速入門
- 24. 使ってみよう3
テスト実施
$ lein test
> Testing KyotoCljSample.test.core
>
> Ran 1 tests containing 1 assertions.
> 0 failures, 0 errors.
Leiningen超速入門
- 25. 使ってみよう4
パッケージング
$ lein uberjar
KyotoCljSample
・・・
KyotoCljSample-1.0.0-
SNAPSHOT-standalone.jar
KyotoCljSample-1.0.0-
SNAPSHOT.jar
Leiningen超速入門
- 26. まとめ
• あっという間にClojure環境構築
• 使いたいライブラリを速攻ゲット
• テストまで出来る
• 超お手軽パッケージング
Leiningen超速入門
- 27. 参考サイト
• Clojure@wiki : http://www16.atwiki.jp/clojure/
• GitHub: http://github.com/kuchitama/hentai
Leiningen超速入門
Editor's Notes
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n