简体   繁体   English

排除maven中的目标

[英]Exclude goals in maven

I have done some integration tests using Selenium, so I have defined a goal on pre-integration-test phase so I: 我已经使用Selenium完成了一些集成测试,所以我在预集成测试阶段定义了一个目标,所以我:

  • 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). 但是,现在我正在使用tomcat将应用程序部署到开发服务器,并且我希望使用此tomcat执行此测试,而不是使用Jetty,并且我的构建无法尝试在与tomcat(8080)相同的端口上启动Jetty。 I am executing a mvn package. 我正在执行一个mvn包。

Is there any parameter in maven I can use to skip this goal from being executed? 我可以使用maven中的任何参数来跳过这个目标吗?

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>

You can solve your problems with maven profiles . 您可以使用maven 配置文件解决您的问题。 Create a profile for Jetty container and a separate profile for Tomcat 为Jetty容器创建配置文件,为Tomcat创建单独的配置文件

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 '!' 从Maven 2.0.10开始,可以使用命令行停用一个或多个配置文件,方法是在其标识符前加上字符“!”。 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. 这可用于停用标记为activeByDefault的配置文件或通过其激活配置激活的配置文件。

Here is more info 是更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM