maven
EditMAVEN : The Definitive Guide
시작하기
http://maven.apache.org/guides/introduction/introduction-to-the-pom.html
[강좌 maven 따라하기 - 프로젝트 생성, 빌드, 레포팅, 배포]
생성 mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=myapp
[Maven으로 프로젝트 빌드하기 (maven1)]
<dependency>
<groupId>.....</groupId>
<artifactId>.....</artifactId>
<version>1.0.1</version>
<scope>system</scope>
<systemPath>${basedir}/lib/xss.jar</systemPath>
</dependency>
Effective pom : mvn help:effective-pom
Super pom
Options
- -e : 발생한 error에 대해서 보여준다.
- -X : Debug를 보여준다. 보통 이 옵션에 > log.log 처럼 파일로 내보내서 무슨 문제가 생겼는지 확인하면 좋다.
- -U : 업데이트가 제대로 안되었을 경우 강제로 repository에서 업데이트 하도록한다.
- -fn : 에러가 나던 말던 일단 빌드부터 하고 본다.
- -P : 프로파일을 설정해서 하나의 프로젝트를 다른 설정으로 빌드할 수 있다.
기초개념
Life Cycle
- [MavenOption]
- 메이븐 상식: 기본 페이스(phase)
Dependency
[Maven을 쓴다고 해서 종속성을 안중에서 Out 시킬 수 있느냐?]
exclusion을 하까마까 "가장 가까운" 의존성을 사용하게 됩니다
mvn versions:display-dependency-updates : 상위 버전 보여주기
Site
디렉토리구조
Plug-in
http://maven.apache.org/plugins/maven-assembly-plugin/ : Assemblies
http://mojo.codehaus.org/javancss-maven-plugin/http://maven-plugins.sourceforge.net/maven-javancss-plugin/http://emma.sourceforge.net/maven-emma-plugin/http://maven.apache.org/guides/development/guide-testing-development-plugins.html
http://maven.apache.org/guides/development/guide-testing-development-plugins.html
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>ca.sqlpower.architect.swingui.ArchitectFrame</mainClass>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
<manifestEntries>
<Class-Path>jdbc/</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
exec plugin
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>/home1/irteam/bin/tomcat.sh</executable>
<workingDirectory>/home1/irteam/bin</workingDirectory>
<arguments>
<argument>start</argument>
<argument>buzz</argument>
</arguments>
</configuration>
</plugin>
Resource Filter encoding 설정
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
archetype
mvn install:install-file -Dfile=C:\aa.jar -DgroupId=aa -DartifactId=aa -Dversion=1.0 -Dpackaging=jar
mvn archetype:update-local-catalog
mvn archetype:generate
Maven - Eclipse
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
Maven-Eclipse plugin
==== 테스트
Skip : -Dmaven.test.skip=true
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
하나만 : -Dtest=MyTest
메모리 문제시
export MAVEN_OPTS=-XX:MaxPermSize=256m
-XX:MaxPermSize=256m
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<argLine>-Xmx256m</argLine> << 요 부분에 좀 자세히 적어주시면 될 겁니다.
<forkMode>once</forkMode>
<reportFormat>xml</reportFormat>
</configuration>
</plugin>
==== 주의할 점
Version 인식문제
==== Profile
=== Library 검색
=== Repository
[메이븐 저장소 war 버전 Nexus 설치 및 설정]
=== Maven WAS
===== Jetty
<build>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
<scanIntervalSeconds>3</scanIntervalSeconds>
<contextPath>/</contextPath>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8080</port>
</connector>
</connectors>
</configuration>
</plugin><plugin>
===== Tomcat
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<path>/admin</path>
</configuration>
</plugin>
</plugins>
</build>
Tomcat maven plugin 소스 : https://github.com/apache/tomcat-maven-plugin
=== Eclipse Integration
===== m2 Eclipse
update site : http://m2eclipse.sonatype.org/update/, http://download.eclipse.org/technology/m2e/releases
Maven Integration for Eclipse (M2 Eclipse):
===== Q4e
Local에 파일설치 : mvn install:install-file -Dfile=ojdbc14.jar -DgroupId=com.oracle-DartifactId=ojdbc14 -Dversion=10.2.0.2.0 -Dpackaging=jar
Release
mvn release:prepare -Darguments="-DskipTests" -Dusername=benelog -Dpassword=234234
War 파일에 버전 새기기
<properties>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
</properties>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webappDirectory>${deploy.dir}</webappDirectory>
<archive>
<manifestEntries>
<Build-Date>${maven.build.timestamp}</Build-Date>
<Revision-Number>${revision}</Revision-Number>
</manifestEntries>
</archive>
</configuration>
</plugin>