日々の記録。

プログラミングのメモや感じた事などを記録。

Maven in 5 Minutes メモ

Maven in 5 Minutesの要約

Creating a Project

新しいプロジェクトを作るには次のコマンドを実行する。実行すると、artifactIdと同じ名前のディレクトリが作成される。

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

初回の実行は、最新のプラグインをローカルリポジトリにダウンロードするので時間がかかるかもしれない。

If you have just installed Maven, it may take a while on the first run. This is because Maven is downloading the most recent artifacts (plugin jars and other files) into your local repository.

プロジェクトディレクトリは次の構成になる。

my-app |-- pom.xml -- src |-- main | -- java | -- com | -- mycompany | -- app | -- App.java -- test -- java -- com -- mycompany -- app -- AppTest.java

goal と phase

mavenには二つの実行の指定方法がある。

goal

maven plugin:goal これはpluginに定義されているgoalを実行する。

phase

maven phase

these are the most common default lifecycle phases executed.

  • validate: validate the project is correct and all necessary information is available
  • compile: compile the source code of the project
  • test: test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
  • package: take the compiled code and package it in its distributable format, such as a JAR.
  • integration-test: process and deploy the package if necessary into an environment where integration tests can be run
  • verify: run any checks to verify the package is valid and meets quality criteria
  • install: install the package into the local repository, for use as a dependency in other projects locally
  • deploy: done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.

lifecycleと異なり二つのphaseもある。 * clean: cleans up artifacts created by prior builds * site: generates site documentation for this project

特定のゴールは、phaseに依存する。

Check out theMaven Getting Started Guide.