2012-09-03 6 views
9

Mavenビルドにいくつかのシステム変数を渡したいと思います。もし私がmvn clean install -Dfirst.variable=value -Dsecond.variable=second.valueを使用していれば、すべて問題ありません。しかしpom.xmlでこの設定は動作しません。Maven-surefire-pluginでシステム変数を渡す

 <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.12.3</version> 
      <executions> 
       <execution> 
        <id>tests</id> 
        <phase>test</phase> 
        <goals> 
         <goal>test</goal> 
        </goals> 
        <configuration> 
         <includes> 
          <include>**/*Test.java</include> 
         </includes> 
         <systemPropertyVariables> 
          <first.variable>${value}</first.variable> 
          <second.variable>${second.value}</second.variable> 
         </systemPropertyVariables> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

私は、<phase/><goals>せずにこの設定を使用しようとしましたが、それは助けにはなりませんでした。プラグインが実行されない可能性はありますか?これらの変数のハードコードされた値でさえも合格しません。もしそうなら、考えられる解決策は何ですか?前もって感謝します。

答えて

8

<execution/>を作成する必要はありません。簡単な方法:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <configuration> 
     <systemPropertyVariables> 
     <my.property>propertyValue</my.property> 
     </systemPropertyVariables> 
    </configuration> 
</plugin> 
+0

ありがとう、それは働いた!私はのコードサンプルを見て、うまく動作するはずです。そのような行動の理由は何ですか? –