프로그래밍/Spring & Maven

Maven

Terry Cho 2013. 1. 30. 21:11

http://www.sonatype.com/books/mvnex-book/pdf/mvnex-pdf.pdf


Maven은 빌드 결과물을 goal이라는 개념으로 정의하며 . war,jar, Ruby on Rails 를 만드는 goal, junit을 수행하는 goal, jar로 패키징 하는 goal등이 구체적인 goal이 될 수 있다.

이러한 goal을 지원하기 위해서는 Maven에서 plug in 이라는 개념을 사용한다.

하나의 plug in 은 여러개의 goal을 지원한다.

예를 들어 jar를 만드는 plug in의 경우, compiler plug in, jar file 만드는 플러그인등을 지원한다.

(goal 들이 모여서 하나의 build를 만든다. ant의 각 task 개념과 유사하다.)


 


archetype에 따라서 디렉토리 구조가 다르게 정의 된다.

archetype은 만들고자 하는 애플리케이션 (이를 maven에서는 goal이라고 부른다.)  예를들어 jar, Ruby, Python 에 따라서 디렉토리 구조를 미리 정의해놓은 일종의 profile 개념이다.

generate archetype에 의해서 생성된 디렉토리 구조


Maven Diectory structure 


my-app

|-- pom.xml

`-- src

    |-- main

    |   `-- java

    |       `-- com

    |           `-- mycompany

    |               `-- app

    |                   `-- App.java

    `-- test

        `-- java

            `-- com

                `-- mycompany

                    `-- app

                        `-- AppTest.java

                        

Maven Phases


Although hardly a comprehensive list, 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.

There are two other Maven lifecycles of note beyond the default list above. They are


clean: cleans up artifacts created by prior builds

site: generates site documentation for this project


그리드형