1

[app-root]/target/my-project-war 아래에 maven-assembly-plugin을 사용하여 war 파일을 만듭니다. 이 war 파일은 [app-root]/war와 같은 응용 프로그램 루트 아래의 폴더가되도록 압축을 풀려면 어떻게합니까?maven 클린 패키지 후 war 파일 압축 해제

target/** 전쟁 대신 war 폴더를 원한다는 이유는 mvn gae : deploy를 사용하여 앱 엔진에 직접 배포하는 것입니다. gae : deploy는 maven-gae-plugin에서 제공되며, confirguration을 사용하면 war 파일이 아닌 appDir 만 지정할 수 있습니다.

의 pom.xml

<plugin> 
    <groupId>net.kindleit</groupId> 
    <artifactId>maven-gae-plugin</artifactId> 
    <version>${gae.plugin.version}</version> 
    <configuration> 
      <unpackVersion>${gae.version}</unpackVersion> 
      <serverId>appengine.google.com</serverId> 
      <sdkDir>${gae.home}</sdkDir> 
      <appDir>${basedir}/war</appDir> 
      <splitJars>true</splitJars> 
    </configuration> 
</plugin> 
<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-assembly-plugin</artifactId> 
    <version>2.2.1</version> 
    <configuration> 
     <appendAssemblyId>false</appendAssemblyId> 
     <descriptors> 
       <descriptor>${basedir}/assembly-war.xml</descriptor> 
     </descriptors> 
    </configuration> 
    <executions> 
     <execution> 
       <id>make-assembly</id> 
       <phase>package</phase> 
       <goals> 
        <goal>single</goal> 
        </goals> 
     </execution> 
    </executions> 
</plugin> 

조립 war.xml

<assembly> 
    <id>war</id> 

    <formats> 
     <format>war</format> 
    </formats> 

    <includeSiteDirectory>false</includeSiteDirectory> 
    <includeBaseDirectory>false</includeBaseDirectory> 
    <fileSets> 
    ... 
    </fileSets> 
    <dependencySets> 
    </dependencySets> 
</assembly> 

여기 내 프로젝트 폴더입니다. 전쟁 폴더는 굵게 표시됩니다.

$ ls -l test-maven-play-plugin/ 
total 24 
drwxr-xr-x 5 angeloh staff 170 Jan 25 21:45 app 
[email protected] 1 angeloh staff 2962 Jan 25 23:58 assembly-war.xml 
drwxr-xr-x 6 angeloh staff 204 Jan 25 21:46 conf 
drwxr-xr-x 26 angeloh staff 884 Jan 25 22:42 lib 
[email protected] 1 angeloh staff 7380 Jan 26 00:05 pom.xml 
drwxr-xr-x 4 angeloh staff 136 Jan 26 00:04 precompiled 
drwxr-xr-x 5 angeloh staff 170 Jan 25 21:45 public 
drwxr-xr-x 9 angeloh staff 306 Jan 26 00:04 target 
drwxr-xr-x 6 angeloh staff 204 Jan 25 22:11 test 
drwxr-xr-x 3 angeloh staff 102 Jan 25 22:15 test-result 
drwxr-xr-x 2 angeloh staff 68 Jan 26 00:04 tmp 
drwxr-xr-x 3 angeloh staff 102 Jan 25 22:10 **war** 

---------------------- [UPDATE] ------------------ ----

약간의 진전. 나는 이러한 변화 할 경우

의 pom.xml

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    ...... 
    <configuration> 
     ...... 
     <outputDirectory>${basedir}/war</outputDirectory> 
    </configuration> 
    ...... 
</plugin> 

조립 war.xml

<assembly> 
    <id>war</id> 

    <formats> 
     <format>dir</format> 
    </formats> 
    ...... 
</assembly> 

전쟁의 컨텐츠를 것 전쟁/테스트 플레이 1.0.0로 출력. 그러나 전쟁/테스트 - 1.0.0이 아닌 전쟁에 직접 참여하고 싶습니다.

---------------------- [업데이트] --------------------- -

마지막으로 이러한 변경 작업을 수행 한 후에도 문제가 해결되었습니다.

의 pom.xml

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    ...... 
    <configuration> 
     ...... 
     <outputDirectory>${basedir}</outputDirectory> 
     <finalName>war</finalName> 
    </configuration> 
    ...... 
</plugin> 
+0

왜 그렇게합니까? 프로젝트 유형 전쟁은 대부분의 경우를 다룹니다. –

+0

질문의 이유를 편집합니다. – angelokh

+0

war 프로젝트에서 패키지 단계를 호출하면 먼저 대상 디렉토리에 war 컨텐츠가있는 디렉토리를 생성 한 다음 war 파일을 작성합니다. 그 디렉토리를 사용할 수 없습니까? –

답변

0

받는다는 전쟁 - 플러그인은 먼저 디렉토리에 웹 응용 프로그램을 구축합니다. 기본적으로이 디렉토리는 ${project.build.directory}/${project.build.finalName}입니다 (webappDirectory 구성 등록 정보 참조).

maven-gae-plugin은 압축되지 않은 전쟁에서 전개됩니다. 기본적으로 동일한 디렉토리입니다. 당신이 문제가있는 경우

mvn clean package gae:deploy 

, 당신은 전쟁에 사용을 고려할 수 : 인플레 이스 목표를, 클래스 파일과 자원을 복사 할

그래서 당신은 간단하게 실행할 수 있어야합니다 (그 appDir 구성 속성을 참조하십시오) src/main/webapp/WEB-INF/classes에, src/main/webapp/WEB-INF/lib에 의존성을 설정합니다.

+1

아, 맞지 않습니다. 오버레이와 제외를 많이 사용하면 webAppDirectory에 표시되지만 최종 전쟁에는 표시되지 않습니다. –