在JaCoCo Gradle中生成报告期间找不到源文件“ com / project / api / ** / ** / MyClass.java”

问题描述

我知道JaCoCo用户手册-https://www.jacoco.org/jacoco/trunk/doc/faq.html中的规则,但是我不能更改目录,因为我的项目是多模块的。因此,示例我有这个模块: MyProject / Module_A / src / main / java / com.myorg.api / some_directories ... MyProject / Module_B / the_same_as_module_a ... ... MyProject / src / main / java / com.myorg.api / Application.java MyProject / test / java / com.myorg.api / some_directories ... 如何覆盖我的多模块项目中的所有代码? 我在遇到同样的问题时遇到了麻烦:

  1. Source files not found for Kotlin convention packaging during JaCoCo report generation

  2. JaCoCo Not Generating Coverage Reports based on Source File - Method names not clickable

    def otherProjects = [':A',':B',':C']
    
    allprojects {
          // ...
          apply plugin: 'java'
          apply plugin: 'jacoco'
          // ...
            jacoco {
                toolVersion = "0.8.5"
            }
          // ...
    }
    
    test {
      useTestNG()
      finalizedBy jacocoTestReport
    }
    
    otherProjects.each {
      evaluationDependsOn it
    }
    
    jacocoTestReport {
      filetree sourceTree = files().getAsfiletree()
      filetree classtree = files().getAsfiletree()
    
      otherProjects.each {
        sourceTree += project(it).sourceSets.main.allJava
        classtree += project(it).sourceSets.main.output.asfiletree
      }
    
      getAdditionalSourceDirs().setFrom(sourceTree)
      getAdditionalClassDirs().setFrom(classtree)
      reports {
        html.enabled = true
        xml.enabled = true
        csv.enabled = false
      }
    }
    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)