首页 > 解决方案 > JaCoCo xml 报告自定义名称。合并 XML 文件

问题描述

由于新版本的声纳,JaCoCo 二进制报告不再可能。

我有一个包含多个模块的项目,并且在**/target/site/report.xml 报告阶段创建了 xml 报告,遗憾的是没有<destFile>配置。

正如我对.exec文件所做的那样,是否有可能对 xml 文件这样做?为 xml 报告设置自定义名称并可能合并它们?

<profile>
            <id>jacoco</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>prepare-agent</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                                <configuration>
                                    <excludes>
                                        <exclude>src/main/ui/**/*.js</exclude>
                                        <exclude>src/main/ui/**/*.ts</exclude>
                                        <exclude>src/main/ui/**/*.tsx</exclude>
                                    </excludes>
                                    <!-- Sets the path to the file which contains the execution data. -->
                                    <destFile>${sonar.jacoco.reportPath}jacoco_${project.artifactId}.exec</destFile>
                                    <!-- Sets the name of the property containing the settings for JaCoCo
                                        runtime agent. -->
                                </configuration>
                            </execution>
                            <execution>
                                <id>report</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                                <configuration>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <!-- Jacoco prepare-agent builds some command-line params without -->
                            <!-- which jacoco will not instrument. Hence it is important to add -->
                            <!-- those command-line params here (${argLine} holds those params) -->
                            <argLine>${argLine} -Xms128m -Xmx512m</argLine>
                            <forkCount>1</forkCount>
                            <runOrder>random</runOrder>
                            <testFailureIgnore>true</testFailureIgnore>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <reporting>
                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <reportSets>
                            <reportSet>
                                <reports>
                                    <report>report</report>
                                </reports>
                            </reportSet>
                        </reportSets>
                    </plugin>
                </plugins>
            </reporting>
        </profile>

谢谢,德拉戈斯。

标签: mavensonarqubecode-coveragejacocosonarlint

解决方案


推荐阅读