Skip to content

Commit 86790a1

Browse files
committed
Add support for AGP 3.2.0-alpha07 (AndroidUnitTest.assetsCollection changed types)
1 parent 715344a commit 86790a1

File tree

3 files changed

+13
-7
lines changed
  • android-junit5-tests/src/test/kotlin/de/mannodermaus/gradle/plugins/junit5
  • android-junit5/src/main

3 files changed

+13
-7
lines changed

android-junit5-tests/src/test/kotlin/de/mannodermaus/gradle/plugins/junit5/PluginSpec.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,11 @@ class PluginSpec : Spek({
583583
// Since the location of intermediate class files changed in different
584584
// versions of the Android Gradle Plugin,
585585
// create each class file in multiple directories to remain compatible with all approaches
586+
// TODO Clean this mess up once the Android Gradle Plugin 3.2.0 finally decides on something. :|
586587
listOf(
587-
// AGP 3.2.0-alpha06 and above
588+
// AGP 3.2.0-alpha07 and above
589+
"build/intermediates/javac/debug/compileDebugJavaWithJavac/classes",
590+
// AGP 3.2.0-alpha06
588591
"build/intermediates/artifact_transform/compileDebugJavaWithJavac/classes",
589592
// AGP 3.2.0-alpha04 and above
590593
"build/intermediates/artifact_transform/javac/debug/classes",
@@ -597,7 +600,9 @@ class PluginSpec : Spek({
597600
}
598601

599602
listOf(
600-
// AGP 3.2.0-alpha06 and above
603+
// AGP 3.2.0-alpha07 and above
604+
"build/intermediates/javac/release/compileReleaseJavaWithJavac/classes",
605+
// AGP 3.2.0-alpha06
601606
"build/intermediates/artifact_transform/compileReleaseJavaWithJavac/classes",
602607
// AGP 3.2.0-alpha04 and above
603608
"build/intermediates/artifact_transform/javac/release/classes",

android-junit5/src/main/groovy/de/mannodermaus/gradle/plugins/junit5/GroovyInterop.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class GroovyInterop {
5151

5252
/**
5353
* Obtains the Java output directory of the provided VariantScope in a safe manner.
54+
* TODO Clean this mess up once the Android Gradle Plugin 3.2.0 finally decides on something. :|
5455
*
5556
* @because In Android Gradle Plugin 3.2.0-alpha02, the original method was removed
5657
* @param variant VariantScope to retrieve the Java output directory from
@@ -64,7 +65,7 @@ class GroovyInterop {
6465
.get()
6566
if (scope.buildArtifactsHolder.hasArtifact(artifactType)) {
6667
// 3.2.0-alpha04 and above:
67-
// Java outputs are moved into an "artifacts_transform" subdirectory
68+
// Java outputs are moved into a subdirectory exposed by the compilation BuildArtifact
6869
return scope.buildArtifactsHolder.getArtifactFiles(artifactType).files
6970
} else {
7071
// 3.2.0-alpha02 and above:

android-junit5/src/main/kotlin/de/mannodermaus/gradle/plugins/junit5/tasks/UnitTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ open class AndroidJUnit5UnitTest : JavaExec(), JUnit5UnitTest {
5353

5454
@InputFiles
5555
@Optional
56-
var resCollection: FileCollection? = null
56+
var resCollection: Set<File>? = null
5757

5858
@InputFiles
5959
@Optional
60-
var assetsCollection: FileCollection? = null
60+
var assetsCollection: Set<File>? = null
6161

6262
override val isRunAllTask = false
6363

@@ -182,8 +182,8 @@ open class AndroidJUnit5UnitTest : JavaExec(), JUnit5UnitTest {
182182
junit5: AndroidJUnitPlatformExtension) {
183183
// Connect to the default unit test task
184184
val variantUnitTestTask = this.getDefaultJUnit4Task()
185-
task.resCollection = variantUnitTestTask.resCollection
186-
task.assetsCollection = variantUnitTestTask.assetsCollection
185+
task.resCollection = variantUnitTestTask.resCollection?.files
186+
task.assetsCollection = variantUnitTestTask.assetsCollection?.files
187187

188188
variantUnitTestTask.enabled = junit5.enableStandardTestTask
189189
variantUnitTestTask.dependsOn(task)

0 commit comments

Comments
 (0)