Clojure

= Official Site =


 * http://clojure.org/
 * http://incanter.org/ : Incanter is a Clojure-based, R-like platform for statistical computing and graphics.
 * http://clojars.org/ : Clojars is a dead easy community repository for open source Clojure libraries. It's the default repository for Leiningen and Cake but you can use it with other build tools like Maven or Ivy as well.

= Mavenによるclojure開発開始手順(1) maven-clojure-blank.git = mavenを使えば
 * clojureを個別にインストールする必要はなくなる（mavenが然るべきバージョンのclojureをダウンロードしてくれる）
 * javaとの連携もスムーズ

プロジェクトのひな形作成
参考 http://blog.ik.am/entry/view/id/25/title/clojure-maven-plugin%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6Maven%E3%81%A7Clojure%2BJava%E3%83%93%E3%83%AB%E3%83%89/

blank project取得 git clone git://github.com/making/maven-clojure-blank.git .gitディレクトリを削除して、project名(ディレクトリ名、pom.xmlの設定)を変えて使ってください

とのこと. どうもありがとうございます.

作られるひな形の内容は以下の通り. $ tree .
 * -- README.md
 * -- pom.xml
 * -- src
 * |-- main
 * |  |-- clojure
 * |  |   `-- am
 * |  |       `-- ik
 * |  |           `-- blank
 * |  |               `-- hello.clj
 * |  |-- java
 * |  |   `-- am
 * |  |       `-- ik
 * |  |           `-- blank
 * |  |               `-- Hello.java
 * |  `-- script
 * |      `-- run.clj
 * `-- test
 * `-- clojure
 * `-- am
 * `-- ik
 * `-- blank
 * `-- hello_test.clj


 * clojure以下のディレクトリ構造を作り変える.
 * java以下のディレクトリ構造を作り替える.
 * (このディレクトリ構造を最初から自分で作っても大したことない. . . ）

pom.xmlを書き換える
1.6          UTF-8

maven-surefire-plugin 2.3        org.apache.maven.plugins maven-javadoc-plugin true 1g org.apache.maven.plugins maven-site-plugin ja          UTF-8 UTF-8

org.apache.maven.wagon wagon-webdav</artifactId> 1.0-beta-2

<id>central</id> http://repo1.maven.org/maven2 <id>clojure-snapshots</id> http://build.clojure.org/snapshots <id>clojars</id> http://clojars.org/repo/

<id>private-webdav-repository</id> oga private dav:http://rgm2.lab.nig.ac.jp/maven2 <id>private-webdav-snapshot-repository</id> oga private snapshot dav:http://rgm2.lab.nig.ac.jp/maven2/maven2-snapshot <distributionManagement> <uniqueVersion>false</uniqueVersion> <id>private-webdav-repository</id> oga private dav:http://rgm2.lab.nig.ac.jp/maven2 <snapshotRepository> <uniqueVersion>true</uniqueVersion> <id>private-webdav-snapshot-repository</id> oga private snapshot dav:http://rgm2.lab.nig.ac.jp/maven2/maven2-snapshot </snapshotRepository> </distributionManagement>

Emacsによるプログラム編集
clojure-modeのインストール http://blog.ik.am/entry/view/id/110/Clojure+Emacs%E3%81%AA%E9%96%8B%E7%99%BA%E7%92%B0%E5%A2%83%E3%82%92%E4%BD%9C%E3%82%8B%28late%202011%29

http://d.hatena.ne.jp/leque/20091209/p1 より.

実行

 * mvn clojure:compile
 * mvn clojure:test
 * mvn clojure:repl
 * mnv clojure:run # スクリプト実行 (src/main/script/run.cljを実行)

= Mavenによるclojure開発手順 (2) clojure-archetype.git =

参照
 * https://github.com/stuartsierra/clojure-archetype

clojure-archetype

by Stuart Sierra

This is a Maven 2 archetype for Clojure projects. It will generate a new project pre-configured to use Clojure and the Clojure Maven plugin.

clojure-archetypeのインストール
git clone git://github.com/stuartsierra/clojure-archetype.git cd clojure-archetype mvn install

ひな形作成
mvn archetype:create \ -DgroupId=your.group.name \ -DartifactId=your-new-project-name \ -DarchetypeGroupId=com.stuartsierra \ -DarchetypeArtifactId=clojure-archetype \ -DarchetypeVersion=1.0-SNAPSHOT

作られるひな形のディレクトリ構造は以下の通り. $ tree . `-- src |-- main |  |-- clojure |  |   `-- app.clj |  `-- resources |-- scripts |  `-- runtests.clj `-- test `-- clojure `-- testapp.clj
 * -- pom.xml

pom.xmlの編集
ひな形作成時に作られるpom.xmlは以下の通り. clojure-archetype.git pom.xmlの説明

SOURCES

The generated project has source code in src/main/clojure and test code in src/test/clojure. The example file src/main/clojure/app.clj demonstrates how to create a "main" Java class that can be executed at the command line.

実行
In addition to the standard Maven goals, you have several Clojure-specific goals available through clojure-maven-plugin:

* clojure:compile will ahead-of-time compile your Clojure source code to Java .class files

* clojure:test will run the script at src/scripts/runtests.clj

* clojure:repl will run a Clojure REPL

* clojure:swank will run a SWANK server for connecting to Emacs SLIME (requires SWANK as a dependency)

The clojure:compile goal is bound to the Maven "compile" lifecycle, and the clojure:test goal is bound to the Maven "test" lifecycle.

To see more available goals, run (one line):

mvn help:describe -DgroupId=com.theoryinpractise \ -DartifactId=clojure-maven-plugin

DEPENDENCIES

By default, the generated project has dependencies on Clojure 1.0. For dependencies on other Clojure versions, or on clojure-contrib, uncomment the indicated sections in the generated pom.xml.

LICENSE

Copyright (c) 2009 Stuart Sierra. All rights reserved. The use and distribution terms for this software are covered by the Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which can be found in the file epl-v10.html at the root of this distribution. By using this software in any fashion, you are agreeing to be bound by the terms of this license. You must not remove this notice, or any other, from this software.

= その他 =

Ubuntu (10.04 LTS)にclojureをインストール
参照 http://riddell.us/ClojureOnUbuntu.html


 * mvn installしてもclojure-contrib-1.3.jarができてきません(2012.01.16). とりあえず http://clojure.org/downloads からclojure-contrib-1.2.0.zipをダウンロードして回避を図ります.

leiningenのインストール
無いと何かと不便. 参照 http://d.hatena.ne.jp/t2ru/20100123/1264199643

JSR223
Comment 5 by schlafbo...@googlemail.com, Oct 30, 2010

hi there, i took the pleasure of uploading your script engine implementation onto the clojars.org/repo maven repository. the pom dependency to use is:

clojure-jsr223</groupId> clojure-jsr223</artifactId> 1.0

should you not have clojars.org/repo configured as a maven repository in your configuration, you could do so in the pom of your project in the section:

<id>clojars</id> http://clojars.org/repo/

enjoy, and thanks for the work

Matthias

http://code.google.com/p/clojure-jsr223/issues/detail?id=1

I/O
http://nakkaya.com/2010/06/15/clojure-io-cookbook/