【问题标题】:How do I make this plugin run only on non-Windows platforms?如何让这个插件只在非 Windows 平台上运行?
【发布时间】:2016-07-08 22:45:10
【问题描述】:

我正在使用 Maven 3.0.3。对于我们的项目集成测试,我们需要使用 Unix 命令创建一个虚拟帧缓冲区。然而,当我们在 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>

当平台不是windows时如何使上述运行,否则禁止插件的运行?谢谢, - 戴夫

【问题讨论】:

    标签: maven


    【解决方案1】:

    您可以使用配置文件执行此操作。操作系统设置有配置文件激活开关。而且这个插件很智能,你可以使用否定。

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

    更多关于配置文件的信息可以在here找到,关于你可以使用的值here

    【讨论】:

    • 你能给它一个逗号分隔的 OS 系列值吗?
    • 我希望它只在linux上执行
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-23
    • 1970-01-01
    • 2011-07-31
    • 2021-11-03
    • 2016-07-03
    • 2014-02-07
    相关资源
    最近更新 更多