如何在gradle的jar项目中获得sonarqube中的jacoco结果?

如何在gradle的jar项目中获得sonarqube中的jacoco结果?,gradle,sonarqube,jacoco,multi-module,sonarqube-scan,Gradle,Sonarqube,Jacoco,Multi Module,Sonarqube Scan,我很难让jacoco和sonarqube从web服务项目使用的库项目中的代码中获得代码覆盖率结果。这是我的Gradle mutli模块项目的基本布局 母公司 图书馆项目1 图书馆项目2 Web服务项目 Gradle 2.13和org.sonarsource.scanner.Gradle:sonarqube Gradle插件:2.1-rc3 我的父项目在build.gradle中具有sonar属性。我在webService项目中有一个integrationTest任务。webService

我很难让jacoco和sonarqube从web服务项目使用的库项目中的代码中获得代码覆盖率结果。这是我的Gradle mutli模块项目的基本布局

  • 母公司
    • 图书馆项目1
    • 图书馆项目2
    • Web服务项目
Gradle 2.13和org.sonarsource.scanner.Gradle:sonarqube Gradle插件:2.1-rc3

我的父项目在build.gradle中具有sonar属性。我在webService项目中有一个integrationTest任务。webService项目依赖于两个库jar项目。库项目没有集成测试配置。我可以运行集成测试,但当我运行sonarqube任务时,它只报告webService项目的覆盖率。集成测试没有在库项目中创建jacoco.exec

如何在相关库项目的集成测试期间获得代码覆盖率

每个库项目的build.gradle都是这样的。让杰科科和声纳扫描这个信号源是不是遗漏了什么

buildscript {
  ext { springBootVersion = '1.4.1.RELEASE' }
  dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") }
}

apply plugin: 'spring-boot'
jar { archiveName = 'schema.jar' }

configurations {
  all*.exclude group: "org.slf4j", module: "slf4j-simple"
  all*.exclude group: "org.hibernate", module: "hibernate-entitymanager"
}

dependencies {
  compile('org.springframework.boot:spring-boot-starter-data-jpa')
  compile("org.eclipse.persistence:org.eclipse.persistence.jpa:2.6.4")
  compile("org.springframework:spring-orm")
  compile('org.springframework.boot:spring-boot-starter-web')
  compile("com.oracle.jdbc:ojdbc7:12.1.0.2")

  testCompile('org.springframework.boot:spring-boot-starter-test')
}
bootRepackage { enabled = false }
编辑:

有人能做到这一点吗?我发现了这个示例代码,我认为它有点不同

// get source dirs for project dependencies
FileCollection getSonarSrcDirs(List projects) {
    Set srcDirs = sourceSets.main.java.srcDirs
    projects.each {
        def projDir = project(it).projectDir
        srcDirs.add("${projDir}/src/main/java")
    }
    return files(srcDirs)
}
sonarqube {
    properties {
        property "sonar.sources", getSonarSrcDirs([':library1',':library2'])        
    }
}
但当我运行声纳时,我得到以下信息

File '/scratch/workspace/project/library1/src/main/java/Application.java' is ignored. It is not located in module basedir '/scratch/workspace/project/ws'.

不允许我将依赖模块放在对等目录中,而不是ws-project文件夹的子目录中吗?

澄清一下:您的“库项目”是由源代码还是jar组成的?构成jar的源代码。build.gradle有“jar{archiveName='schema.jar'}”。或者这不是将其纳入webService项目的最佳方式?