diff --git a/build.gradle b/build.gradle index 8c183878..cf9a84f5 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,6 @@ buildscript { } } -//apply plugin: 'com.palantir.jacoco-full-report' apply plugin: 'com.github.kt3k.coveralls' @@ -58,7 +57,7 @@ ext { compileSdkVersion = 28 volleyVersion = "1.1.0" targetSdkVersion = 27 - jacocoVersion = "0.8.7" + jacocoVersion = "0.8.8" mapboxSdkVersion = "8.3.3" mapboxAnnotationPluginVersion = "0.6.0" } @@ -78,40 +77,44 @@ task jacocoFullReport(type: JacocoReport, group: 'Coverage reports') { sourceDirectories.from = files(subprojects.sourceSets.main.allSource.srcDirs) classDirectories.from = files(subprojects.sourceSets.main.output) - def index = 0 - for (dir in additionalSourceDirs) { - System.out.println( (index + 1) + ". " + dir.path) - } - - index = 0 - for (dir in sourceDirectories) { - System.out.println( (index + 1) + ". " + dir.path) - } - - index = 0 - for (dir in classDirectories) { - System.out.println( (index + 1) + ". " + dir.path) - } List executionDataPaths = new ArrayList<>() + List classPaths = new ArrayList<>() + List sourcePaths = new ArrayList<>() + List jacocoClasspathPaths = new ArrayList<>() + for (subModule in subprojects) { def jacocoTestReportTask = subModule.getTasksByName("jacocoTestReport", false) jacocoTestReportTask.forEach({task -> if (task instanceof JacocoReport) { - System.out.println("This is a JacocoReport task: " + task.name) executionDataPaths.addAll((task as JacocoReport).executionData.getFiles()) + classPaths.addAll((task as JacocoReport).classDirectories) + sourcePaths.addAll((task as JacocoReport).sourceDirectories) + jacocoClasspathPaths.addAll((task as JacocoReport).jacocoClasspath) } }) } executionData.from = executionDataPaths + sourceDirectories.from = sourcePaths + classDirectories.from = classPaths - getReports().getXml().setDestination(file("${buildDir}/reports/jacoco/jacocoFullReport/merged.xml")) + getReports().getXml().setDestination(file("${buildDir}/reports/jacoco/jacocoFullReport/jacocoFullReport.xml")) getReports().getHtml().setDestination(file("${buildDir}/reports/jacoco/jacocoFullReport/html")) reports { html.enabled true xml.enabled true } + + jacocoClasspath = files(jacocoClasspathPaths) } + +task printClasspath { + doLast { + this.printClasspath + } + + //def task = org.gradle.testing.jacoco.tasks.JacocoReport() +} diff --git a/library/build.gradle b/library/build.gradle index f6d6d017..ec2e7d81 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -70,7 +70,8 @@ android { } debug { - testCoverageEnabled true + // See bug https://github.com/vanniktech/gradle-android-junit-jacoco-plugin/issues/183 + testCoverageEnabled false if (project.rootProject.file("local.properties").exists()) { Properties properties = new Properties() @@ -178,7 +179,8 @@ tasks.withType(Test) { jacoco.excludes = ['jdk.internal.*'] } -task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) { +// createDebugCoverageReport is not available when android.buildTypes.debug.testCoverageEnabled is false +task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) { //, 'createDebugCoverageReport']) { reports { xml.enabled = true @@ -190,7 +192,7 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'crea def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*' , 'android/**/*.*', "io/realm/*.*"] - def debugTree = fileTree(dir: "${buildDir}/intermediates/javac/debug/compileDebugJavaWithJavac/classes", excludes: fileFilter) + def debugTree = fileTree(dir: "${buildDir}/intermediates/javac/debug/classes", excludes: fileFilter) def mainSrc = "${project.projectDir}/src/main/java" sourceDirectories.setFrom([mainSrc]) diff --git a/sample/build.gradle b/sample/build.gradle index 8408c1c7..b9b48252 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -139,7 +139,8 @@ android { } debug { - testCoverageEnabled true + // See bug https://github.com/vanniktech/gradle-android-junit-jacoco-plugin/issues/183 + testCoverageEnabled false buildConfigField "String", "MAPBOX_SDK_ACCESS_TOKEN", properties["mapbox.sdk.token"] buildConfigField "String", "CGR_USERNAME", properties["cgr.username"] buildConfigField "String", "CGR_PASSWORD", properties["cgr.password"] @@ -242,7 +243,8 @@ tasks.withType(Test) { jacoco.excludes = ['jdk.internal.*'] } -task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) { +// createDebugCoverageReport is not available when android.buildTypes.debug.testCoverageEnabled is false +task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) { //, 'createDebugCoverageReport']) { reports { xml.enabled = true @@ -254,7 +256,7 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'crea def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*' , 'android/**/*.*', "io/realm/*.*", "io/ona/kujaku/sample/activities/*.*"] - def debugTree = fileTree(dir: "${buildDir}/intermediates/javac/debug/compileDebugJavaWithJavac/classes", excludes: fileFilter) + def debugTree = fileTree(dir: "${buildDir}/intermediates/javac/debug/classes", excludes: fileFilter) def mainSrc = "${project.projectDir}/src/main/java" sourceDirectories.setFrom(files([mainSrc])) diff --git a/utils/build.gradle b/utils/build.gradle index 115de45b..1b7824c8 100644 --- a/utils/build.gradle +++ b/utils/build.gradle @@ -36,7 +36,8 @@ android { } debug { - testCoverageEnabled true + // See bug https://github.com/vanniktech/gradle-android-junit-jacoco-plugin/issues/183 + testCoverageEnabled false } } @@ -68,9 +69,11 @@ dependencies { tasks.withType(Test) { jacoco.includeNoLocationClasses = true + jacoco.excludes = ['jdk.internal.*'] } -task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) { +// createDebugCoverageReport is not available when android.buildTypes.debug.testCoverageEnabled is false +task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) { //, 'createDebugCoverageReport']) { reports { xml.enabled = true @@ -82,7 +85,7 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'crea def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*' , 'android/**/*.*', "io/realm/*.*"] - def debugTree = fileTree(dir: "${buildDir}/intermediates/javac/debug/compileDebugJavaWithJavac/classes", excludes: fileFilter) + def debugTree = fileTree(dir: "${buildDir}/intermediates/javac/debug/classes", excludes: fileFilter) def mainSrc = "${project.projectDir}/src/main/java" sourceDirectories.setFrom(files([mainSrc])) @@ -92,5 +95,9 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'crea ])) } +task printTasks { + System.out.println("Jacoco version ${jacoco.toolVersion}") +} + // Add github packages, maven-central and sonatype publishing apply from: '../publish.gradle' \ No newline at end of file diff --git a/utils/src/test/java/io/ona/kujaku/helpers/MapBoxStyleHelperTest.java b/utils/src/test/java/io/ona/kujaku/helpers/MapBoxStyleHelperTest.java index f595b7fe..7d13bea9 100644 --- a/utils/src/test/java/io/ona/kujaku/helpers/MapBoxStyleHelperTest.java +++ b/utils/src/test/java/io/ona/kujaku/helpers/MapBoxStyleHelperTest.java @@ -22,7 +22,6 @@ */ @RunWith(RobolectricTestRunner.class) -@Config(manifest = Config.NONE) public class MapBoxStyleHelperTest { /** diff --git a/wrapper/build.gradle b/wrapper/build.gradle index ab08673e..9d057045 100644 --- a/wrapper/build.gradle +++ b/wrapper/build.gradle @@ -39,7 +39,8 @@ android { } debug { - testCoverageEnabled true + // See bug https://github.com/vanniktech/gradle-android-junit-jacoco-plugin/issues/183 + testCoverageEnabled false } } @@ -69,7 +70,8 @@ tasks.withType(Test) { jacoco.excludes = ['jdk.internal.*'] } -task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) { +// createDebugCoverageReport is not available when android.buildTypes.debug.testCoverageEnabled is false +task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) { //, 'createDebugCoverageReport']) { reports { xml.enabled = true @@ -81,7 +83,7 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'crea def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*' , 'android/**/*.*', "io/realm/*.*"] - def debugTree = fileTree(dir: "${buildDir}/intermediates/javac/debug/compileDebugJavaWithJavac/classes", excludes: fileFilter) + def debugTree = fileTree(dir: "${buildDir}/intermediates/javac/debug/classes", excludes: fileFilter) def mainSrc = "${project.projectDir}/src/main/java" sourceDirectories.setFrom(files([mainSrc]))