Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude goals in maven

Tags:

java

maven

jetty

I have done some integration tests using Selenium, so I have defined a goal on pre-integration-test phase so I:

  • Start a Jetty
  • Deploy the app
  • Perform tests
  • Stop the Jetty

This runs fine in my local server.

However, now I am deploying the app to a dev server with tomcat, and I want this tests to be executed with this tomcat, not with Jetty, and my build fails trying to start Jetty on the same port as tomcat (8080). I am executing a mvn package.

Is there any parameter in maven I can use to skip this goal from being executed?

This is the snippet I am using to start the server before the integration tests:

        <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>maven-jetty-plugin</artifactId>
            <version>6.1.10</version>
            <configuration>
                <scanIntervalSeconds>10</scanIntervalSeconds>
                <stopKey>foo</stopKey>
                <stopPort>9999</stopPort>
                <contextPath>/</contextPath>
            </configuration>
            <executions>
                <execution>
                    <id>start-jetty</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <scanIntervalSeconds>0</scanIntervalSeconds>
                        <daemon>true</daemon>
                    </configuration>
                </execution>
                <execution>
                    <id>stop-jetty</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
like image 689
Eugenio Cuevas Avatar asked Sep 15 '25 05:09

Eugenio Cuevas


2 Answers

Starting with Maven 2.0.10, one or more profiles can be deactivated using the command line by prefixing their identifier with either the character '!' or '-' as shown below:

mvn groupId:artifactId:goal -P !profile-1,!profile-2

This can be used to deactivate profiles marked as activeByDefault or profiles that would otherwise be activated through their activation config.

Here is more info

like image 65
husayt Avatar answered Sep 16 '25 19:09

husayt


You can solve your problems with maven profiles. Create a profile for Jetty container and a separate profile for Tomcat

like image 33
WeMakeSoftware Avatar answered Sep 16 '25 20:09

WeMakeSoftware