maven 빌드시 개발/운영 분리 및 정적리소스 제외 pom.xml 설정
pom.xml 설정 팁 2가지 정리
1. 로컬환경과 운영환경 선택적으로 build배포하기
2. 웹서버에 배포될 정적 리소스를 제거하고 build 하기
첫번째로 profiles를 이용하여 로컬환경과 운영환경 선택적으로 build배포하기 입니다.
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<env>dev</env>
</properties>
</profile>
<profile>
<id>real</id>
<properties>
<env>real</env>
</properties>
</profile>
</profiles>
... 중략...
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/resources-${env}</directory>
</resource>
</resources>
src/main/ 이하에 resources 관련 디렉토리를 아래와 같이 구분하여 정리합니다.
> main
> java
> resources
> resources-dev
> resources-real
두번째는 웹서버에 배포될 정적 리소스를 제거하고 build 하기입니다.
<plugins>
<!-- WAR 동적 파일 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<warName>testBuild-was</warName>
<warSourceExcludes>css/**,form/**,html/**,images/**,js/**,resource/**</warSourceExcludes>
</configuration>
</plugin>