2012-02-14 77 views
15

我正在使用Maven 3.0.3。對於我們的項目集成測試,我們需要使用Unix命令創建虛擬幀緩衝區。但是,當我們在Windows機器上運行我們的項目時,我們不需要這個。我們使用如何讓這個插件僅在非Windows平臺上運行?

 <plugin> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <executions> 
       <execution> 
        <id>start-xvfb</id> 
        <phase>process-test-resources</phase> 
        <goals> 
         <goal>run</goal> 
        </goals> 
        <configuration> 
         <tasks> 
          <echo message="Starting xvfb ..." /> 
          <exec executable="Xvfb" spawn="true"> 
           <arg value=":0.0" /> 
          </exec> 
         </tasks> 
        </configuration> 
       </execution> 
       <execution> 
        <id>shutdown-xvfb</id> 
        <phase>post-integration-test</phase> 
        <goals> 
         <goal>run</goal> 
        </goals> 
        <configuration> 
         <tasks> 
          <echo message="Ending xvfb ..." /> 
          <exec executable="killall"> 
           <arg value="Xvfb" /> 
          </exec> 
         </tasks> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

我怎樣才能讓上面運行時平臺未窗戶和抑制插件的運行,否則?謝謝, - 戴夫

回答

19

你可以用配置文件做到這一點。操作系統設置有配置文件激活開關。而插件是如此聰明,你可以使用否定。

<profiles> 
    <profile> 
    <activation> 
     <os> 
     <family>!windows</family> 
     </os> 
    </activation> 
    <build> 
     <plugins> 
     <plugin> 
      ... 
     </plugin> 
     </plugins> 
    </build> 
    ... 
    </profile> 
</profiles> 

有關配置文件的詳細信息,可以發現here,以及有關的值,可以使用here

+0

你可以給它一個逗號分隔值的OS系列? – 2017-03-21 18:11:44

+0

我希望它只能在linux上執行 – 2017-03-21 18:41:11

相關問題