Maven은 Java tool이다. 실행하려면 먼저 Java를 설치해야 한다.
더 정확히 JDK가 필요하다. JRE로는 충분하지 않다.
참조 사이트: http://maven.apache.org/download.html#Installation
C:\Users\geenoo>mvn -version
Maven version: 2.0.9
Java version: 1.5.0_16
OS name: "windows vista" version: "6.0" arch: "x86" Family: "windows"
| Directory | Description | Note |
|---|---|---|
| src/main/java | Application/Library sources | |
| src/main/resources | Application/Library resources | |
| src/main/filters | Resource filter files | |
| src/main/assembly | Assembly descriptors | |
| src/main/config | Configuration files | 사용자 환경에 맞춰서 수정할 수 있는 config. |
| src/main/webapp | Web application sources | |
| src/test/java | Test sources | |
| src/test/resources | Test resources | |
| src/test/filters | Test filter files | |
| src/site | Site | |
| LICENCE.txt | Project's licence | |
| README.txt | Project's readme | |
| pom.xml | Project를 묘사하는 파일 |
[INFO] [archetype:create]
[WARNING] This goal is deprecated. Please use mvn archetype:generate instead
[INFO] Defaulting package to group ID: com.oracleclub.app
[INFO] artifact org.apache.maven.archetypes:maven-archetype-quickstart: checking for updates from central
Downloading: http://repo1.maven.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.0/maven-archetype-quickstart-1.0.jar
4K downloaded
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating OldArchetype: maven-archetype-quickstart:RELEASE
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.oracleclub.app
[INFO] Parameter: packageName, Value: com.oracleclub.app
[INFO] Parameter: basedir, Value: D:\dev\workspace
[INFO] Parameter: package, Value: com.oracleclub.app
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: artifactId, Value: maven-app
[INFO] ********************* End of debug info from resources from generated POM ***********************
[INFO] OldArchetype created in dir: D:\dev\workspace\maven-app
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 54 seconds
[INFO] Finished at: Sun Oct 12 14:55:34 KST 2008
[INFO] Final Memory: 8M/14M
[INFO] ------------------------------------------------------------------------
위의 WARNING을 보니 create Goal이 generate로 바뀐 모양이다.
build 성공 후 확인을 해 보니 다음과 같이 프로젝트가 만들어졌다.
D:\dev\workspace\maven-app>dir
D 드라이브의 볼륨에는 이름이 없습니다.
볼륨 일련 번호: 8C54-1B4E
D:\dev\workspace\maven-app 디렉터리
2008-10-12 오후 02:55 <DIR> .
2008-10-12 오후 02:55 <DIR> ..
2008-10-12 오후 02:55 649 pom.xml
2008-10-12 오후 02:55 <DIR> src
1개 파일 649 바이트
3개 디렉터리 82,510,557,184 바이트 남음
D:\dev\workspace>tree ./maven-app /f > list.txt
D:\DEV\WORKSPACE\MAVEN-APP
│ pom.xml
│
└─src
├─main
│ └─java
│ └─com
│ └─oracleclub
│ └─app
│ App.java
│
└─test
└─java
└─com
└─oracleclub
└─app
AppTest.java
POM은 거대하고 그 복잡도 때문에 질려버릴 수 있으나
그렇다고 모든 내용을 다 이해할 필요는 없다.
top level 디렉토리에 있는 pom.xml 의 내용을 잠시 살펴보자.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.oracleclub.app</groupId>
<artifactId>maven-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>maven-app</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
여러분은 방금 Maven goal archetype:generate(이전 버전에서는 archetype:create)을 실행했다.
archetype은 goal의 plugin이다.
Maven에서의 goal은 Ant의 task와 비슷하다.
$ mvn compile
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-app
[INFO] task-segment: [compile]
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.2/maven-resources-plugin-2.2.pom
1K downloaded
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-plugins/1/maven-plugins-1.pom
3K downloaded
Downloading: http://repo1.maven.org/maven2/org/apache/maven/maven-parent/1/maven-parent-1.pom
:
:
Downloading: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-compiler-javac/1.5.3/plexus-compiler-javac-1.5.3.jar
13K downloaded
[INFO] [compiler:compile]
[INFO] Compiling 1 source file to d:\dev\workspace\maven-app\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 11 seconds
[INFO] Finished at: Tue Nov 04 02:23:05 KST 2008
[INFO] Final Memory: 2M/6M
[INFO] ------------------------------------------------------------------------
$ mvn test
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-app
[INFO] task-segment: [test]
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.4.2/maven-surefire-plugin-2.4.2.pom
6K downloaded
Downloading: http://repo1.maven.org/maven2/org/apache/maven/surefire/surefire/2.4.2/surefire-2.4.2.pom
6K downloaded
Downloading: http://repo1.maven.org/maven2/org/apache/maven/maven-parent/7/maven-parent-7.pom
20K downloaded
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.4.2/maven-surefire-plugin-2.4.2.jar
21K downloaded
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
Downloading: http://repo1.maven.org/maven2/junit/junit/3.8.1/junit-3.8.1.jar
118K downloaded
[INFO] [compiler:testCompile]
[INFO] Compiling 1 source file to d:\dev\workspace\maven-app\target\test-classes
Downloading: http://repo1.maven.org/maven2/org/apache/maven/surefire/surefire-booter/2.4.2/surefire-booter-2.4.2.pom
1K downloaded
:
:
[INFO] Surefire report directory: d:\dev\workspace\maven-app\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.oracleclub.app.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.038 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 minutes 40 seconds
[INFO] Finished at: Tue Nov 04 02:40:35 KST 2008
[INFO] Final Memory: 4M/8M
[INFO] ------------------------------------------------------------------------
$ mvn package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-app
[INFO] task-segment: [package]
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.2/maven-jar-plugin-2.2.pom
8K downloaded
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-plugins/10/maven-plugins-10.pom
7K downloaded
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.2/maven-jar-plugin-2.2.jar
26K downloaded
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test]
[INFO] Surefire report directory: d:\dev\workspace\maven-app\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.oracleclub.app.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.063 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
Downloading: http://repo1.maven.org/maven2/org/apache/maven/maven-plugin-api/2.0.6/maven-plugin-api-2.0.6.pom
1K downloaded
Downloading: http://repo1.maven.org/maven2/org/apache/maven/maven/2.0.6/maven-2.0.6.pom
8K downloaded
Downloading: http://repo1.maven.org/maven2/org/apache/maven/maven-project/2.0.7/maven-project-2.0.7.pom
2K downloaded
Downloading: http://repo1.maven.org/maven2/org/apache/maven/maven/2.0.7/maven-2.0.7.pom
10K downloaded
Downloading: http://repo1.maven.org/maven2/org/apache/maven/maven-settings/2.0.7/maven-settings-2.0.7.pom
1K downloaded
:
:
[INFO] [jar:jar]
[INFO] Building jar: d:\dev\workspace\maven-app\target\maven-app-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 27 seconds
[INFO] Finished at: Wed Nov 05 02:32:11 KST 2008
[INFO] Final Memory: 6M/13M
[INFO] ------------------------------------------------------------------------
install phase는 package phase도 실행을 포함한다.
$ mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-app
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.2/maven-install-plugin-2.2.pom
2K downloaded
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.2/maven-install-plugin-2.2.jar
15K downloaded
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test]
[INFO] Surefire report directory: d:\dev\workspace\maven-app\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.oracleclub.app.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.043 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] [jar:jar]
Downloading: http://repo1.maven.org/maven2/org/apache/maven/maven-project/2.0.6/maven-project-2.0.6.pom
2K downloaded
Downloading: http://repo1.maven.org/maven2/org/apache/maven/maven-settings/2.0.6/maven-settings-2.0.6.pom
1K downloaded
:
:
[INFO] [install:install]
[INFO] Installing d:\dev\workspace\maven-app\target\maven-app-1.0-SNAPSHOT.jar to C:\Users\geenoo\.m2\repository\com\ora
cleclub\app\maven-app\1.0-SNAPSHOT\maven-app-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11 seconds
[INFO] Finished at: Wed Nov 05 02:34:52 KST 2008
[INFO] Final Memory: 8M/15M
[INFO] ------------------------------------------------------------------------
building, testing, packaging, install
target 디렉토리 하위의 site 폴더에 report가 생성된다.
$ mvn site
:
:
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-war-plugin/2.1-alpha-1/maven-war-plugin-2.1-alpha-1.pom
4K downloaded
[INFO] Generating "Mailing Lists" report.
[INFO] Generating "Continuous Integration" report.
[INFO] Generating "Project License" report.
[INFO] Generating "Project Team" report.
[INFO] Generating "Source Repository" report.
[INFO] Generating "About" report.
[INFO] Generating "Issue Tracking" report.
[INFO] Generating "Project Summary" report.
[INFO] Generating "Dependencies" report.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 minutes 28 seconds
[INFO] Finished at: Wed Nov 05 02:45:49 KST 2008
[INFO] Final Memory: 19M/40M
[INFO] ------------------------------------------------------------------------
$ mvn clean
target 디렉토리 하위의 모든 빌드 데이터를 삭제한다.
mvn eclipse:eclipse goal 실행 후에 root directory에 .classpath와 .project 가 생성된다.
$ mvn eclipse:eclipse
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'eclipse'.
[INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking for updates from central
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-eclipse-plugin/2.5.1/maven-eclipse-plugin-2.5.1.pom
7K downloaded
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-eclipse-plugin/2.5.1/maven-eclipse-plugin-2.5.1.jar
177K downloaded
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-app
[INFO] task-segment: [eclipse:eclipse]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing eclipse:eclipse
[INFO] No goals needed for project - skipping
Downloading: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-interactivity-jline/1.0-alpha-5/plexus-interactivity-jline-1.0-alpha-5.pom
772b downloaded
Downloading: http://repo1.maven.org/maven2/jline/jline/0.9.1/jline-0.9.1.pom
145b downloaded
Downloading: http://repo1.maven.org/maven2/org/apache/maven/maven-archiver/2.2/maven-archiver-2.2.pom
1K downloaded
Downloading: http://repo1.maven.org/maven2/org/apache/maven/shared/maven-shared-components/3/maven-shared-components-3.pom
1K downloaded
:
:
[INFO] [eclipse:eclipse]
[INFO] Using as WTP server : null
[INFO] Adding default classpath contaigner: org.eclipse.jdt.launching.JRE_CONTAI
NER
[INFO] Using source status cache: d:\dev\workspace\maven-app\target\mvn-eclipse-
cache.properties
[INFO] Not writing settings - defaults suffice
[INFO] Wrote Eclipse project for "maven-app" to d:\dev\workspace\maven-app.
[INFO]
Sources for some artifacts are not available.
Please run the same goal with the -DdownloadSources=true parameter in order to check remote repositories for sources.
List of artifacts without a source archive:
o junit:junit:3.8.1
Javadoc for some artifacts is not available.
Please run the same goal with the -DdownloadJavadocs=true parameter in order to check remote repositories for javadoc.
List of artifacts without a javadoc archive:
o junit:junit:3.8.1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23 seconds
[INFO] Finished at: Fri Nov 07 00:36:20 KST 2008
[INFO] Final Memory: 5M/10M
[INFO] ------------------------------------------------------------------------
Help > Software Updates > Find and Install >
팝업창에서 다음을 입력한다.
이름: M2_Eclipse
Url: http://m2eclipse.codehaus.org/update