为什么即使未激活配置文件,Maven仍会运行配置文件插件 [英] Why Maven runs profile plugin even if profile is not activated
问题描述
另一个Maven问题.我有通过maven-surefire-plugin运行的TestNG测试应用程序.我创建了2个配置文件,用于pdoruction和测试.
Another Maven question. I have app with TestNG tests running by maven-surefire-plugin. I have created 2 profiles, for pdoruction and for testing.
我正在通过"mvn clean install"命令来构建我的应用程序.现在,我的目标是仅在指定测试配置文件时才运行TestNG测试.
I'm building my app by 'mvn clean install' command. Now my goal is to run TestNG tests only when I specify test profile.
代码:
profiles>
<profile>
<id>prod</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>test</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${basedir}/target/test-classes/firstTest.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
但是问题在于,无论何时指定"test"配置文件,每次构建应用程序时都在运行测试.为什么?
But the problem is that tests are running everytime when I build my app... no matter if 'test' profile is specified, or not. Why?
推荐答案
您可以运行mvn clean install -DskipTests
或更改您的production
配置文件定义:
You can run mvn clean install -DskipTests
or change your production
profile definition:
<profile>
<id>prod</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</profile>
这篇关于为什么即使未激活配置文件,Maven仍会运行配置文件插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!