0

I have an application which use the Eclipse RCP. I have severals plugins, they each have a pom.xml file, and all the project has a super pom.xml.

The structure is :

plugin.a ( pom.xml inside )
plugin.b ( pom.xml inside )
plugin.c ( pom.xml inside )
plugin.test ( with a pom.xml too, contains all JUnit tests classes )
pom.xml

My problem is, when i launch the command : mvn integration-test

Maven tries to execute all *Test.java, but if it doesn't find it crashes ( for example in plugin a / b / c ).

How exclude specifics plugins to avoid this compilation error ?

Thank you in advance.

Edit : I found. In Each pom.xml, i was in <packaging>eclipse-test-plugin</packaging> and no in <packaging>eclipse-plugin</packaging> if i want to avoid compilation error in non tests plugins.

But thank you for help guys. <3

  • It will try to execute the unit tests cause it bound to the test phase (done by maven-surefire-plugin). If you have integration test than you should name according to the naming schema like `*IT.java` and use the appropriate maven-failsafe-plugin for such purposes. So you can control what should be executed and what not. – khmarbaise Oct 31 '14 at 08:53
  • I found the solution, but thank you. :) – Gerard Bob Oct 31 '14 at 13:17

1 Answers1

0

You can distinguish which tests run in which phase using both the surefire plugin (Unit Testing) and the failsafe plugin (Integration Testing)

As an example: (in parent pom.xml)

In your case I would think you need a similar configuration in every plugin module if there is no common pattern across the modules. So you can disable the execution per plugin.

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.16</version>
                <configuration>
                    <forkMode>once</forkMode>
                    <includes>
                        <include>**/Test*.java</include>
                    </includes>
                    <excludes>
                        <exclude>**/*</exclude>
                        <exclude>**/*IntegrationTest.java</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.17</version>
                <executions>
                    <execution>
                        <id>failsafe-tests</id>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <includes>
                        <include>**/*IntegrationTest.java</include>
                    </includes>
                </configuration>
            </plugin>

If there is a common pattern but you want to just disable the execution you can add an execution to the plugin, giving it an id. A child pom can then re-configure that execution if it uses the same id

        <plugin>
            <groupId></groupId>
            <artifactId></artifactId>
            <version></version>
            <configuration>
            </configuration>
            <executions>
                <execution>
                    <id>test-run-thing-id</id>
                    <phase>install</phase>
                    <goals>
                        <goal>plugin-goal</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
wemu
  • 7,952
  • 4
  • 30
  • 59