Java Maven:组合2个配置文件时没有覆盖范围
我有一个maven构建,有两个相关的概要文件,分别称为集成构建(用于运行集成测试)和sonar(用于覆盖)Java Maven:组合2个配置文件时没有覆盖范围,java,maven,sonarqube,maven-surefire-plugin,maven-failsafe-plugin,Java,Maven,Sonarqube,Maven Surefire Plugin,Maven Failsafe Plugin,我有一个maven构建,有两个相关的概要文件,分别称为集成构建(用于运行集成测试)和sonar(用于覆盖) 没有覆盖的集成构建是有效的 没有集成测试的正常构建+sonar工作中的覆盖(覆盖显示在sonarqube中) 覆盖率为0的集成生成不起作用 所以最后一种类型的构建失败了。我的命令是: mvn clean install -Pintegration-build,sonar 这似乎是我的集成构建maven概要文件中的相关部分: <plugin>
- 没有覆盖的集成构建是有效的
- 没有集成测试的正常构建+sonar工作中的覆盖(覆盖显示在sonarqube中)
- 覆盖率为0的集成生成不起作用
mvn clean install -Pintegration-build,sonar
这似乎是我的集成构建maven概要文件中的相关部分:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<argLine>-Xms256m -Xmx2048m</argLine>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version>
<configuration>
<argLine>-Xms256m -Xmx2048m</argLine>
<includes>
<include>**/IT*.java</include>
<include>**/*IT.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
我如何解决这个问题,同时保持覆盖范围?我认为主要问题是,当两个配置文件都激活时,您将
放在故障保护和surefire插件中,这两个插件不兼容
请记住,激活配置文件时会合并它们。所以你突然有了两个
定义等等
我想您需要将尽可能多的
移动到需要它的
中。谢谢您的输入。所以我应该在我的集成构建配置中将-Xms256m-Xmx2048m部分从argline中排除,并将其作为argline添加到执行部分?我会尝试的。我尝试了。激活了2个概要文件的构建可以工作(覆盖范围),但是只有激活了集成概要文件而没有激活sonar的构建在错误“@{surefire.argLine}”时失败。在我当前的设置中,它的配置是@{surefire.argLine},执行中的配置是-Xms256m-xmx2048m。当我使用这两个配置文件时,它似乎得到了很好的合并,但是当我不使用sonar配置文件时,集成构建配置文件似乎无法解析@{surefire.argLine},或者我错了吗?
<profile>
<id>sonar</id>
<properties>
<envTarget>tst</envTarget>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<argLine>@{surefire.argLine} -Xms256m -Xmx2048m</argLine>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version>
<configuration>
<argLine>@{failsafe.argLine} -Xms256m -Xmx2048m</argLine>
<includes>
<include>**/IT*.java</include>
<include>**/*IT.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<append>true</append>
</configuration>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>surefire.argLine</propertyName>
<destFile>${project.basedir}/target/jacoco.exec</destFile>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.basedir}/target/jacoco.exec</dataFile>
</configuration>
</execution>
<execution>
<id>pre-it-test</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
<configuration>
<propertyName>failsafe.argLine</propertyName>
<destFile>${project.basedir}/target/jacoco-it.exec</destFile>
</configuration>
</execution>
<execution>
<id>post-it-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.basedir}/target/jacoco-it.exec</dataFile>
</configuration>
</execution>
<execution>
<id>report-aggregate</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<createChecksum>true</createChecksum>
</configuration>
</plugin>
</plugins>
</build>
</profile>
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.0:test (default-test) on project app-models: There are test failures.
[ERROR]
[ERROR] Please refer to /srv/path//build/build-IB/app-models/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was /bin/sh -c cd "/srv/autobuild/workspace/build/build-IB/app-models" && /srv/path/tools/hudson.model.JDK/IBM-JDK8-x86_64/jre/bin/java '@{surefire.argLine}' -Xms256m -Xmx2048m -jar '/srv/autobuild/workspace/build/build-IB/app-models/target/surefire/surefirebooter6984324204710827506.jar' '/srv/autobuild/workspace/build/build-IB/app-models/target/surefire' 2020-03-20T11-00-50_881-jvmRun1 surefire5755643707151660451tmp surefire_04579178873474557152tmp
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was /bin/sh -c cd "/srv/path/workspace/build/build-IB/app-models" && /srv/path/tools/hudson.model.JDK/IBM-JDK8-x86_64/jre/bin/java '@{surefire.argLine}' -Xms256m -Xmx2048m -jar '/srv/path/workspace/build/build-IB/app-models/target/surefire/surefirebooter6984324204710827506.jar' '/srv/path/workspace/build/build-IB/app-models/target/surefire' 2020-03-20T11-00-50_881-jvmRun1 surefire5755643707151660451tmp surefire_04579178873474557152tmp