Java 当我从命令行设置参数(如-DrunIT=true)时,从maven failsafe插件为概要文件运行集成测试
我使用的是maven 3.0.4。我只希望在执行maven命令时设置一些属性,例如mvnverify-Pstage-DrunIT=true时,failsafe和jetty插件才能运行(仅运行集成测试) 我在pom中的舞台简介如下所示Java 当我从命令行设置参数(如-DrunIT=true)时,从maven failsafe插件为概要文件运行集成测试,java,maven,integration-testing,maven-jetty-plugin,maven-failsafe-plugin,Java,Maven,Integration Testing,Maven Jetty Plugin,Maven Failsafe Plugin,我使用的是maven 3.0.4。我只希望在执行maven命令时设置一些属性,例如mvnverify-Pstage-DrunIT=true时,failsafe和jetty插件才能运行(仅运行集成测试) 我在pom中的舞台简介如下所示 <profile> <id>stage</id> <activation> <activeByDefault>false</activeByDe
<profile>
<id>stage</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.16</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.16</version>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>1.5</version>
</dependency>
</dependencies>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<stopPort>8005</stopPort>
<stopKey>STOP</stopKey>
<contextPath>/</contextPath>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run-exploded</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>
</plugins>
</build>
</profile>
阶段
假的
org.apache.maven.plugins
maven故障保护插件
2.16
集成测试
集成测试
验证
验证
org.mortbay.jetty
maven jetty插件
6.1.16
javax.servlet
servlet api
2.5
朱尼特
朱尼特
4.11
org.hamcrest
汉克雷斯特酒店
1.3
mysql
mysql连接器java
5.1.6
xmlunit
xmlunit
1.5
10
8005
停止
/
起动码头
预集成测试
跑爆
0
真的
停靠码头
整合后测试
停止
好吧,在
中,您需要定义属性,您似乎忽略了该属性:
...
<profile>
<id>stage</id>
<activation>
<activeByDefault>false</activeByDefault>
<property>
<name>runIT</name>
<!-- I think you can safely skip the value part below
and just pass in -DrunIT. -->
<value>true</value>
</property>
</activation>
...
</profile>
。。。
阶段
假的
runIT
真的
...
为什么配置文件还不够?在我的项目中,创建一个新的配置文件需要大量的返工。我需要根据传递的参数找到一种激活或停用插件的方法。我可以创建一个maven插件吗?谢谢你的回答,但这将激活或运行配置文件。有了这个mvn verify-Pstage,它将与mvn verify-DrunIT=true相同,但我想根据传递的参数激活或停用概要文件中的插件。因此,mvn verify-Pstage-DrunIT=true将使用maven failsafe和maven jetty插件运行阶段概要文件,如果runIT设置为false,这两个插件都将无法工作。我不能创建两个不同的配置文件,一个有插件,一个没有。