Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make this plugin run only on non-Windows platforms?

Tags:

maven

I'm using Maven 3.0.3. For our project integration testing, we require a virtual frame buffer to be created, using Unix commands. However, when we run our project on the Windows machines, we don't need this. We use

        <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>

How can I make the above run when the platform isn't windows and suppress the running of the plugin otherwise? Thanks, - Dave

like image 968
Dave Avatar asked Feb 14 '12 22:02

Dave


1 Answers

You can do this with profiles. There is profile activation switch for OS settings. And the plugin is so intelligent, you can use negation.

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

Further information about profiles can be found here, and about the values you can use here.

like image 119
Corubba Avatar answered Nov 19 '22 22:11

Corubba