2014-09-27 4 views
0

메이븐 프로파일을 사용하여 여러 종류의 테스트 (단위, 통합, 승인)를 분리하려고합니다.메이븐 프로파일은 하위 모듈에서 상속되지 않습니다.

 <properties> 
      <build.profile.id>dev</build.profile.id> 

      <skip.unit.tests>false</skip.unit.tests> 
      <skip.integration.tests>true</skip.integration.tests> 
      <skip.acceptance.tests>true</skip.acceptance.tests> 
     </properties> 

     <profiles> 
      <profile> 
       <id>dev</id> 
      </profile> 
      <profile> 
       <id>integration-test</id> 
       <properties> 
        <build.profile.id>integration-test</build.profile.id> 
        <skip.unit.tests>true</skip.unit.tests> 
        <skip.integration.tests>false</skip.integration.tests> 
        <skip.acceptance.tests>true</skip.acceptance.tests> 
       </properties> 
      </profile> 
      <profile> 
       <id>acceptance-test</id> 
       <properties> 
        <build.profile.id>acceptance-test</build.profile.id> 
        <skip.unit.tests>true</skip.unit.tests> 
        <skip.integration.tests>true</skip.integration.tests> 
        <skip.acceptance.tests>false</skip.acceptance.tests> 
       </properties> 
      </profile> 
     </profiles> 
     <build> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.17</version> 
       <configuration> 
        <skipTests>${skip.unit.tests}</skipTests> 
        <includes> 
         <include>**/*UnitTests.java</include> 
        </includes> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-failsafe-plugin</artifactId> 
       <version>2.17</version> 
       <executions> 
        <execution> 
         <id>integration-tests</id> 
         <goals> 
          <goal>integration-test</goal> 
          <goal>verify</goal> 
         </goals> 
         <configuration> 
          <skipTests>${skip.integration.tests}</skipTests> 
          <includes> 
           <include>**/*IntegrationTests.java</include> 
          </includes> 
         </configuration> 
        </execution> 
        <execution> 
         <id>acceptance-tests</id> 
         <goals> 
          <goal>integration-test</goal> 
          <goal>verify</goal> 
         </goals> 
         <configuration> 
          <skipTests>${skip.acceptance.tests}</skipTests> 
          <includes> 
           <include>**/*AcceptanceTests.java</include> 
          </includes> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 

당신은 내가 사용하는 프로파일에 따라 검사의 특정 유형을 실행하려면 프로필 정보를 사용하고 볼 수 있듯이이 메인 치어 파일의 일부이다. 기본 프로필은 dev이며 단위 테스트 만 실행합니다. 그들은 다음과 같이 실행할 수 있습니다 : 나는 안전 장치 플러그인을 사용

통합과 수용 테스트를 위해
mvn clean test 

: integartion 테스트를 실행의 예는 다음과 같습니다이 잘 작동

mvn clean verify -P integration-test 

내가 메인 치어에서 실행하는 경우 모듈이지만 자식 모듈에서 실행할 때 작동하지 않습니다. 테스트는 무시됩니다. 하위 모듈에 대한 효과적인 POM을 보면 프로필이 표시되지 않습니다. 제가 잘못한 일을하고 있습니까? 아니면 이것이 maven으로부터 기대되는 행동입니까? 프로필 상속 (계층 구조에서 가장 깊은 모듈로 계단식으로 연결해야하는 경우)을 수행 할 수 없다면이 방법을 사용할 수 없습니까?

업데이트 : 이것은 당신이 일반적으로 직접 모듈을 실행하지 않는 멀티 모듈 프로젝트와 프로젝트 계층 구조 프로젝트 디렉토리

--main module 
--commons module 
--administration 
----domain 
----data 
----business 
----web 
+0

POM 계층 구조 란 무엇입니까? 이것을 기반으로 - http://stackoverflow.com/questions/3695394/inheriting-maven-profiles - 작동해야합니다. –

+0

제 말은 ... 귀하의 모듈은 부모로서 다중 모듈 POM을 가지고있는 것입니다, 그렇습니까? –

+0

질문을 업데이트했습니다. 네 그들이 갖고 있어요. –

답변

3

입니다. 대신 항상 주 모듈을 실행해야하지만 원하는 하위 모듈 via -pl parameter 만 지정하십시오. 모듈을 직접 실행하는 것과 관련된 많은 문제가 있습니다.


그냥 더블 나는에 참여한 일부 멀티 모듈 프로젝트를 확인하고 나는 우리 아이 프로젝트에 플러그인 구성 형태로 부모 POM을 전파 <pluginManagement>을 사용하고 있습니다.

+0

조언을 주셔서 감사합니다. 내가 메인 모듈을 실행할 수 있기 때문에 이것은 문제가되지 않는다고 당신이 말했던 것처럼.나는 이것이 매우 유용 할 것이기 때문에 가능한 것을보고 싶었습니다. 나는 그들의 서브 모듈을 가질 다수의 서브 모듈을 가질 것이다. 개별적으로 개발할 수 있도록 별도의 저장소에 저장하려고합니다. –

+0

독립적으로 모듈을 개발할 수는 있지만 부모가 포함 된 모든 모듈은 이미 포함되어 있어야합니다. Btw, 하위 모듈이 부모를 올바르게 선언하고 있습니까? – kaqqao

관련 문제