2010-11-29 3 views

답변

13

유레카! 이 문제를 연구 한 지 며칠 후에 나는 마침내 매우 효과적인 해결책을 발견했습니다. 열쇠는 톰캣 XML 컨텍스트 프래그먼트 파일을 가져 와서 이라는 이름의 conf/Catalina/localhost 디렉토리에있는화물의 <configfiles> 요소를 사용하는 것입니다. 유일한 단점은 모든 웹 응용 프로그램에서 컨텍스트 정의를 사용할 수 있도록 설정한다는 것입니다. 그러나 이것은 정말로 중요하지 않습니다. Cargo만이이 Tomcat 인스턴스를 사용하므로 다른 웹 응용 프로그램이 없습니다.

<configuration> <!-- Deployer configuration --> 
    <type>standalone</type> 
    <properties> 
     <cargo.servlet.port>${tomcat6.port}</cargo.servlet.port> 
    </properties> 
    <deployables> 
     <deployable> 
     <groupId>com.myapp<groupId> 
     <artifactId>myapp-war</artifactId> 
     <type>war</type> 
     <properties> 
       <context>${tomcat6.context}</context> 
     </properties> 
     </deployable> 
    </deployables> 
    <configfiles> 
     <configfile> 
     <file>${basedir}/../config/tomcat-context.xml</file> 
     <todir>conf/Catalina/localhost/</todir> 
     <tofile>context.xml.default</tofile> 
     </configfile> 
    </configfiles> 
</configuration> 

최종 결과는 테스트하기 위해 더 이상 가짜 WAR 모듈이며, 전쟁을 더 이상 병합 :

여기에 구성입니다. 희망이 사람을 도움이됩니다.

+0

화물이 1.1.1 이음새가 새로운 파일을 추가하지 않는다는 사실을 제외하고 그것은 작동했다. 파일 만 바꿀 수있었습니다. – Ralph

2

나는 아직 이것을 할 수있는 방법을 찾지 못했지만, 나는 내 프로젝트에서 그 일을 해결하는 작업을 생각해 냈다. 나는 현재 기본적으로 3 서브 모듈과 프로젝트를 :

나는 "웹 ​​애플리케이션"프로젝트를 짓고 있어요
dependencies 
    webapp 
    smoketest 

, 나는 다음과 같은 플러그인 선언을 실행합니다

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-war-plugin</artifactId> 
    <executions> 
     <execution> 
     <id>create-war-smoketest</id> 
     <phase>verify</phase> 
     <goals> 
      <goal>war</goal> 
     </goals> 
     <configuration> 
      <webappDirectory>${project.build.directory}/exploded</webappDirectory> 
      <primaryArtifact>false</primaryArtifact> 
      <classifier>smoketest</classifier> 
      <webResources> 
      <resource> 
       <filtering>true</filtering> 
       <directory>src/test/resources/smoketest</directory> 
       <targetPath>META-INF</targetPath> 
       <includes> 
        <include>context.xml</include> 
       </includes> 
      </resource> 
      </webResources> 
     </configuration> 
     </execution> 
    </executions> 
</plugin> 

을 그리고 내를 실행하고있을 때 smokeTest 프로젝트화물/WebTest에 스위트, 내가 thusly 히 내 deployrables 설정 종속성으로 내화물 구성에서 smoketest WAR 파일을 지정합니다

<deployables> 
    <deployable> 
     <groupId>${pom.groupId}</groupId> 
     <artifactId>webapp</artifactId> 
     <type>war</type> 
     <properties> 
      <context>smoketest</context> 
     </properties> 
    </deployable> 
</deployables> 

을 종속성 리터로 다음과 같은 것을 좋아합니다 :

<dependencies> 
    <dependency> 
     <groupId>${pom.groupId}</groupId> 
     <artifactId>webapp</artifactId> 
     <version>${pom.version}</version> 
     <classifier>smoketest</classifier> 
     <type>war</type> 
     <scope>system</scope> 
     <!-- trick the dependency plugin to never look for it in the repo --> 
     <systemPath>${basedir}/../webapp/target/webapp-${pom.version}-smoketest.war</systemPath> 
    </dependency> 
</dependencies> 

매우 더럽지 만, 적어도 지금은 작동합니다. 한 가지 간단한 참고 사항 :이 시점에서 repo에서 버전을 찾지 않도록 강제하는 것에 대한 내 의견은 잘못된 것일 수 있습니다. 나는이 트릭이 어떤 시점에서 의존성 플러그인으로의 변경으로 인해 깨질 수 있다고 생각한다.

+0

나도 이것을 시도했다 - 그것은 나를 위해 또한 잘 작동한다. 폐지 된 WAR 아티팩트를 제거하기를 원했기 때문에 - 우리는 필터링 된 context.xml 파일이있는 WAR을 원하지 않거나 보낼 수 없으므로 – HDave

관련 문제