Maven:合并2个配置文件时无覆盖范围

问题描述 投票:0回答:1

我有一个具有2个相关配置文件的Maven构建,称为集成构建(用于运行集成测试)和声纳(用于覆盖)。

  • 无覆盖范围的集成版本有效>
  • 没有集成测试的正常构建+声纳工程的覆盖范围(覆盖范围显示在声纳库中)
  • 具有覆盖率的集成版本不起作用(覆盖率为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>

这是我的声纳资料:

<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>

现在,我在集成构建配置文件中更新了以下几行:<argLine>-Xms256m -Xmx2048m</argLine><argLine>@{surefire.argLine} -Xms256m -Xmx2048m</argLine><argLine>-Xms256m -Xmx2048m</argLine><argLine>@{failsafe.argLine} -Xms256m -Xmx2048m</argLine>

然后运行。在他运行mvn sonar:sonar -Psonar之后,我进行了集成测试和覆盖。

但是当我现在仅使用集成构建概要文件运行时(没有声纳),它将失败!然后我得到类似的错误:

[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

如何解决此问题,但要保持覆盖范围?

我有一个具有2个相关配置文件的Maven构建,称为集成构建(用于运行集成测试)和声纳(用于覆盖)。没有覆盖范围的集成版本可以在没有...

java maven sonarqube maven-surefire-plugin maven-failsafe-plugin
1个回答
0
投票

我认为主要问题是您将<configuration>放在了同时激活两个配置文件时都不兼容的故障安全和surefire插件中。

© www.soinside.com 2019 - 2024. All rights reserved.