diff --git a/src/main/groovy/org/gradle/android/workarounds/JdkImageWorkaround.groovy b/src/main/groovy/org/gradle/android/workarounds/JdkImageWorkaround.groovy index 83553cda..c6b169e9 100644 --- a/src/main/groovy/org/gradle/android/workarounds/JdkImageWorkaround.groovy +++ b/src/main/groovy/org/gradle/android/workarounds/JdkImageWorkaround.groovy @@ -36,7 +36,7 @@ import java.util.stream.Stream * than Java 9. This normalizes out minor inconsequential differences between JDKs used to generate the * custom runtime and improve cache hits between environments. */ -@AndroidIssue(introducedIn = "7.1.0", fixedIn = ['7.4.0-alpha07'], link = "https://issuetracker.google.com/u/1/issues/234820480") +@AndroidIssue(introducedIn = "7.1.0", link = "https://issuetracker.google.com/u/1/issues/234820480") class JdkImageWorkaround implements Workaround { static final String WORKAROUND_ENABLED_PROPERTY = "org.gradle.android.cache-fix.JdkImageWorkaround.enabled" @@ -63,15 +63,9 @@ class JdkImageWorkaround implements Workaround { } } + // Configuration for Old Variant API will drop in AGP 9. We will need to use a different + // approach to retrieve the variants using the new Variant API. private static void applyToAllAndroidVariants(Project project, Closure configureVariant) { - if (Versions.CURRENT_ANDROID_VERSION <= VersionNumber.parse("7.4.0-alpha01")) { - applyToAllAndroidVariantsWithOldVariantApi(project, configureVariant) - } else { - applyToAllAndroidVariantsWithNewVariantApi(project, configureVariant) - } - } - - private static void applyToAllAndroidVariantsWithOldVariantApi(Project project, Closure configureVariant) { project.plugins.withId("com.android.application") { def android = project.extensions.findByName("android") android.unitTestVariants.all(configureVariant) @@ -85,12 +79,6 @@ class JdkImageWorkaround implements Workaround { } } - private static void applyToAllAndroidVariantsWithNewVariantApi(Project project, Closure configureVariant) { - def androidComponents = project.extensions.findByName("androidComponents") - def selector = androidComponents.selector() - androidComponents.onVariants(selector.all(), configureVariant) - } - static def applyRuntimeClasspathNormalization(Project project) { project.normalization { handler -> handler.runtimeClasspath { @@ -174,6 +162,7 @@ class JdkImageWorkaround implements Workaround { interface Parameters extends TransformParameters { @Internal Provider getJavaHome() + void setJavaHome(Provider javaHome) } @@ -240,7 +229,7 @@ class JdkImageWorkaround implements Workaround { private static String serializeRequires(ModuleDescriptor.Requires requires) { String requireString - if (! requires.compiledVersion().empty) { + if (!requires.compiledVersion().empty) { requireString = requires.name() + " (@" + requires.compiledVersion() + ")" } else { requireString = requires.name() diff --git a/src/test/groovy/org/gradle/android/WorkaroundTest.groovy b/src/test/groovy/org/gradle/android/WorkaroundTest.groovy index abf39268..f43f2387 100644 --- a/src/test/groovy/org/gradle/android/WorkaroundTest.groovy +++ b/src/test/groovy/org/gradle/android/WorkaroundTest.groovy @@ -12,9 +12,9 @@ class WorkaroundTest extends Specification { workarounds.collect { it.class.simpleName.replaceAll(/Workaround/, "") }.sort() == expectedWorkarounds.sort() where: androidVersion | expectedWorkarounds - "8.1.0-alpha01" | ['MergeSourceSetFolders', 'RoomSchemaLocation', 'ZipMergingTask'] - "8.0.0-beta01" | ['MergeSourceSetFolders', 'RoomSchemaLocation', 'ZipMergingTask'] - "7.4.0" | ['MergeSourceSetFolders', 'RoomSchemaLocation', 'ZipMergingTask'] + "8.1.0-alpha01" | ['MergeSourceSetFolders', 'RoomSchemaLocation', 'ZipMergingTask', 'JdkImage'] + "8.0.0-beta01" | ['MergeSourceSetFolders', 'RoomSchemaLocation', 'ZipMergingTask', 'JdkImage'] + "7.4.0" | ['MergeSourceSetFolders', 'RoomSchemaLocation', 'ZipMergingTask', 'JdkImage'] "7.3.1" | ['MergeSourceSetFolders', 'RoomSchemaLocation', 'ZipMergingTask', 'JdkImage'] "7.2.2" | ['MergeSourceSetFolders', 'RoomSchemaLocation', 'ZipMergingTask', 'JdkImage'] "7.1.3" | ['BundleLibraryClasses', 'CompileLibraryResources', 'DataBindingMergeDependencyArtifacts', 'LibraryJniLibs', 'MergeNativeLibs', 'MergeSourceSetFolders', 'RoomSchemaLocation', 'StripDebugSymbols', 'ZipMergingTask', 'JdkImage']