Add support for compileSdk 37 - #70
Draft
rahul-lohra wants to merge 9 commits into
Draft
Conversation
Contributor
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
Make the convention plugins usable by consumer projects that build on Android Gradle Plugin 9.x (required for
compileSdk/targetSdk = 37, Android 17), while remaining compatible with AGP 8 consumers.Current problem
The published plugin is compiled against AGP 8.11.1, where
com.android.build.api.dsl.CommonExtensionis generic (CommonExtension<*, *, *, *, *, *>) and exposes block-DSL functions (compileOptions {},testOptions {},sourceSets {},buildTypes {}).In AGP 9,
CommonExtensionis non-generic and those block-DSL functions were removed — only the getters remain (getCompileOptions(),getTestOptions(), …). As a result, when a project on AGP 9 applies these plugins, configuration fails at runtime:(
0.13.1's bytecode calls a method that no longer exists.) This blocks any consumer from moving to AGP 9 / compileSdk 37.Implementation
Bump compile-time AGP
8.11.1 → 9.1.1(gradle/libs.versions.toml) so the plugin compiles against the AGP-9 DSL. (compileOnly— does not force consumers onto AGP 9.)BaseConfiguration.kt/coverage/CoverageConfiguration.kt— in theconfigureAndroid<Ext>()helpers:CommonExtension<*, *, *, *, *, *>→CommonExtension.compileOptions { … }→compileOptions.apply { … }testOptions { unitTests { … } }→testOptions.unitTests.apply { … }sourceSets { all { … } }→sourceSets.all { … }buildTypes { getByName("debug") { … } }→buildTypes.getByName("debug") { … }This is required because member resolution inside
<reified Ext : CommonExtension>binds to the upper bound (CommonExtension), so the block DSLs can't be used even though callers pass concreteApplicationExtension/LibraryExtension/TestExtension.The getters used (
getCompileOptions,getTestOptions().getUnitTests(),getSourceSets(),getBuildTypes()) exist in both AGP 8 and 9, and.all {}/.getByName(name) {}only configure existing elements (safe under the? extendsvariance) — so no@Suppresscasts and no break for AGP 8 consumers.Testing
./gradlew :plugin:compileKotlinandpublishToMavenLocalsucceed.NoSuchMethodErroris gone and all modules configure and compile.Checklist