Skip to content

Commit 9398fe7

Browse files
committed
Allow compileSdk overriding for old AGP versions
AGP 8.0 doesn't work with compileSdk=35, so force it to the maximum it does support. Also, remove optionality from the Gradle requirement, since each AGP version needs its own anyway
1 parent 51eb3d6 commit 9398fe7

File tree

8 files changed

+192
-167
lines changed

8 files changed

+192
-167
lines changed

build-logic/src/main/kotlin/Environment.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import java.util.Properties
66

77
enum class SupportedAgp(
88
val version: String,
9-
val gradle: String? = null
9+
val gradle: String,
10+
val compileSdk: Int? = null
1011
) {
11-
AGP_8_0("8.0.2", gradle = "8.0"),
12+
AGP_8_0("8.0.2", gradle = "8.0", compileSdk = 33),
1213
AGP_8_1("8.1.4", gradle = "8.0"),
1314
AGP_8_2("8.2.2", gradle = "8.2"),
1415
AGP_8_3("8.3.2", gradle = "8.4"),

build-logic/src/main/kotlin/Tasks.kt

+11-4
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,28 @@ fun Project.configureTestResources() {
3434
"JUNIT5_ANDROID_LIBS_VERSION" to Artifacts.Instrumentation.Core.latestStableVersion,
3535

3636
// Collect all supported AGP versions into a single string.
37-
// This string is delimited with semicolons, and each of the separated values itself is a 3-tuple.
37+
// This string is delimited with semicolons, and each of the separated values itself is a 4-tuple.
3838
//
3939
// Example:
40-
// AGP_VERSIONS = 3.5|3.5.3|;3.6|3.6.3|6.4
40+
// AGP_VERSIONS = 3.5|3.5.3|;3.6|3.6.3|6.4;3.7|3.7.0|8.0|33
4141
//
4242
// Can be parsed into this list of values:
4343
// |___> Short: "3.5"
4444
// Full: "3.5.3"
45-
// Gradle Requirement: null
45+
// Gradle Requirement: ""
46+
// Compile SDK: null
4647
//
4748
// |___> Short: "3.6"
4849
// Full: "3.6.3"
4950
// Gradle Requirement: "6.4"
51+
// Compile SDK: null
52+
//
53+
// |___> Short: "3.7"
54+
// Full: "3.7.0"
55+
// Gradle Requirement: "8.0"
56+
// Compile SDK: 33
5057
"AGP_VERSIONS" to SupportedAgp.values().joinToString(separator = ";") { plugin ->
51-
"${plugin.shortVersion}|${plugin.version}|${plugin.gradle ?: ""}"
58+
"${plugin.shortVersion}|${plugin.version}|${plugin.gradle}|${plugin.compileSdk ?: ""}"
5259
}
5360
)
5461

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class ConfigurationCacheTests {
6969
private fun runGradle(project: File, task: String, expectSuccess: Boolean) =
7070
GradleRunner.create()
7171
.withProjectDir(project)
72-
.apply { agp.requiresGradle?.let(::withGradleVersion) }
72+
.withGradleVersion(agp.requiresGradle)
7373
.withArguments("--configuration-cache", "--stacktrace", task)
7474
.withPrunedPluginClasspath(agp)
7575
.run {

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

+7-6
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ class FunctionalTests {
7272
projectCreator.allSpecs.filterSpecs().map { spec ->
7373
dynamicTest(spec.name) {
7474
// Required for visibility inside IJ's logging console (display names are still bugged in the IDE)
75-
println("AGP: ${agp.version}, Project: ${spec.name}, Forced Gradle: ${agp.requiresGradle ?: "no"}")
75+
println(buildList {
76+
add("AGP: ${agp.version}")
77+
add("Project: ${spec.name}")
78+
add("Gradle: ${agp.requiresGradle}")
79+
agp.requiresCompileSdk?.let { add("SDK: $it") }
80+
}.joinToString(", "))
7681

7782
// Create a virtual project with the given settings & AGP version.
7883
// This call will throw a TestAbortedException if the spec is not eligible for this version,
@@ -147,11 +152,7 @@ class FunctionalTests {
147152
}
148153

149154
return GradleRunner.create()
150-
.apply {
151-
if (agpVersion.requiresGradle != null) {
152-
withGradleVersion(agpVersion.requiresGradle)
153-
}
154-
}
155+
.withGradleVersion(agpVersion.requiresGradle)
155156
.withArguments(arguments)
156157
.withPrunedPluginClasspath(agpVersion)
157158
}

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,16 @@ class TestEnvironment {
5151
junit5AndroidLibsVersion = envProps.getProperty(JUNIT5_ANDROID_PROP_NAME)
5252

5353
// Each entry in this string is separated by semicolon.
54-
// Within each entry, the pipe ("|") divides it into three properties
54+
// Within each entry, the pipe ("|") divides it into four properties
5555
val agpVersionsString = envProps.getProperty(AGP_VERSIONS_PROP_NAME)
5656
supportedAgpVersions = agpVersionsString.split(";")
5757
.map { entry -> entry.split("|") }
5858
.map { values ->
5959
TestedAgp(
6060
shortVersion = values[0],
6161
version = values[1],
62-
requiresGradle = values[2].ifEmpty { null }
62+
requiresGradle = values[2],
63+
requiresCompileSdk = values[3].toIntOrNull()
6364
)
6465
}
6566
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package de.mannodermaus.gradle.plugins.junit5.util
22

3-
data class TestedAgp(val shortVersion: String, val version: String, val requiresGradle: String?) {
3+
data class TestedAgp(
4+
val shortVersion: String,
5+
val version: String,
6+
val requiresGradle: String,
7+
val requiresCompileSdk: Int?
8+
) {
49
val fileKey: String = "agp${shortVersion.replace(".", "")}x"
510
}

0 commit comments

Comments
 (0)