From 0bfa86de77063bba18ff760c4ea3d0bf65e9319f Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Thu, 9 Aug 2018 20:32:29 +0200 Subject: [PATCH 1/5] Update Jacoco to 0.8.1 version. Signed-off-by: Yahor Berdnikau --- dependencies.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies.gradle b/dependencies.gradle index c803fd2e..14b9e19b 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -8,7 +8,7 @@ ext.versions = [ ktlint : "0.24.0", ktlintGradle : "4.1.0", detekt : "1.0.0.RC6-4", - jacoco : "0.7.9", + jacoco : "0.8.1", jacocoAndroid : "0.1.2", androidSupport : "22.2.1", From 12b2dce86070f7ab87ae9555b1b62ee5b54e7e23 Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Thu, 9 Aug 2018 20:32:55 +0200 Subject: [PATCH 2/5] Update JacocoAndroid plugin to 0.1.3 version. Signed-off-by: Yahor Berdnikau --- dependencies.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies.gradle b/dependencies.gradle index 14b9e19b..90f7fb05 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -9,7 +9,7 @@ ext.versions = [ ktlintGradle : "4.1.0", detekt : "1.0.0.RC6-4", jacoco : "0.8.1", - jacocoAndroid : "0.1.2", + jacocoAndroid : "0.1.3", androidSupport : "22.2.1", From 2a1dfc3e8d40374b4a4dd39bb0d248f0e9c9f5b5 Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Thu, 9 Aug 2018 20:34:23 +0200 Subject: [PATCH 3/5] Enable running test for subsonic image loader on CI. Signed-off-by: Yahor Berdnikau --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 59d7bbf1..fa7fd824 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,7 +25,7 @@ jobs: - run: name: unit-tests command: | - ./gradlew :subsonic-api:test :cache:test :ultrasonic:testDebugUnitTest + ./gradlew :subsonic-api:test :cache:test :subsonic-api-image-loader:testDebugUnitTest :ultrasonic:testDebugUnitTest ./gradlew jacocoFullReport bash <(curl -s https://codecov.io/bash) - run: From 501015c6496461baff6ea10b658773a75681bc52 Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Tue, 11 Sep 2018 22:21:55 +0200 Subject: [PATCH 4/5] Rework jacoco report generation for android projects. Signed-off-by: Yahor Berdnikau --- build.gradle | 4 +- dependencies.gradle | 3 +- gradle_scripts/jacoco.gradle | 74 +++++++++++++------------- subsonic-api-image-loader/build.gradle | 31 +++++------ ultrasonic/build.gradle | 11 ++-- 5 files changed, 60 insertions(+), 63 deletions(-) diff --git a/build.gradle b/build.gradle index b839f789..abcee58c 100644 --- a/build.gradle +++ b/build.gradle @@ -12,9 +12,7 @@ buildscript { classpath gradlePlugins.kotlin classpath gradlePlugins.ktlintGradle classpath gradlePlugins.detekt - classpath(gradlePlugins.jacocoAndroid) { - exclude group: 'org.codehaus.groovy', module: 'groovy-all' - } + classpath gradlePlugins.jacoco } } diff --git a/dependencies.gradle b/dependencies.gradle index 90f7fb05..ffbb8e74 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -9,7 +9,6 @@ ext.versions = [ ktlintGradle : "4.1.0", detekt : "1.0.0.RC6-4", jacoco : "0.8.1", - jacocoAndroid : "0.1.3", androidSupport : "22.2.1", @@ -37,7 +36,7 @@ ext.gradlePlugins = [ kotlin : "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin", ktlintGradle : "gradle.plugin.org.jlleitschuh.gradle:ktlint-gradle:$versions.ktlintGradle", detekt : "gradle.plugin.io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$versions.detekt", - jacocoAndroid : "com.dicedmelon.gradle:jacoco-android:$versions.jacocoAndroid" + jacoco : "org.jacoco:org.jacoco.core:$versions.jacoco" ] ext.androidSupport = [ diff --git a/gradle_scripts/jacoco.gradle b/gradle_scripts/jacoco.gradle index c8209068..eef97b49 100644 --- a/gradle_scripts/jacoco.gradle +++ b/gradle_scripts/jacoco.gradle @@ -1,17 +1,21 @@ apply plugin: 'jacoco' +jacoco { + toolVersion(versions.jacoco) +} + task jacocoMergeReports(type: JacocoMerge) { group = "Reporting" description = "Merge all jacoco reports from projects into one." - def subsonicApi = project.findProject("subsonic-api") - def ultrasonicApp = project.findProject("ultrasonic") - def cache = project.findProject("cache") - executionData( - "${subsonicApi.buildDir}/jacoco/test.exec", - "${ultrasonicApp.buildDir}/jacoco/testDebugUnitTest.exec", - "${cache.buildDir}/jacoco/test.exec" - ) + List jacocoFiles = new ArrayList<>() + project.subprojects { subproject -> + File commonModuleReport = new File(subproject.buildDir, "/jacoco/test.exec") + if (commonModuleReport.exists()) jacocoFiles.add(commonModuleReport) + File androidModuleReport = new File(subproject.buildDir, "/jacoco/testDebugUnitTest.exec") + if (androidModuleReport.exists()) jacocoFiles.add(androidModuleReport) + } + executionData(jacocoFiles.toArray()) destinationFile(file("${project.buildDir}/jacoco/jacoco.exec")) } @@ -20,35 +24,33 @@ def createJacocoFullReportTask() { group = "Reporting" description = "Generate full Jacoco coverage report including all modules." - def subsonicApi = project.findProject("subsonic-api") - def subsonicApiImageLoader = project.findProject("subsonic-api-image-loader") - def ultrasonicApp = project.findProject("ultrasonic") - def cache = project.findProject("cache") - - classDirectories = files( - fileTree( - dir: "${subsonicApi.buildDir}/classes/main", - excludes: subsonicApi.jacocoExclude - ), - fileTree( - dir: "${subsonicApiImageLoader.buildDir}/intermediates/classes/debug/org", - excludes: subsonicApiImageLoader.jacocoExclude - ), - fileTree( - dir: "${ultrasonicApp.buildDir}/intermediates/classes/debug/org", - excludes: ultrasonicApp.jacocoExclude - ), - fileTree( - dir: "${cache.buildDir}/classes/kotlin/main", - excludes: cache.jacocoExclude + List classFileTreeList = new ArrayList<>() + List sourceFileTreeList = new ArrayList<>() + project.subprojects { subproject -> + if (subproject.plugins.hasPlugin("kotlin-android") && + subproject.hasProperty("jacocoExclude")) { + classFileTreeList.add( + fileTree( + dir: "${subproject.buildDir}/tmp/kotlin-classes/debug", + excludes: subproject.jacocoExclude + ) ) - ) - sourceDirectories = files( - subsonicApi.sourceSets.main.getAllSource(), - subsonicApiImageLoader.extensions.getByName('android').sourceSets.main.java.sourceFiles, - ultrasonicApp.extensions.getByName('android').sourceSets.main.java.sourceFiles, - cache.sourceSets.main.getAllSource(), - ) + sourceFileTreeList.add( + subproject.extensions.getByName('android').sourceSets.main.java.sourceFiles + ) + } else if (subproject.hasProperty("jacocoExclude")) { + classFileTreeList.add( + fileTree( + dir: "${subproject.buildDir}/classes/kotlin/main", + excludes: subproject.jacocoExclude + ) + ) + sourceFileTreeList.add(subproject.sourceSets.main.getAllSource()) + } + } + + classDirectories = files(classFileTreeList.toArray()) + sourceDirectories = files(sourceFileTreeList.toArray()) executionData = files("${buildDir}/jacoco/jacoco.exec") reports { diff --git a/subsonic-api-image-loader/build.gradle b/subsonic-api-image-loader/build.gradle index 7f7d3a71..5baa60ce 100644 --- a/subsonic-api-image-loader/build.gradle +++ b/subsonic-api-image-loader/build.gradle @@ -1,7 +1,20 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' -apply plugin: 'jacoco-android' apply from: '../gradle_scripts/code_quality.gradle' +apply plugin: 'jacoco' + + +ext { + jacocoExclude = [] +} + +jacoco { + toolVersion(versions.jacoco) +} + +tasks.withType(Test) { + jacoco.includeNoLocationClasses = true +} android { compileSdkVersion(versions.compileSdk) @@ -37,19 +50,3 @@ dependencies { testImplementation testing.kluent testImplementation testing.robolectric } - -jacoco { - toolVersion(versions.jacoco) -} - -ext { - jacocoExclude = [] -} - -jacocoAndroidUnitTestReport { - excludes += jacocoExclude -} - -afterEvaluate { - testDebugUnitTest.finalizedBy jacocoTestDebugUnitTestReport -} \ No newline at end of file diff --git a/ultrasonic/build.gradle b/ultrasonic/build.gradle index e26e6631..aa7a2ff5 100644 --- a/ultrasonic/build.gradle +++ b/ultrasonic/build.gradle @@ -1,6 +1,6 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' -apply plugin: 'jacoco-android' +apply plugin: 'jacoco' apply from: "../gradle_scripts/code_quality.gradle" android { @@ -90,10 +90,11 @@ ext { '**/di/**' ] } -jacocoAndroidUnitTestReport { - excludes += jacocoExclude + +jacoco { + toolVersion(versions.jacoco) } -afterEvaluate { - testDebugUnitTest.finalizedBy jacocoTestDebugUnitTestReport +tasks.withType(Test) { + jacoco.includeNoLocationClasses = true } From e85fcc2def1f786e10f94fa2089bba9fe945960a Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Tue, 11 Sep 2018 22:23:11 +0200 Subject: [PATCH 5/5] Update Jacoco version to 0.8.2. Signed-off-by: Yahor Berdnikau --- dependencies.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies.gradle b/dependencies.gradle index ffbb8e74..d3070c20 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -8,7 +8,7 @@ ext.versions = [ ktlint : "0.24.0", ktlintGradle : "4.1.0", detekt : "1.0.0.RC6-4", - jacoco : "0.8.1", + jacoco : "0.8.2", androidSupport : "22.2.1",