From 4e845019852c5548b1b78b0d5a0fc55985255de9 Mon Sep 17 00:00:00 2001 From: jawnpaul Date: Thu, 28 May 2026 17:34:58 -0400 Subject: [PATCH 1/3] Add AGP 9 compatibility by migrating to public DSL types Replace the internal `BaseAppModuleExtension` (removed in AGP 9) with the stable public `ApplicationExtension`, migrate `LibraryExtension` to the `com.android.build.api.dsl` package, and replace the removed `applicationVariants`/`libraryVariants` APIs with direct reads of `productFlavors` and `buildTypes`. Bump the compileOnly AGP dependency to 9.0.0 and update the minimum requirement in the README accordingly. --- README.md | 2 +- gradle/libs.versions.toml | 2 +- .../hyperdevs/poeditor/gradle/PoEditorPlugin.kt | 16 +++++++--------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index b66529b..5064caf 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ It also provides a built-in syntax to handle placeholders to enhance the already ## Minimum requirements * Gradle 8.2 or above -* Android Gradle Plug-in 8.0 or above +* Android Gradle Plug-in 9.0 or above ## Setting Up In your main `build.gradle`, add [jitpack.io](https://jitpack.io/) repository in the `buildscript` block and include the plug-in as a dependency: diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 39bc16f..7841deb 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,7 +8,7 @@ retrofit = "2.9.0" okhttp = "4.12.0" [libraries] -android-buildTools = "com.android.tools.build:gradle:8.1.2" +android-buildTools = "com.android.tools.build:gradle:9.0.0" kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" } diff --git a/src/main/kotlin/com/hyperdevs/poeditor/gradle/PoEditorPlugin.kt b/src/main/kotlin/com/hyperdevs/poeditor/gradle/PoEditorPlugin.kt index 44ee4de..0ea3927 100644 --- a/src/main/kotlin/com/hyperdevs/poeditor/gradle/PoEditorPlugin.kt +++ b/src/main/kotlin/com/hyperdevs/poeditor/gradle/PoEditorPlugin.kt @@ -18,12 +18,12 @@ package com.hyperdevs.poeditor.gradle +import com.android.build.api.dsl.ApplicationExtension +import com.android.build.api.dsl.LibraryExtension import com.android.build.api.variant.ApplicationAndroidComponentsExtension import com.android.build.api.variant.LibraryAndroidComponentsExtension import com.android.build.gradle.AppPlugin -import com.android.build.gradle.LibraryExtension import com.android.build.gradle.LibraryPlugin -import com.android.build.gradle.internal.dsl.BaseAppModuleExtension import com.hyperdevs.poeditor.gradle.extensions.registerNewTask import com.hyperdevs.poeditor.gradle.tasks.ImportPoEditorStringsTask import com.hyperdevs.poeditor.gradle.utils.* @@ -81,7 +81,7 @@ class PoEditorPlugin : Plugin { // Add android.poEditorConfig extension container so we can set-up flavors and build types // configurations with Android app modules. val configsExtensionContainer = project.container() - val androidExtension = project.the() + val androidExtension = project.the() val androidComponentsExtension = project.the() (androidExtension as ExtensionAware).extensions.add(POEDITOR_CONFIG_NAME, configsExtensionContainer) @@ -103,9 +103,8 @@ class PoEditorPlugin : Plugin { project.afterEvaluate { val allPossibleConfigNames: Set by lazy { - androidExtension.applicationVariants.flatMapTo(mutableSetOf()) { - listOf(it.buildType.name) + it.productFlavors.map { it.name } - } + (androidExtension.productFlavors.map { it.name } + + androidExtension.buildTypes.map { it.name }).toSet() } verifyAndLinkTasks(configsExtensionContainer, @@ -142,9 +141,8 @@ class PoEditorPlugin : Plugin { project.afterEvaluate { val allPossibleConfigNames: Set by lazy { - androidExtension.libraryVariants.flatMapTo(mutableSetOf()) { - listOf(it.buildType.name) + it.productFlavors.map { it.name } - } + (androidExtension.productFlavors.map { it.name } + + androidExtension.buildTypes.map { it.name }).toSet() } verifyAndLinkTasks(configsExtensionContainer, From b150e4729e65738a51dd082fc21407ceb61a9f28 Mon Sep 17 00:00:00 2001 From: jawnpaul Date: Thu, 28 May 2026 18:07:58 -0400 Subject: [PATCH 2/3] =?UTF-8?q?Replace=20`defaultResPath.getOrElse(getReso?= =?UTF-8?q?urceDirectory(project,=20=E2=80=A6))`=20with=20`defaultResPath.?= =?UTF-8?q?get()`.=20The=20fallback=20was=20dead=20code=20=E2=80=94=20defa?= =?UTF-8?q?ultResPath=20always=20carries=20a=20value=20set=20at=20configur?= =?UTF-8?q?ation=20time=20=E2=80=94=20but=20Kotlin's=20eager=20argument=20?= =?UTF-8?q?evaluation=20caused=20`Task.project`=20to=20be=20accessed=20at?= =?UTF-8?q?=20execution=20time,=20which=20Gradle's=20configuration=20cache?= =?UTF-8?q?=20forbids.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../poeditor/gradle/tasks/ImportPoEditorStringsTask.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/kotlin/com/hyperdevs/poeditor/gradle/tasks/ImportPoEditorStringsTask.kt b/src/main/kotlin/com/hyperdevs/poeditor/gradle/tasks/ImportPoEditorStringsTask.kt index 4d06fbe..956990c 100644 --- a/src/main/kotlin/com/hyperdevs/poeditor/gradle/tasks/ImportPoEditorStringsTask.kt +++ b/src/main/kotlin/com/hyperdevs/poeditor/gradle/tasks/ImportPoEditorStringsTask.kt @@ -26,7 +26,6 @@ import com.hyperdevs.poeditor.gradle.network.api.FilterType import com.hyperdevs.poeditor.gradle.network.api.OrderType import com.hyperdevs.poeditor.gradle.utils.DEFAULT_PLUGIN_NAME import com.hyperdevs.poeditor.gradle.utils.POEDITOR_CONFIG_NAME -import com.hyperdevs.poeditor.gradle.utils.getResourceDirectory import org.gradle.api.DefaultTask import org.gradle.api.provider.ListProperty import org.gradle.api.provider.MapProperty @@ -204,9 +203,7 @@ abstract class ImportPoEditorStringsTask @Inject constructor() : DefaultTask() { projectId = projectId, defaultLang = defaultLang.getOrElse(DefaultValues.DEFAULT_LANG), languages = languages.getOrElse(DefaultValues.LANGUAGES), - resDirPath = defaultResPath.getOrElse(getResourceDirectory( - project, DefaultValues.MAIN_CONFIG_NAME).absolutePath - ), + resDirPath = defaultResPath.get(), filters = filters.getOrElse(DefaultValues.FILTERS).map { FilterType.from(it) }, order = OrderType.from(order.getOrElse(DefaultValues.ORDER_TYPE.lowercase())), tags = tags.getOrElse(DefaultValues.TAGS), From 8cf4a35e7462772cef129049d157f219c892152d Mon Sep 17 00:00:00 2001 From: jawnpaul Date: Thu, 28 May 2026 18:56:37 -0400 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06c52a9..939eb95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,13 +24,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - No new features! ### Changed -- No changed features! +- Migrate to AGP 9 public DSL types for compatibility with Gradle 9 and AGP 9. ### Deprecated - No deprecated features! ### Removed - No removed features! ### Fixed -- No fixed issues! +- Fix Gradle configuration cache incompatibility in `ImportPoEditorStringsTask`: accessing `Task.project` at execution time is no longer supported with the configuration cache enabled by default in Gradle 9. ### Security - No security issues fixed!