Ubuntu 10.10 で ivy を使う
ivy とは、複雑な java ライブラリの依存関係を解決してくれる ant のプラグイン。遅ればせながら導入を検討中。
インストールする
まずはパッケージをインストール。
aptitude install ivy
インストール後、 /usr/share/doc/ivy/README.Debian を読むと、
This package installs the ivy.jar in /usr/share/java.
No symlink to ivy.jar is created in /usr/share/ant/lib/ due to several
reasons listed in #547969.To use ivy ant tasks, ivy should be added to ant's classpath in any of
the ways listed here:
http://ant.apache.org/manual/install.html#optionalTasks
とのことで、すぐに使える状態ではない。とりあえず、.ant/lib 以下にシンボリックリンクを貼ることにする。
mkdir -p ~/.ant/lib ln -s /usr/share/java/ivy.jar ~/.ant/lib/ivy.jar
これで動くはず。
使ってみる
http://ant.apache.org/ivy/history/trunk/tutorial/start.html
を見ながらやってみるといい。
例えば、xmemcached を依存関係に追加してみたい。
ivy.xml と build.xml を作成して、ant を実行する。
ivy.xml:
<ivy-module version="2.0"> <info organisation="apache" module="hello-ivy"/> <dependencies> <dependency org="com.googlecode.xmemcached" name="xmemcached" rev="1.2.6.2" conf="default" /> </dependencies> </ivy-module>
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="hello-ivy" default="retrieve"> <target name="retrieve"> <ivy:retrieve /> </target> </project>
xmemcached の場合、 <dependency> に conf="default" を指定しないと、なぜか失敗してしまい悩んだ。
どんなライブラリが登録されているかは、
http://mvnrepository.com/
あたりを参考にするとよさそう。