1

maven 3.0.4를 사용하고 있습니다. 나는 -Pstage -DrunIT = 사실이-DrunIT = true와 같은 명령 줄에서 매개 변수를 설정할 때 프로필에 대한 maven failsafe 플러그인의 통합 테스트를 실행합니다.

치어 나의 무대 프로필과 같습니다 확인 MVN 예를 에 대한 받는다는 명령을 실행에 몇 가지 속성을 설정하는 경우에만 안전 장치 및 부두 플러그인 실행 (전용 통합 테스트를 실행)하고 싶다.

<profile> 
     <id>stage</id> 
     <activation> 
      <activeByDefault>false</activeByDefault> 

     </activation> 
     <build> 
      <plugins> 

       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-failsafe-plugin</artifactId> 
        <version>2.16</version> 
        <executions> 
         <execution> 
          <id>integration-test</id> 
          <goals> 
           <goal>integration-test</goal> 
          </goals> 
         </execution> 
         <execution> 
          <id>verify</id> 
          <goals> 
           <goal>verify</goal> 
          </goals> 
         </execution> 
        </executions> 
       </plugin> 


       <plugin> 
        <groupId>org.mortbay.jetty</groupId> 
        <artifactId>maven-jetty-plugin</artifactId> 
        <version>6.1.16</version> 
        <dependencies> 
         <dependency> 
          <groupId>javax.servlet</groupId> 
          <artifactId>servlet-api</artifactId> 
          <version>2.5</version> 
         </dependency> 

         <dependency> 
          <groupId>junit</groupId> 
          <artifactId>junit</artifactId> 
          <version>4.11</version> 
         </dependency> 
         <dependency> 
          <groupId>org.hamcrest</groupId> 
          <artifactId>hamcrest-all</artifactId> 
          <version>1.3</version> 
         </dependency> 

         <dependency> 
          <groupId>mysql</groupId> 
          <artifactId>mysql-connector-java</artifactId> 
          <version>5.1.6</version> 
         </dependency> 

         <dependency> 
          <groupId>xmlunit</groupId> 
          <artifactId>xmlunit</artifactId> 
          <version>1.5</version> 
         </dependency> 



        </dependencies> 
        <configuration> 
         <scanIntervalSeconds>10</scanIntervalSeconds> 
         <stopPort>8005</stopPort> 
         <stopKey>STOP</stopKey> 
         <contextPath>/</contextPath> 
        </configuration> 
        <executions> 
         <execution> 
          <id>start-jetty</id> 
          <phase>pre-integration-test</phase> 
          <goals> 
           <goal>run-exploded</goal> 
          </goals> 
          <configuration> 
           <scanIntervalSeconds>0</scanIntervalSeconds> 
           <daemon>true</daemon> 
          </configuration> 
         </execution> 
         <execution> 
          <id>stop-jetty</id> 
          <phase>post-integration-test</phase> 
          <goals> 
           <goal>stop</goal> 
          </goals> 
         </execution> 
        </executions> 
       </plugin> 


      </plugins> 
     </build> 
    </profile> 
+1

왜 프로필이 충분하지 않다? – khmarbaise

+0

새 프로필을 만드는 데는 내 프로젝트에서 많은 재 작업이 필요합니다. 전달 된 인수를 기반으로 플러그인을 활성화하거나 비활성화하는 방법을 찾아야합니다. 어떻게 든 그렇게 할 메이븐 플러그인을 만들 수 있습니까? –

답변

2

글쎄, 당신이 놓친 것 같다 당신이 속성을 정의하는 데 필요한 <activation/>에서 :

... 
<profile> 
    <id>stage</id> 
    <activation> 
     <activeByDefault>false</activeByDefault> 

     <property> 
      <name>runIT</name> 
      <!-- I think you can safely skip the value part below 
       and just pass in -DrunIT. --> 
      <value>true</value> 
     </property> 
    </activation> 
    ... 
</profile> 
+0

답장을 보내 주셔서 감사합니다.하지만 프로필이 활성화되거나 실행됩니다. 이 mvn verify를 사용하면 -Pstage가 mvn verify -DrunIT = true와 같아 지지만 전달 된 인수를 기반으로 프로파일에서 플러그인을 활성화 또는 비활성화하려고합니다. 그래서, mvn verify -Pstage -DrunIT = true는 maven failafe와 maven jetty plugin으로 무대 프로파일을 실행하고, runIT가 false로 설정되면 두 플러그인 모두 작동하지 않습니다. 두 개의 다른 프로필을 만들 수 없습니다. 하나는 플러그인이 있고 다른 하나는 플러그인이 아닙니다. –