Sonar Qube
カバレッジのためにJaCoCo
をAndroid
に追加しようとしています。しかし、コマンド./gradlew jacocoTestReport
を実行すると、次のエラーが発生します。
Task :app:testAlphaReleaseUnitTest FAILED
FAILURE: Build failed with an exception.
何が悪かったのか:
Could not resolve all files for configuration ':app:jacocoAgent'.
> Could not find org.jacoco:org.jacoco.agent:org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.
Searched in the following locations:
- file:/Users/atif/Library/Android/sdk/extras/m2repository/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.pom
- file:/Users/atif/Library/Android/sdk/extras/m2repository/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.421021a4
- file:/Users/atif/Library/Android/sdk/extras/google/m2repository/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.pom
- file:/Users/atif/Library/Android/sdk/extras/google/m2repository/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.421021a4
- file:/Users/atif/Library/Android/sdk/extras/Android/m2repository/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.pom
- file:/Users/atif/Library/Android/sdk/extras/Android/m2repository/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.421021a4
- https://jcenter.bintray.com/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.pom
- https://jcenter.bintray.com/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.421021a4
- https://dl.google.com/dl/Android/maven2/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.pom
- https://dl.google.com/dl/Android/maven2/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.421021a4
- https://maven.fabric.io/public/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.pom
- https://maven.fabric.io/public/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.421021a4
- https://jcenter.bintray.com/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.pom
- https://jcenter.bintray.com/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.421021a4
- https://maven.fabric.io/public/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.pom
- https://maven.fabric.io/public/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.421021a4
- https://dl.google.com/dl/Android/maven2/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.pom
- https://dl.google.com/dl/Android/maven2/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.421021a4
- https://repo.maven.Apache.org/maven2/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.pom
- https://repo.maven.Apache.org/maven2/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.421021a4
Required by:
project :app
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
これが私のgradle
ファイルです。
プロジェクトbuild.gradle
buildscript{
dependencies {
classpath "org.jacoco:org.jacoco.core:0.8.2"
classpath "org.jacoco:org.jacoco.agent:0.8.2"
}
}
plugins {
id "jacoco"
}
App build.gradle:
plugins {
id "com.Android.application"
id "jacoco-Android"
id "org.sonarqube" version "2.6"
}
Android {
buildTypes {
debug {
testCoverageEnabled = true
}
}
}
Android.testOptions {
unitTests.all {
jacoco {
includeNoLocationClasses = true
}
}
}
jacoco {
toolVersion = "0.8.2"
reportsDir = file("$buildDir/reports/jacoco/")
}
jacocoAndroidUnitTestReport {
csv.enabled false
html.enabled false
xml.enabled true
}
ここのモハメッドは、通常のgradlejacocoプラグインで使用しているコードです。
デフォルトでエスプレッソとスプーンの両方を集めるためのセットアップも
jacoco {toolVersion = "0.8.2" //カスタムレポートディレクトリは次のように指定できます:reportsDir = file( "$ buildDir/outputs/reports/jacoco")
} tasks.withType(Test){jacoco.includeNoLocationClasses = true} task jacocoTestReport(type:JacocoReport、dependsOn:['testDebugUnitTest'、 'createDebugCoverageReport']){
reports {
xml.enabled = true
html.enabled = true
}
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'Android/**/*.*']
def debugTree = fileTree(dir: "${buildDir}/intermediates/classes/debug", excludes: fileFilter)
def mainSrc = "${project.projectDir}/src/main/Java"
getSourceDirectories().setFrom(files([mainSrc]))
//sourceDirectories = files([mainSrc])
//classDirectories = files([debugTree])
getClassDirectories().setFrom(files([debugTree]))
getExecutionData().setFrom(fileTree(dir: "$buildDir", includes: [
"jacoco/testDebugUnitTest.exec",
"**/io.gitlab.fredgrott.droidkotlinkit.*/coverageExecutionData/spoonCoverage.ec",
"outputs/code-coverage/connected/*coverage.ec"
]))
}
ビルドでリポジトリを定義していません。多くの人にとって、それはMavenCentralになります。
repositories {
mavenCentral()
}
Libフォルダーを指しているので、自分でライブラリを管理したいようです。これらのライブラリはソースコードでチェックインされていると思いますか?同じ戦略をJaCoCoライブラリに適用する必要がある場合は、それらをそこに配置して、JaCoCoプラグインの構成に割り当てる必要があります。