Skip to content

Commit f6a4f2b

Browse files
authored
JUnit 5.5.1 & Better Compat implementation for class directories (#182)
* Update to Gradle 5.5.1 * Update to JUnit 5.5.1 * Replace compat implementation for class folders The latest AGP doesn't use the Artifact Files API anymore, therefore another way needed to be found. Using the official javaCompile property works more reliable and shouldn't break in the future, unless Google even deprecates the javaCompileProvider. * Still use 3.4.x as stable plugin foundation for now
1 parent e0c49e7 commit f6a4f2b

File tree

9 files changed

+67
-70
lines changed

9 files changed

+67
-70
lines changed

buildSrc/src/main/kotlin/Artifacts.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ object Artifacts {
3535
platform = Java,
3636
groupId = "de.mannodermaus.gradle.plugins",
3737
artifactId = "android-junit5",
38-
currentVersion = "1.5.0.1-SNAPSHOT",
38+
currentVersion = "1.5.1.0-SNAPSHOT",
3939
latestStableVersion = "1.5.0.0",
4040
license = license,
4141
description = "Unit Testing with JUnit 5 for Android."

buildSrc/src/main/kotlin/Versions.kt

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,84 +7,84 @@ import kotlin.String
77
*
88
* YOU are responsible for updating manually the dependency version. */
99
object Versions {
10-
const val espresso_core: String = "3.2.0"
10+
const val espresso_core: String = "3.2.0"
1111

12-
const val androidx_test_core: String = "1.2.0"
13-
const val androidx_test_monitor: String = "1.2.0"
14-
const val androidx_test_runner: String = "1.2.0"
12+
const val androidx_test_core: String = "1.2.0"
13+
const val androidx_test_monitor: String = "1.2.0"
14+
const val androidx_test_runner: String = "1.2.0"
1515

16-
const val aapt2: String = "3.2.1-4818971"
16+
const val aapt2: String = "3.2.1-4818971"
1717

18-
const val com_android_tools_build_gradle: String = "3.4.1"
19-
const val com_android_tools_build_gradle_32x: String = "3.2.1"
20-
const val com_android_tools_build_gradle_33x: String = "3.3.2"
21-
const val com_android_tools_build_gradle_34x: String = "3.4.1"
22-
const val com_android_tools_build_gradle_35x: String = "3.5.0-beta05"
23-
const val com_android_tools_build_gradle_36x: String = "3.6.0-alpha04"
18+
const val com_android_tools_build_gradle_32x: String = "3.2.1"
19+
const val com_android_tools_build_gradle_33x: String = "3.3.2"
20+
const val com_android_tools_build_gradle_34x: String = "3.4.2"
21+
const val com_android_tools_build_gradle_35x: String = "3.5.0-rc01"
22+
const val com_android_tools_build_gradle_36x: String = "3.6.0-alpha05"
23+
const val com_android_tools_build_gradle: String = "3.4.2"
2424

25-
const val lint_gradle: String = "26.2.1"
25+
const val lint_gradle: String = "26.2.1"
2626

27-
const val stream: String = "1.2.1"
27+
const val stream: String = "1.2.1"
2828

29-
const val gradle_versions_plugin: String = "0.20.0"
29+
const val gradle_versions_plugin: String = "0.20.0"
3030

31-
const val android_maven_gradle_plugin: String = "2.1"
31+
const val android_maven_gradle_plugin: String = "2.1"
3232

33-
const val dokka: String = "0.9.18"
33+
const val dokka: String = "0.9.18"
3434

35-
const val java_semver: String = "0.9.0"
35+
const val java_semver: String = "0.9.0"
3636

37-
const val gradle_bintray_plugin: String = "1.8.4"
37+
const val gradle_bintray_plugin: String = "1.8.4"
3838

39-
const val truth: String = "0.43"
39+
const val truth: String = "0.43"
4040

41-
const val truth_android: String = "1.1.0"
41+
const val truth_android: String = "1.1.0"
4242

43-
const val commons_io: String = "2.6"
43+
const val commons_io: String = "2.6"
4444

45-
const val commons_lang: String = "2.6"
45+
const val commons_lang: String = "2.6"
4646

47-
const val de_fayard_buildsrcversions_gradle_plugin: String = "0.3.2"
47+
const val de_fayard_buildsrcversions_gradle_plugin: String = "0.3.2"
4848

49-
const val android_junit5: String = "1.3.2.0-SNAPSHOT"
49+
const val android_junit5: String = "1.3.2.0-SNAPSHOT"
5050

51-
const val de_mannodermaus_junit5: String = "0.2.2"
51+
const val de_mannodermaus_junit5: String = "0.2.2"
5252

53-
const val android_maven_publish: String = "3.6.2"
53+
const val android_maven_publish: String = "3.6.2"
5454

55-
const val junit: String = "4.12"
55+
const val junit: String = "4.12"
5656

57-
const val assertj_core: String = "3.11.1"
57+
const val assertj_core: String = "3.11.1"
5858

59-
const val org_jetbrains_kotlin: String = "1.3.21"
59+
const val org_jetbrains_kotlin: String = "1.3.21"
6060

61-
const val org_jetbrains_spek: String = "1.2.1"
61+
const val org_jetbrains_spek: String = "1.2.1"
6262

63-
const val org_jacoco_agent: String = "0.8.2"
64-
const val org_jacoco_ant: String = "0.8.2"
63+
const val org_jacoco_agent: String = "0.8.2"
64+
const val org_jacoco_ant: String = "0.8.2"
6565

66-
const val junit_pioneer: String = "0.2.2" // available: "0.3.0"
66+
const val junit_pioneer: String = "0.2.2" // available: "0.3.0"
6767

68-
const val org_junit_jupiter: String = "5.5.0"
68+
const val org_junit_jupiter: String = "5.5.1"
6969

70-
const val org_junit_platform: String = "1.5.0"
70+
const val org_junit_platform: String = "1.5.1"
7171

72-
const val junit_vintage_engine: String = "5.5.0"
72+
const val junit_vintage_engine: String = "5.5.1"
7373

74-
const val mockito_core: String = "2.19.0" // available: "2.23.4"
74+
const val mockito_core: String = "2.19.0" // available: "2.23.4"
7575

76-
/**
77-
*
78-
* To update Gradle, edit the wrapper file at path:
79-
* ./gradle/wrapper/gradle-wrapper.properties
80-
*/
81-
object Gradle {
82-
const val runningVersion: String = "5.0"
76+
/**
77+
*
78+
* To update Gradle, edit the wrapper file at path:
79+
* ./gradle/wrapper/gradle-wrapper.properties
80+
*/
81+
object Gradle {
82+
const val runningVersion: String = "5.0"
8383

84-
const val currentVersion: String = "5.0"
84+
const val currentVersion: String = "5.0"
8585

86-
const val nightlyVersion: String = "5.2-20181230000028+0000"
86+
const val nightlyVersion: String = "5.2-20181230000028+0000"
8787

88-
const val releaseCandidate: String = "5.1-rc-3"
89-
}
88+
const val releaseCandidate: String = "5.1-rc-3"
89+
}
9090
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package de.mannodermaus.gradle.plugins.junit5
22

33
import com.android.annotations.NonNull
44
import com.android.build.gradle.api.BaseVariant
5-
import com.android.build.gradle.internal.scope.InternalArtifactType
6-
import com.android.build.gradle.internal.scope.VariantScope
75
import com.android.build.gradle.internal.variant.BaseVariantData
86
import com.android.builder.core.VariantTypeImpl
97
import org.gradle.api.Project
@@ -33,19 +31,18 @@ class GroovyInterop {
3331
}
3432

3533
/**
36-
* Obtains the Java artifact files of the provided VariantScope in a safe manner.
34+
* Obtains the Java class directory for the provided variant in a safe manner.
3735
*
38-
* @because Some scopes, especially for Jacoco, don't have the files at hand through this API
39-
* @param variant VariantScope to retrieve the Java artifact files from
36+
* @because Recent versions of the Android Gradle Plugin have moved to a Provider-based architecture, deprecating the old direct accessors for tasks.
37+
* @param variant Variant to retrieve the destination directory for class files from
4038
* @return That file
4139
*/
4240
@NonNull
43-
static Set<File> variantScope_getJavacArtifactFiles(VariantScope scope) {
44-
if (scope.artifacts.hasArtifact(InternalArtifactType.JAVAC)) {
45-
return scope.artifacts.getArtifactFiles(InternalArtifactType.JAVAC).files
41+
static File baseVariant_javaCompileDestinationDir(BaseVariant variant) {
42+
if (variant.hasProperty("javaCompileProvider")) {
43+
return variant.javaCompileProvider.get().destinationDir
4644
} else {
47-
return [new File(scope.globalScope.intermediatesDir,
48-
"/classes/" + scope.variantConfiguration.dirName)]
45+
return variant.javaCompile.destinationDir
4946
}
5047
}
5148

plugin/android-junit5/src/main/kotlin/de/mannodermaus/gradle/plugins/junit5/Interop.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package de.mannodermaus.gradle.plugins.junit5
22

33
import com.android.build.gradle.api.BaseVariant
4-
import com.android.build.gradle.internal.scope.VariantScope
54
import com.android.build.gradle.internal.variant.BaseVariantData
65
import org.gradle.api.Project
76
import org.gradle.testing.jacoco.tasks.JacocoReportBase
@@ -17,8 +16,8 @@ import java.io.File
1716
val BaseVariant.variantData: BaseVariantData
1817
get() = GroovyInterop.baseVariant_variantData(this)
1918

20-
val VariantScope.safeJavacArtifactFiles: Set<File>
21-
get() = GroovyInterop.variantScope_getJavacArtifactFiles(this)
19+
val BaseVariant.safeJavaCompileDestinationDir: File
20+
get() = GroovyInterop.baseVariant_javaCompileDestinationDir(this)
2221

2322
/*
2423
* Compatibility methods for multiple Gradle versions.

plugin/android-junit5/src/main/kotlin/de/mannodermaus/gradle/plugins/junit5/providers/Java.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ package de.mannodermaus.gradle.plugins.junit5.providers
22

33
import com.android.build.gradle.api.BaseVariant
44
import de.mannodermaus.gradle.plugins.junit5.internal.unitTestVariant
5-
import de.mannodermaus.gradle.plugins.junit5.safeJavacArtifactFiles
6-
import de.mannodermaus.gradle.plugins.junit5.variantData
5+
import de.mannodermaus.gradle.plugins.junit5.safeJavaCompileDestinationDir
76

87
/**
98
* Default Provider implementation for Java-based test root directories.
@@ -25,5 +24,5 @@ class JavaDirectoryProvider(private val variant: BaseVariant) : DirectoryProvide
2524
.toSet()
2625

2726
private fun classFoldersOf(variant: BaseVariant) =
28-
variant.variantData.scope.safeJavacArtifactFiles
27+
setOf(variant.safeJavaCompileDestinationDir)
2928
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,8 @@ class PluginSpec : Spek({
387387
// TODO Clean this mess up once the Android Gradle Plugin 3.2.0 finally decides on something. :|
388388
listOf(
389389
"build/intermediates/javac/debug/compileDebugJavaWithJavac/classes",
390-
"build/intermediates/classes/debug").forEach { folder ->
390+
"build/intermediates/classes/debug",
391+
"build/intermediates/javac/debug/classes").forEach { folder ->
391392
project.file(folder).mkdirs()
392393
project.file("$folder/R.class").createNewFile()
393394
project.file("$folder/FirstFile.class").createNewFile()
@@ -396,7 +397,8 @@ class PluginSpec : Spek({
396397

397398
listOf(
398399
"build/intermediates/javac/release/compileReleaseJavaWithJavac/classes",
399-
"build/intermediates/classes/release").forEach { folder ->
400+
"build/intermediates/classes/release",
401+
"build/intermediates/javac/release/classes").forEach { folder ->
400402
project.file(folder).mkdirs()
401403
project.file("$folder/R.class").createNewFile()
402404
project.file("$folder/SecondFile.class").createNewFile()

plugin/gradlew

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# you may not use this file except in compliance with the License.
88
# You may obtain a copy of the License at
99
#
10-
# http://www.apache.org/licenses/LICENSE-2.0
10+
# https://www.apache.org/licenses/LICENSE-2.0
1111
#
1212
# Unless required by applicable law or agreed to in writing, software
1313
# distributed under the License is distributed on an "AS IS" BASIS,

plugin/gradlew.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
@rem you may not use this file except in compliance with the License.
66
@rem You may obtain a copy of the License at
77
@rem
8-
@rem http://www.apache.org/licenses/LICENSE-2.0
8+
@rem https://www.apache.org/licenses/LICENSE-2.0
99
@rem
1010
@rem Unless required by applicable law or agreed to in writing, software
1111
@rem distributed under the License is distributed on an "AS IS" BASIS,

0 commit comments

Comments
 (0)