티스토리 뷰
728x90
maven 사용시 pom.xml 파일에서 profile 태그를 활용하면 프로필 별로 종속성, 플러그인 등을 설정할 수 있지만,
<groudId>com.exam</groudId>
<artifactId>com.exam.test</artifactId>
<version>1.0.0</version>
<description>test</description>
<profiles>
<profile>
<id>development</id>
<dependencies>
<!-- 개발용 의존성 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>production</id>
<dependencies>
<!-- 프로덕션용 의존성 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>
</dependencies>
</profile>
</profiles>
기본적인 프로젝트의 groud id, artifact id, version 등은 profile태그로 나눌 수 없다.
자체적인 라이브러리를 개발하여 구성하는 경우 버저닝을 위해 고민하던 중 pom.xml 을 분리할 수 있는 것을 알았다.
예를 들어 pom-dev.xml, pom-prod.xml 등을 만들고
빌드할 때 -f 옵션을 강제로 지정해주면 pom 파일을 바꿔칠 수 있다.
mvn -f pom-prod.xml -U clean deploy
시야를 넓게 보는 능력 키우기.