Maven Profiles
- Maven에 있는 Profile의 사용 목적은 서로 다른 빌드 환경간의 이식성 이다.
Profile 간단 사용 예제
- profile 설정 간단 예제
<profiles>
<profile>
<id>local</id>
<properties>
<env>local</env>
</properties>
</profile>
<profile>
<id>alpha</id>
<properties>
<env>alpha</env>
</properties>
</profile>
<profile>
<id>beta</id>
<properties>
<env>beta</env>
</properties>
</profile>
<profile>
<id>release</id>
<properties>
<env>release</env>
</properties>
<activation>
<property>
<name>bds</name>
<value>false</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<debug>true</debug>
<optimize>true</optimize>
<encoding>utf-8</encoding>
<showDeprecations>true</showDeprecations>
<fork>true</fork>
<executable>/usr/local/env/java/jdk1.5.0_10/bin/javac</executable>
</configuration>
</plugin>
</plugins>
</build>
</profile>
..
</profiles>
<properties>
<env>local</env>
<bds>false</bds>
<clover.home>analysis_tools/clover</clover.home>
<checkstyle.home>analysis_tools/checkstyle</checkstyle.home>
<pmd.home>analysis_tools/pmd</pmd.home>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
- 실행시 profile 옵션을 사용한다 (ex. mvn package -Palpha)
- 실행위치의 pom.xml, 실행위치의 profiles.xml, $USER_HOME/settings.xml, $M2_HOME/conf/settings.xml 순으로 profile 항목을 찾는다.
- profile의 id 가 동일한 경우가 나타나면 해당 profile 에서 선언된 내용을 적용한다.
즉 사용자 정의 환경변수 env 의 값이 alpha로 변경 됨. - mvn -Palpha는 mvn -Denv=alpha 로 변경 사용.
Profile activation의 사용
- activation 엘리먼트는 오직 profile 엘리먼트 내부에서만 사용할 수 있다.
- 정의한 환경과 실행 환경이 일치하면 profile에 설정한 값들이 project에 설정한 값에 대체 한다.
- mvn -Ddeploy=true 실행시 아래 activation 수행 됨
<profiles> <profile> <activation> <property> <name>deploy</name> <value>true</value> </property> </activation> <build> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <phase>compile</phase> <goals> <goal>run</goal> </goals> <configuration> <tasks> <mkdir dir="../webapps" /> <copy todir="../webapps" overwrite="true" preservelastmodified="true"> <fileset dir="${basedir}/web"> <include name="**/*" /> </fileset> </copy> </tasks> </configuration> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles>
문서정보
- 이 문서는 구루비에서 작성하였습니다.
- 이 문서를 다른 블로그나 홈페이지에 게재하실 경우에는 출처를 꼭 밝혀 주시면 고맙겠습니다.~^^
- 출처 : http://wiki.gurubee.net/display/SWDEV/Maven+Profiles?
- 구루비 지식창고의 모든 문서는 크리에이티브 커먼즈의 저작자표시-비영리-동일조건변경허락(BY-NC-SA) 라이선스에 따라 자유롭게 사용할 수 있습니다.
댓글 없음:
댓글 쓰기