2012-02-14 42 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

相关问题