Skip to content

Commit 50f5e27

Browse files
committed
AGP 8.12, 8.13 RC1, 9.0 Alpha 1
Also update the build script of our test projects to address deprecations and, more importantly, deprecated APIs that were removed in AGP 9.0
1 parent bf38a6b commit 50f5e27

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ enum class SupportedAgp(
1919
AGP_8_9("8.9.3", gradle = "8.11.1"),
2020
AGP_8_10("8.10.1", gradle = "8.11.1"),
2121
AGP_8_11("8.11.1", gradle = "8.13"),
22-
AGP_8_12("8.12.0-rc01", gradle = "8.13"),
23-
AGP_8_13("8.13.0-alpha02", gradle = "8.13")
22+
AGP_8_12("8.12.0", gradle = "8.13"),
23+
AGP_8_13("8.13.0-rc01", gradle = "8.13"),
24+
AGP_9_0("9.0.0-alpha01", gradle = "9.0.0"),
2425
;
2526

2627
companion object {

plugin/android-junit5/src/test/resources/test-projects/build.gradle.kts.template

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77
// The individual configuration of each test depends on the config.toml file,
88
// located in the sub-folder next to its source code.
99

10+
import com.android.build.api.variant.HasUnitTestBuilder
1011
import org.gradle.api.tasks.testing.Test
1112
import org.gradle.api.tasks.testing.logging.TestLogEvent
13+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1214

1315
val androidGradlePluginVersion: String = "{{ AGP_VERSION }}"
1416
val kotlinVersion: String = "{{ KOTLIN_VERSION }}"
1517
val junitJupiterVersion: String = "{{ JUNIT_JUPITER_VERSION }}"
1618
val junit5AndroidLibsVersion: String = "{{ JUNIT5_ANDROID_LIBS_VERSION }}"
19+
val javaVersion = JavaVersion.VERSION_17
1720

1821
buildscript {
1922
repositories {
@@ -42,7 +45,7 @@ plugins {
4245
}
4346

4447
// Double-checking the integrity of the AGP version under test
45-
val version = com.android.builder.model.Version.ANDROID_GRADLE_PLUGIN_VERSION
48+
val version = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
4649
if (version != "${androidGradlePluginVersion}") {
4750
throw IllegalStateException("Incorrect AGP version. Expected ${androidGradlePluginVersion}, got $version")
4851
}
@@ -58,23 +61,23 @@ repositories {
5861
}
5962

6063
android {
61-
val minSdk: Int = {{ MIN_SDK_VERSION }}
64+
val minSdkVersion: Int = {{ MIN_SDK_VERSION }}
6265

6366
{% if OVERRIDE_SDK_VERSION %}
6467
val compileSdk: String = "android-{{ OVERRIDE_SDK_VERSION }}"
65-
val targetSdk: Int = {{ OVERRIDE_SDK_VERSION }}
68+
val targetSdkVersion: Int = {{ OVERRIDE_SDK_VERSION }}
6669
{% else %}
6770
val compileSdk: String = "{{ COMPILE_SDK_VERSION }}"
68-
val targetSdk: Int = {{ TARGET_SDK_VERSION }}
71+
val targetSdkVersion: Int = {{ TARGET_SDK_VERSION }}
6972
{% endif %}
7073

7174
compileSdkVersion("${compileSdk}")
7275

7376
defaultConfig {
7477
namespace = "de.mannodermaus.app"
7578

76-
minSdkVersion(minSdk)
77-
targetSdkVersion(targetSdk)
79+
minSdk = minSdkVersion
80+
targetSdk = targetSdkVersion
7881

7982
{% if INCLUDE_ANDROID_RESOURCES %}
8083
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
@@ -88,27 +91,19 @@ android {
8891
{% endif %}
8992
}
9093

91-
val javaVersion = JavaVersion.VERSION_17
92-
9394
compileOptions {
9495
sourceCompatibility = javaVersion
9596
targetCompatibility = javaVersion
9697
}
9798

98-
{% if USE_KOTLIN %}
99-
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
100-
kotlinOptions.jvmTarget = javaVersion.toString()
101-
}
102-
{% endif %}
103-
10499
{% if USE_FLAVORS %}
105100
flavorDimensions("environment")
106101
productFlavors {
107102
register("free") {
108-
setDimension("environment")
103+
dimension = "environment"
109104
}
110105
register("paid") {
111-
setDimension("environment")
106+
dimension = "environment"
112107
}
113108
}
114109
{% endif %}
@@ -131,6 +126,14 @@ android {
131126
}
132127
}
133128

129+
{% if USE_KOTLIN %}
130+
kotlin {
131+
compilerOptions {
132+
jvmTarget = JvmTarget.fromTarget(javaVersion.toString())
133+
}
134+
}
135+
{% endif %}
136+
134137
junitPlatform {
135138
{% if USE_JACOCO %}
136139
jacocoOptions {
@@ -144,8 +147,8 @@ junitPlatform {
144147

145148
{% for type in DISABLE_TESTS_FOR_BUILD_TYPES %}
146149
androidComponents {
147-
beforeVariants(selector().withBuildType("{{ type }}")) { variant ->
148-
variant.enableUnitTest = false
150+
beforeVariants(selector().withBuildType("{{ type }}")) { variantBuilder ->
151+
(variantBuilder as HasUnitTestBuilder).enableUnitTest = false
149152
}
150153
}
151154
{% end %}

0 commit comments

Comments
 (0)