Skip to content

Commit

Permalink
Fix java classes being skipped in AGP >= 3.4 (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeppeman authored and vanniktech committed Jan 13, 2020
1 parent 5461b09 commit 0b2f3d6
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ class GenerationPlugin implements Plugin<Project> {

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)) {
Expand Down Expand Up @@ -373,7 +374,7 @@ class GenerationPlugin implements Plugin<Project> {
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')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 0b2f3d6

Please sign in to comment.