maven에서 리소스 파일복사를 지정하고 동일한 파일을 복사하다가 충돌이 나서 파일복사가 안되는 경우가 있다.

(결국 중복 파일 이슈)

 

그 때 –X 옵션을 이용해서 debug된 화면을 보면 다음과 같이 나온다.

 

파일이름 wasn't copied because it has already been packaged for overlay [currentBuild].

 

충돌을 잘 피할 수 있도록 exclude를 사용하면 문제를 회피할 수 있다.

 

 

 

 

예를 들어 아래 설정이 에러가 나는 상황이라고 가정한다.

src/conf/release 디렉토리에 ‘prop.properties’ 파일이 있고, src/conf/release/test 디렉토리에 ‘prop.properties’ 파일이 존재한다. pom.xml 파일을 빌드하면 복사가 안된다.

 

        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-war-plugin</artifactId>
                        <configuration>
                            <webappDirectory>${deploy.dir}</webappDirectory>
                            <ignoreWebxml>true</ignoreWebxml>
                            <webResources>
                                <resource>
                                    <directory>src/conf/release</directory>
                                    <targetPath>WEB-INF/classes</targetPath>
                                </resource>
                                <resource>
                                    <directory>src/conf/release/test</directory>
                                    <targetPath>WEB-INF/classes</targetPath>
                                </resource>
                            </webResources>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

 

 

그래서, 복사하는 파일이 충돌할 경우 다음과 같이 따로 exclude로 빼서 파일 복사가 충돌 나지 않도록 설정하면 파일 복사가 원하는 대로 이루어진다. 즉, 기존 파일은 안쓰고, 새로운 디렉토리에 있던 파일을 복사해서 쓰도록 한다의 의미를 넣은 것이다.

 

 

         <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-war-plugin</artifactId>
                        <configuration>
                            <webappDirectory>${deploy.dir}</webappDirectory>
                            <ignoreWebxml>true</ignoreWebxml>
                            <webResources>
                                <resource>
                                    <directory>src/conf/release</directory>
                                    <targetPath>WEB-INF/classes</targetPath>
                                    <excludes>
                                        <exclude>prop.properties</exclude>
                                      </excludes>
                                </resource>
                                <resource>
                                    <directory>src/conf/release/test</directory>
                                    <targetPath>WEB-INF/classes</targetPath>
                                </resource>
                            </webResources>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
Posted by '김용환'
,