From 0b2f3d6ee8d79b39128c103e2f7981ca979a3900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20=C3=85man?= Date: Mon, 13 Jan 2020 14:08:38 +0100 Subject: [PATCH] Fix java classes being skipped in AGP >= 3.4 (#166) --- .../junit/jacoco/GenerationPlugin.groovy | 5 +- .../junit/jacoco/GenerationTest.groovy | 73 ++++++++++++++++--- 2 files changed, 64 insertions(+), 14 deletions(-) diff --git a/src/main/groovy/com/vanniktech/android/junit/jacoco/GenerationPlugin.groovy b/src/main/groovy/com/vanniktech/android/junit/jacoco/GenerationPlugin.groovy index a234459..55b54f9 100644 --- a/src/main/groovy/com/vanniktech/android/junit/jacoco/GenerationPlugin.groovy +++ b/src/main/groovy/com/vanniktech/android/junit/jacoco/GenerationPlugin.groovy @@ -192,7 +192,8 @@ class GenerationPlugin implements Plugin { def classPaths = [ "**/intermediates/classes/${sourcePath}/**", - "**/intermediates/javac/${sourceName}/*/classes/**" // Android Gradle Plugin 3.2.x support. + "**/intermediates/javac/${sourceName}/*/classes/**", // Android Gradle Plugin 3.2.x support. + "**/intermediates/javac/${sourceName}/classes/**" // Android Gradle Plugin 3.4 and 3.5 support. ] if (isKotlinAndroid(subProject) || isKotlinMultiplatform(subProject)) { @@ -373,7 +374,7 @@ class GenerationPlugin implements Plugin { protected static boolean isAndroidFeature(final Project project) { return project.plugins.hasPlugin('com.android.feature') } - + protected static boolean isAndroidDynamicFeature(final Project project) { return project.plugins.hasPlugin('com.android.dynamic-feature') } diff --git a/src/test/groovy/com/vanniktech/android/junit/jacoco/GenerationTest.groovy b/src/test/groovy/com/vanniktech/android/junit/jacoco/GenerationTest.groovy index ca4a1de..99f3626 100644 --- a/src/test/groovy/com/vanniktech/android/junit/jacoco/GenerationTest.groovy +++ b/src/test/groovy/com/vanniktech/android/junit/jacoco/GenerationTest.groovy @@ -295,13 +295,26 @@ class GenerationTest { assert reports.html.destination.toPath() == Paths.get(project.buildDir.absolutePath, "/reports/jacoco/${flavor}${buildType.capitalize()}") assert classDirectories.getFrom().first().dir == project.file("build/") - assert contentEquals(classDirectories.getFrom().first().includes, ["**/intermediates/classes/${flavor}/${buildType}/**".toString(), "**/intermediates/javac/${flavor}${buildType.capitalize()}/*/classes/**".toString()]) + + assert contentEquals(classDirectories.getFrom().first().includes, [ + "**/intermediates/classes/${flavor}/${buildType}/**".toString(), + "**/intermediates/javac/${flavor}${buildType.capitalize()}/*/classes/**".toString(), + "**/intermediates/javac/${flavor}${buildType.capitalize()}/classes/**".toString() + ]) if (hasKotlin(project)) { - assert contentEquals(classDirectories.getFrom().first().includes, ["**/intermediates/classes/${flavor}/${buildType}/**".toString(), "**/intermediates/javac/${flavor}${buildType.capitalize()}/*/classes/**".toString(), - "**/tmp/kotlin-classes/${buildType}/**".toString(), "**/tmp/kotlin-classes/${flavor}${buildType.capitalize()}/**".toString()]) + assert contentEquals(classDirectories.getFrom().first().includes, [ + "**/intermediates/classes/${flavor}/${buildType}/**", + "**/intermediates/javac/${flavor}${buildType.capitalize()}/*/classes/**", + "**/intermediates/javac/${flavor}${buildType.capitalize()}/classes/**", + "**/tmp/kotlin-classes/${buildType}/**", + "**/tmp/kotlin-classes/${flavor}${buildType.capitalize()}/**"]) } else { - assert contentEquals(classDirectories.getFrom().first().includes, ["**/intermediates/classes/${flavor}/${buildType}/**".toString(), "**/intermediates/javac/${flavor}${buildType.capitalize()}/*/classes/**".toString()]) + assert contentEquals(classDirectories.getFrom().first().includes, [ + "**/intermediates/classes/${flavor}/${buildType}/**".toString(), + "**/intermediates/javac/${flavor}${buildType.capitalize()}/*/classes/**".toString(), + "**/intermediates/javac/${flavor}${buildType.capitalize()}/classes/**".toString() + ]) } assert taskDependsOn(task, "test${flavor.capitalize()}${buildType.capitalize()}UnitTest") @@ -345,9 +358,18 @@ class GenerationTest { assert classDirectories.getFrom().first().dir == project.file("build/") if (hasKotlin(project)) { - assert contentEquals(classDirectories.getFrom().first().includes, ['**/intermediates/classes/debug/**', '**/intermediates/javac/debug/*/classes/**', '**/tmp/kotlin-classes/debug/**']) + assert contentEquals(classDirectories.getFrom().first().includes, [ + '**/intermediates/classes/debug/**', + '**/intermediates/javac/debug/*/classes/**', + "**/intermediates/javac/debug/classes/**", + '**/tmp/kotlin-classes/debug/**' + ]) } else { - assert contentEquals(classDirectories.getFrom().first().includes, ['**/intermediates/classes/debug/**', '**/intermediates/javac/debug/*/classes/**']) + assert contentEquals(classDirectories.getFrom().first().includes, [ + '**/intermediates/classes/debug/**', + '**/intermediates/javac/debug/*/classes/**', + "**/intermediates/javac/debug/classes/**" + ]) } assert taskDependsOn(debugTask, 'testDebugUnitTest') @@ -385,9 +407,18 @@ class GenerationTest { assert classDirectories.getFrom().first().dir == project.file("build/") if (hasKotlin(project)) { - assert contentEquals(classDirectories.getFrom().first().includes, ['**/intermediates/classes/debug/**', '**/intermediates/javac/debug/*/classes/**', '**/tmp/kotlin-classes/debug/**']) + assert contentEquals(classDirectories.getFrom().first().includes, [ + '**/intermediates/classes/debug/**', + '**/intermediates/javac/debug/*/classes/**', + "**/intermediates/javac/debug/classes/**", + '**/tmp/kotlin-classes/debug/**' + ]) } else { - assert contentEquals(classDirectories.getFrom().first().includes, ['**/intermediates/classes/debug/**', '**/intermediates/javac/debug/*/classes/**']) + assert contentEquals(classDirectories.getFrom().first().includes, [ + '**/intermediates/classes/debug/**', + '**/intermediates/javac/debug/*/classes/**', + "**/intermediates/javac/debug/classes/**", + ]) } assert taskDependsOn(debugTaskCombined, 'testDebugUnitTest') @@ -429,9 +460,18 @@ class GenerationTest { assert classDirectories.getFrom().first().dir == project.file("build/") if (hasKotlin(project)) { - assert contentEquals(classDirectories.getFrom().first().includes, ['**/intermediates/classes/release/**', '**/intermediates/javac/release/*/classes/**', '**/tmp/kotlin-classes/release/**']) + assert contentEquals(classDirectories.getFrom().first().includes, [ + '**/intermediates/classes/release/**', + '**/intermediates/javac/release/*/classes/**', + "**/intermediates/javac/release/classes/**", + '**/tmp/kotlin-classes/release/**' + ]) } else { - assert contentEquals(classDirectories.getFrom().first().includes, ['**/intermediates/classes/release/**', '**/intermediates/javac/release/*/classes/**']) + assert contentEquals(classDirectories.getFrom().first().includes, [ + '**/intermediates/classes/release/**', + '**/intermediates/javac/release/*/classes/**', + "**/intermediates/javac/release/classes/**" + ]) } assert taskDependsOn(releaseTask, 'testReleaseUnitTest') @@ -470,9 +510,18 @@ class GenerationTest { assert classDirectories.getFrom().first().dir == project.file("build/") if (hasKotlin(project)) { - assert contentEquals(classDirectories.getFrom().first().includes, ['**/intermediates/classes/release/**', '**/intermediates/javac/release/*/classes/**', '**/tmp/kotlin-classes/release/**']) + assert contentEquals(classDirectories.getFrom().first().includes, [ + '**/intermediates/classes/release/**', + '**/intermediates/javac/release/*/classes/**', + "**/intermediates/javac/release/classes/**", + '**/tmp/kotlin-classes/release/**' + ]) } else { - assert contentEquals(classDirectories.getFrom().first().includes, ['**/intermediates/classes/release/**', '**/intermediates/javac/release/*/classes/**']) + assert contentEquals(classDirectories.getFrom().first().includes, [ + '**/intermediates/classes/release/**', + '**/intermediates/javac/release/*/classes/**', + "**/intermediates/javac/release/classes/**", + ]) } assert taskDependsOn(releaseTaskCombined, 'testReleaseUnitTest')