当前位置: 首页 > 知识库问答 >
问题:

jacoco合并目标找不到子模块的数据文件

袁耀
2023-03-14

我有一个使用基于PowerMock的单元测试的大型Maven multiproject构建。我正在子模块中生成一个“target/jacoco.exec”,并在子模块的整个父pom中进行插件配置。我有一个附加的子模块,它只使用“报告-聚合”,并将各种子模块指定为依赖项。这些基本上都起作用了。

我现在正在尝试将这些数据与Sonarqube集成。安装的SonarQube Java Analyzer版本似乎不知道如何处理多个Jacoco.exec文件,它只处理单个文件。所以,我正在努力实现“合并”的目标。我阅读了关于这个目标的文档,但我显然没有做正确的事情,因为它只是没有找到数据文件。

         <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.8</version>
            <executions>
                <execution>
                    <id>report-aggregate</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>report-aggregate</goal>
                    </goals>
                </execution>
                <execution>
                   <id>merge</id>
                   <goals>
                       <goal>merge</goal>
                   </goals>
                   <configuration>
                       <fileSets>
                           <fileSet>
                               <directory>../childmodule1/target</directory>
                               <include>*.exec</include>
                           </fileSet>
                           <fileSet>
                               <directory>../childmodule2/target</directory>
                               <include>*.exec</include>
                           </fileSet>
                           ... several more
                       </fileSets>
                   </configuration>
                </execution>
            </executions>
        </plugin>
[INFO] ------------------------------------------------------------------------
[INFO] Building jacoco-aggregate 2.3.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ jacoco-aggregate ---
[INFO] Deleting ...\jacoco-aggregate\target
[INFO] 
[INFO] --- jacoco-maven-plugin:0.7.8:merge (merge) @ jacoco-aggregate ---
[INFO] Skipping JaCoCo merge execution due to missing execution data files
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (filter) @ jacoco-aggregate ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory ...\jacoco-aggregate\src\main\resources
[INFO] 
[INFO] --- depends-maven-plugin:1.2:generate-depends-file (generate-depends-file) @ jacoco-aggregate ---
[INFO] Created: ...\jacoco-aggregate\target\classes\META-INF\maven\dependencies.properties
[INFO] 
[INFO] --- jacoco-maven-plugin:0.7.8:instrument (default-instrument) @ jacoco-aggregate ---
[INFO] 
[INFO] --- jacoco-maven-plugin:0.7.8:restore-instrumented-classes (default-restore-instrumented-classes) @ jacoco-aggregate ---
[INFO] 
[INFO] --- jacoco-maven-plugin:0.7.8:report (default-report) @ jacoco-aggregate ---
[INFO] Skipping JaCoCo execution due to missing execution data file.
[INFO] 
[INFO] --- maven-javadoc-plugin:2.10.4:jar (module-javadoc-jar) @ jacoco-aggregate ---
[INFO] Not executing Javadoc as the project is not a Java classpath-capable package
[INFO] 
[INFO] --- jacoco-maven-plugin:0.7.8:report-aggregate (report-aggregate) @ jacoco-aggregate ---
[INFO] Loading execution data file ...\childmodule1\target\jacoco.exec
[INFO] Loading execution data file ...\childmodule2\target\jacoco.exec
... several more
[INFO] Analyzed bundle 'childmodule1' with 1 classes
[INFO] Analyzed bundle 'childmodule2' with 1 classes

如您所见,它执行了“合并”目标,但没有找到任何数据文件,尽管后来的“报告-聚合”目标找到了。

因此,我假设我指定文件集或与之相关的东西的方式在某种程度上是错误的。这里可能出了什么问题?

共有1个答案

郑锋
2023-03-14

尝试将 (以及 (如果有))移动到 ,而不是 :

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.7.8</version>
    <configuration>
        <fileSets>
            <fileSet>
                <directory>..</directory>
                <include>**/target/*.exec</include>
            </fileSet>
        </fileSets>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>merge</goal>
            </goals>
        </execution>
    </executions>
</plugin>
 类似资料:
  • 我有两个带有CMake的git存储库,一个是游戏引擎,另一个是我正在用游戏引擎制作的游戏。 原来,这个游戏引擎有一个子模块包含在项目的cmakelists.txt中,而在游戏存储库中,游戏引擎被添加为一个子模块,也包含在cmakelists.txt中。但是在编译两个项目的时候,游戏引擎编译一切正常,没有错误,我更新游戏知识库更新子模块,而在编译游戏的时候,不知什么原因没有找到游戏引擎子模块。 游戏

  • 我有我的自定义框架,它在XCode 10中正常工作。我在XCode11beta 3中重新构建它,然后集成到应用程序中,得到以下错误: 找不到目标“x86_64-apple-ios-simulator”的模块“MyCustomFramework”;发现:arm64,arm64-apple-ios 我必须对框架项目中的“有效架构”进行一些更改吗? 更新:我不能选择任何一个正确的答案,因为我的框架非常小

  • 问题内容: 我需要将供体表中的数据合并到两个目标表中。结构如下。如果在跟踪表中找不到projid,则需要在组件表中创建新组件,并使用新的ID插入到跟踪表中。此外,对于供体表中不再存在的那些项目,跟踪表的“活动”列应标记为0。我可以在单个merge语句中实现此功能吗? 供体表 跟踪表 成分表 合并后的输出表: 成分表 跟踪表 问题答案: 从理论上讲,应该有一个解决方案可以在单个语句中执行此操作,但是

  • 我似乎无法让Maven在多模块项目中找到兄弟姐妹的模块。 我已经在所有模块中运行了。 下面是MagnicCompCommon 下面是Model

  • 我有一个多模块的maven项目,并试图使用Jacoco生成聚合报告,并运行“聚合”检查。但是,我无法以任何可能的方式使Jacoco合并功能通过maven插件工作。因此,我试图创建一个最小的示例,如下所示 null 我尝试下载并手动合并文件,这很好。我想这可以用maven ant run插件下载并运行作为解决方案,但我更喜欢只使用插件! 有什么想法会导致这个问题吗?

  • 我有一个React项目,其中根目录有一个目录。在目录中,有一个和一个目录。如何更改以下内容,以便webpack在我的入口点所在的目录中查找模块。