Mar 01, 2006
CARGO にチャレンジ
CARGO とは
CARGO は、アプリケーションサーバをラッピングするオープンソースのライブラリ。 Maven、Maven2、Ant 用のプラグインが提供されており、それらから簡単にアプリケーションサーバの起動、停止などを実現することができる。 Maven2 から CARGO を使用して Tomcat の起動とアプリケーションのディプロイを行ってみた。
- CARGO 公式サイト
- http://www.geotools.org/display/CARGO
- CARGO Maven2 plugin
- http://www.geotools.org/display/CARGO/Maven2+plugin
- Container Support
- http://docs.codehaus.org/display/CARGO/Home#Home-Containersupport
pom.xml の設定
CARGO で Tomcat 5 を扱うためには、pom.xml に下記の設定を行う。
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<executions>
<execution>
<id>tomcat-execution</id>
<phase>package</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<wait>false</wait>
<container>
<containerId>tomcat5x</containerId>
<zipUrlInstaller>
<url>
http://www.apache.org/dist/tomcat/tomcat-5/v5.5.15/bin/apache-tomcat-5.5.15.zip
</url>
<installDir>
${installDir}
</installDir>
</zipUrlInstaller>
</container>
<configuration>
<dir>
${project.build.directory}/tomcat5x/container
</dir>
</configuration>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
この設定を行った後 "mvn package" を実行すると Tomcat 5 の起動とディプロイを CARGO が自動的に行ってくれる。
Tomcat 5 は CARGO が勝手にダウンロードして、$PROJECT_HOME/target/tomcat5x/container にインストールしてくれる。
"mvn clean" で target が削除されてもその次の実行時に再度ダウンロードされる。
Tomcat が起動しているかどうかは "http://localhost:8080/cargocpc/" にアクセスすることで確認できる。
TrackBack ping me at
http://www.in-vitro.jp/blog/index.cgi/Maven/20060301_01.trackback
writeback message: Ready to post a comment.
