2016-11-21 13 views
0

をカスタマイズするプロファイルを定義私がポンポンで、次のプラグインがあります。のMaven POM - プラグインの設定

<plugin> 
    <groupId>com.github.klieber</groupId> 
    <artifactId>phantomjs-maven-plugin</artifactId> 
    <configuration> 
     <version>${phantomjs.version}</version> 
     <checkSystemPath>false</checkSystemPath>   
     <skip>${skipTests}</skip> 
    </configuration> 
    <executions> 
     <execution> 
     <goals> 
      <goal>install</goal> 
     </goals> 
     </execution> 
    </executions> 
    </plugin> 

を私はプラグインの設定をカスタマイズするために、新しいプロファイルを定義したいと思います:

<profile> 
    <id>enduserTest</id> 

    <properties> 
    <tomcat.version>8.0.39</tomcat.version>    
    <skipTests>true</skipTests> 
    </properties>  

    <build> 
    <defaultGoal>clean verify cargo:run</defaultGoal> 
    <plugins>   

    <plugin> 
    <groupId>com.github.klieber</groupId> 
    <artifactId>phantomjs-maven-plugin</artifactId> 
    <configuration> 
     <version>${phantomjs.version}</version> 
     <checkSystemPath>false</checkSystemPath>   
    </configuration> 
    <executions> 
     <execution> 
     <goals> 
      <goal>install</goal> 
     </goals> 
     </execution> 
    </executions> 
    </plugin> 

唯一の違いは、<skip>${skipTests}</skip> 行です。 mvn -PenduserTestを実行したいが、設定が上書きされない。 アドバイスはありますか?これを行うにはよりよい解決策がありますか?それは正しい戦略ですか?

+0

これらのプラグインをプロファイルの内側と外側の両方に定義すると機能しません。しかし、私がそれらのプラグインだけをプロファイルに定義すれば、うまく動作します。 –

答えて

0

プロファイルを実行するときにテストがスキップされるため、ロジックが間違っていないようにすることが望ましい場合。私はこのコードをテストして、これが期待どおりに動作することを確認します(-PenduserTestを使ってテストをスキップします):

<dependencies> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>3.8.2</version> 
     </dependency> 
    </dependencies> 

    <build> 
     <sourceDirectory>src</sourceDirectory> 
     <plugins> 
      <plugin> 
      <groupId>com.github.klieber</groupId> 
      <artifactId>phantomjs-maven-plugin</artifactId> 
      <version>0.7</version> 
      <configuration> 
       <version>2.1.1</version> 
       <checkSystemPath>false</checkSystemPath>   
       <skip>${skipTests}</skip> 
      </configuration> 
      <executions> 
       <execution> 
       <goals> 
        <goal>install</goal> 
       </goals> 
       </execution> 
      </executions> 
      </plugin> 


      <plugin> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.3</version> 
       <configuration> 
        <source /> 
        <target /> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 

    <profiles> 
     <profile> 
     <id>enduserTest</id> 

     <properties> 
     <tomcat.version>8.0.39</tomcat.version>    
     <skipTests>true</skipTests> 
     </properties>  

     <build> 
     <defaultGoal>clean verify cargo:run</defaultGoal> 
     <plugins>   

     <plugin> 
     <groupId>com.github.klieber</groupId> 
     <artifactId>phantomjs-maven-plugin</artifactId> 
     <version>0.7</version> 
     <configuration> 
      <version>0.7</version> 
      <checkSystemPath>false</checkSystemPath>   
     </configuration> 
     <executions> 
      <execution> 
      <goals> 
       <goal>install</goal> 
      </goals> 
      </execution> 
     </executions> 
     </plugin> 
     </plugins> 
     </build> 
     </profile> 
    </profiles> 

</project> 
関連する問題