2013-10-17 2 views
4

나는 오래된 웹 애플리케이션 프로젝트를 가졌다. 그런 다음 pom.xml을 추가하고 maven-war-plugin을 추가하십시오. 이전 프로젝트 소스는 "Java Resources/src" 디렉토리에있었습니다.maven-war-plugin 소스 디렉토리를 오버라이드하는 방법

내 메이븐 - 전쟁 플러그인에서이 기본 소스 디렉터를 무시하고 있지만 작동하지 않습니다. 컴파일하는 동안

내가 볼 : `

[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ webproj --- 
[INFO] No sources to compile 
[INFO] 

`

pom.xml :

<plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.4</version> 
      <executions> 
       <execution> 
        <phase>compile</phase> 
        <goals> 
         <goal>exploded</goal> 
        </goals> 
       </execution> 
      </executions> 
      <configuration> 
       <webXml>WebContent\WEB-INF\web.xml</webXml>  
       <webappDirectory>WebContent</webappDirectory> 
       <source>${project.basedir}\src</source>   
       <target>${maven.compiler.target}</target> 
       <encoding>utf-8</encoding> 
      </configuration> 
     </plugin> 

답변

1

Maven으로 마이그레이션하려는 경우 Maven Standard Directory Layout을 따르는 것이 좋습니다. 결과적으로 소스 파일을 src/main/java, 정적 리소스를 .properties 파일 src/main/resources, CSS 및 JavaScript 파일과 같은 webapp 리소스를 src/main/webapp으로 옮겨야합니다.

1

메이븐 전쟁 - 플러그인, 프로젝트 소스 폴더를 사용하여 위치를 오버라이드 (override) 할 수 다음과 같이 넣어주세요.

<build> 

    <sourceDirectory>/Java Resources/src</sourceDirectory> 
    <plugins> 
     ... 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>build-helper-maven-plugin</artifactId> 
      <version>${version.build-helper-maven-plugin}</version> 
      <executions> 
       <execution> 
        <phase>generate-sources</phase> 
        <goals> 
         <goal>add-source</goal> 
        </goals> 
        <configuration> 
         <sources> 
          <source>social/src/main/java</source> 
         </sources> 
        </configuration> 
       </execution> 
      </executions> 
     ... 
    </plugins> 
<build> 
+0

전쟁을 시작하려고 할 때 나를 위해 작동하지 않습니다. 폭발했습니다. 플러그인은 기본 소스 디렉토리에있는 소스를 얻으려고 시도합니다. – herau

+0

당신은'sourceDirectory'를 오버라이드합니다. 이것은'maven-war-plugin' 옵션이 아닌 maven 속성입니다. 플러그인은 더 많은 디렉토리가 필요할 때만 유용합니다. –

관련 문제