倭マン's BLOG

くだらない日々の日記書いてます。 たまにプログラミング関連の記事書いてます。 書いてます。

Archetype -- 対話的にプロジェクトを作成する

Maven1.x では出来ていた「対話的にプロジェクトを作成する」ことが、やっとこさ Maven2 でも出来るようになりました(こちらmarsのメモを参考)。

作成方法


適当なフォルダ上でコマンド「mvn archetype:creategenerate」を実行すると、プロジェクト作成プロセスが起動されます*1。 後はメッセージにしたがってパラメータを入力していってください。

archetype の種類は、画面に表示されているリストから番号を選択します。 その他入力が必要なパラメータは「groupId」「artifactId」「version」「packageName」です。

最後にパラメータ値が表示されるので、値が間違っていなければ「Y」もしくは「y」を入力します。 するとプロジェクトのテンプレートが作成されます。

プロジェクトのテンプレート


現在選択できるテンプレートは以下の通り:

No archetype description
1 appfuse-basic-jsf AppFuse archetype for creating a web application with Hibernate, Spring and JSF
2 appfuse-basic-spring AppFuse archetype for creating a web application with Hibernate, Spring and Spring MVC
3 appfuse-basic-struts AppFuse archetype for creating a web application with Hibernate, Spring and Struts 2
4 appfuse-basic-tapestry AppFuse archetype for creating a web application with Hibernate, Spring and Tapestry 4
5 appfuse-core AppFuse archetype for creating a jar application with Hibernate and Spring and XFire
6 appfuse-modular-jsf AppFuse archetype for creating a modular application with Hibernate, Spring and JSF
7 appfuse-modular-spring AppFuse archetype for creating a modular application with Hibernate, Spring and Spring MVC
8 appfuse-modular-struts AppFuse archetype for creating a modular application with Hibernate, Spring and Struts 2
9 appfuse-modular-tapestry AppFuse archetype for creating a modular application with Hibernate, Spring and Tapestry 4
10 maven-archetype-j2ee-simple A simple J2EE Java application
11 maven-archetype-marmalade-mojo A Maven plugin development project using marmalade
12 maven-archetype-mojo A Maven Java plugin development project
13 maven-archetype-portlet A simple portlet application
14 maven-archetype-profiles
15 maven-archetype-quickstart
16 maven-archetype-site-simple A simple site generation project
17 maven-archetype-site A more complex site project
18 maven-archetype-webapp A simple Java web application
19 struts2-archetype-starter A starter Struts 2 application with Sitemesh, DWR, and Spring
20 struts2-archetype-blank A minimal Struts 2 application
21 struts2-archetype-portlet A minimal Struts 2 application that can be deployed as a portlet
22 struts2-archetype-dbportlet A starter Struts 2 portlet that demonstrates a simple CRUD interface with db backing
23 struts2-archetype-plugin A Struts 2 plugin
24 shale-archetype-blank A blank Shale web application with JSF
25 maven-adf-archetype Archetype to ease the burden of creating a new application based with ADF
26 data-app A new Databinder application with sources and resources.
27 jini-service-archetype Archetype for Jini service project creation
28 softeu-archetype-seam JSF+Facelets+Seam Archetype
29 softeu-archetype-seam-simple JSF+Facelets+Seam(no persistence) Archetype
30 softeu-archetype-jsf JSF+Facelets Archetype
31 jpa-maven-archetype JPA application
32 spring-osgi-bundle-archetype Spring-OSGi archetype
33 confluence-plugin-archetype Atlassian Confluence plugin archetype
34 maven-archetype-har Hibernate Archive
35 maven-archetype-sar JBoss Service Archive
36 wicket-archetype-quickstart A simple Apache Wicket project

問題点


まだリリースされたばかりなので(しかも alpha 版)、いろいろ改善の余地は残っているようです。 幾つか気付いたことを。 こまめに -U オプションを付けて実行していると、すぐに改善されてるかも。

「version」や「packageName」が省略できない

以前は、「version」が省略されれば「1.0-SNAPSHOT」が、「packageName」が省略されれば「groupId」と同じ値がデフォルト値として使用されていましたが、その省略が出来なくなったようです。

独自の archetype が使えない

独自の archetype が使用できません。 以前の長いコマンド(archetypeGroupId, archetypeArtifactId, archetypeVersion などのパラメータを指定したもの)を実行しても対話が始まります。 「-DinteractiveMode=false」としても対話が始まります・・・ なんでやねん!!
Apache Maven 2.0入門 Java・オープンソース・ビルドツール

Apache Maven 2.0入門 Java・オープンソース・ビルドツール

*1:最初の1回は -U オプションを付けて「mvn -U archetype:creategenerate」のように実行してください。 2度目からは不要です。