Add support for AGP 9.0.0#10
Conversation
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Cache Gradle dependencies | ||
| uses: actions/cache@v2 |
There was a problem hiding this comment.
It was failing as actions/cache@v2 is deprecated: https://github.com/Telefonica/android-permissioncheck/actions/runs/21857243109 so I've updated both actions.
| object Versions { // See https://mvnrepository.com | ||
| const val JUNIT_5 = "5.7.1" | ||
| const val JUNIT_5 = "5.13.4" | ||
| const val JUNIT_PLATFORM_LAUNCHER ="1.7.1" |
There was a problem hiding this comment.
The JUNIT_PLATFORM_LAUNCHER is now needed because recent versions of Gradle and the Android Gradle Plugin (AGP) have updated their test infrastructure to use the JUnit Platform as the default test engine. This change means that, for custom test runners, plugins, or advanced test configurations, the junit-platform-launcher dependency must be explicitly included to ensure tests are discovered and executed correctly.
| internal object TaskConfiguratorFactory { | ||
|
|
||
| fun getTaskConfigurator(): TaskConfigurator { | ||
| val version = VersionNumber.parse(getAndroidGradlePluginVersion()) |
There was a problem hiding this comment.
VersionNumber is either removed or no longer public and can't be used. It wasn't intended for public usage according to https://stackoverflow.com/questions/69967885/whats-the-successor-of-org-gradle-util-versionnumber
| } | ||
|
|
||
| android { | ||
| namespace = "com.telefonica.manifestcheck.sample.app" |
There was a problem hiding this comment.
The namespace has to be moved from the manifest files to the gradle files when upgrading.
| private val GRADLE_VERSIONS = listOf( | ||
| "7.4.2", | ||
| "7.2", | ||
| "9.1.0", |
| // See https://developer.android.com/studio/releases/gradle-plugin | ||
| private val AGP_VERSIONS = listOf( | ||
| "7.0.0", | ||
| "9.0.0", |
|
|
||
| val manifestFile = androidProject.appDir.resolve("src").resolve("main").resolve("AndroidManifest.xml") | ||
| manifestFile.writeText(manifestFile.readText().replace("simonschiller", "johndoe")) // Trigger change | ||
| manifestFile.writeText(manifestFile.readText().replace("<manifest", "<!-- comment -->\n<manifest")) // Trigger change |
There was a problem hiding this comment.
We can't update anymore the namespace which has been moved from the manifest to the gradle file so it seems safer to just add a comment in that file.
|
|
||
| group = "com.telefonica" | ||
| version = "1.0.2" // Also update the version in the README | ||
| version = "1.1.0" // Also update the version in the README |
There was a problem hiding this comment.
The new version of this plugin
| website = "https://github.com/Telefonica/android-permissioncheck" | ||
| vcsUrl = "https://github.com/Telefonica/android-permissioncheck" |
There was a problem hiding this comment.
website and vcsUrl have been moved from pluginBundle block to the gradlePlugin.plugins block: https://docs.gradle.org/current/userguide/publishing_gradle_plugins.html#:~:text=version%20%3D%20%221.0%22-,gradlePlugin%20%7B,-website%20%3D%20%22%3Csubstitute
| @@ -1,5 +1,4 @@ | |||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | |||
| package="io.github.simonschiller.permissioncheck.sample.app"> | |||
There was a problem hiding this comment.
Package has to be removed and added as namespace in the gradle files
| minSdk = 24 | ||
| targetSdk = 36 |
There was a problem hiding this comment.
I've updated the target and minSdk versions in this sample app project with more actual values
There was a problem hiding this comment.
Pull request overview
Adds compatibility updates for running/building the plugin and samples with Gradle 9 and Android Gradle Plugin (AGP) 9 by modernizing Android DSL usage, updating dependency versions, and tweaking CI/test scaffolding to align with newer tooling.
Changes:
- Updated sample + test Android project configuration (namespace, new Android DSL, lint block) and removed manifest
packageattributes. - Bumped Gradle wrapper / AGP dependency targets and adjusted JUnit runtime dependencies for Gradle 9/JUnit Platform.
- Simplified AGP task configurator selection by removing version parsing logic.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| sample/library/src/main/AndroidManifest.xml | Removes manifest package attribute in favor of Gradle namespace. |
| sample/library/build.gradle.kts | Migrates to namespace, compileSdk, minSdk, and new lint DSL. |
| sample/app/src/main/AndroidManifest.xml | Removes manifest package attribute in favor of Gradle namespace. |
| sample/app/build.gradle.kts | Migrates to namespace, compileSdk, minSdk/targetSdk, and new lint DSL. |
| plugin-core/build.gradle.kts | Sets Java compatibility to 17; adds AGP 9 compileOnly and JUnit platform launcher runtime. |
| manifestcheck/src/test/kotlin/.../TestVersions.kt | Removes VersionNumber compatibility filtering; targets Gradle 9.1.0 + AGP 9.0.0. |
| manifestcheck/src/test/kotlin/.../AndroidProjectExtension.kt | Updates generated build script to set namespace and new lint DSL; updates manifest template. |
| manifestcheck/src/test/kotlin/.../SingleVariantPermissionCheckIntegrationTest.kt | Changes manifest mutation strategy to not rely on removed manifest package. |
| manifestcheck/src/test/kotlin/.../MultiVariantPermissionCheckIntegrationTest.kt | Changes manifest mutation strategy to not rely on removed manifest package. |
| manifestcheck/src/main/kotlin/.../TaskConfiguratorFactory.kt | Removes AGP version detection and always selects TaskConfiguratorV1. |
| manifestcheck/build.gradle.kts | Bumps plugin version + AGP compileOnly; configures JAR task deps and JUnit Platform. |
| gradle/wrapper/gradle-wrapper.properties | Updates Gradle wrapper distribution to 9.1.0. |
| buildSrc/src/main/kotlin/Dependencies.kt | Updates JUnit Jupiter version; adds JUnit Platform launcher constant/version. |
| README.md | Updates published plugin version references to 1.1.0. |
| .java-version | Removes pinned Java version file. |
| .github/workflows/ci.yml | Updates GitHub Actions versions for checkout/cache. |
Comments suppressed due to low confidence (1)
manifestcheck/src/test/kotlin/io/github/simonschiller/permissioncheck/testutil/AndroidProjectExtension.kt:1
namespacehas been migrated, but the generated test project is still using the oldercompileSdkVersion(...),minSdkVersion(...), andtargetSdkVersion(...)DSL. Since this PR targets AGP 9, it’s safer to migrate these to the modern properties (compileSdk = ...,defaultConfig { minSdk = ...; targetSdk = ... }) to avoid DSL removals/deprecations and keep the generated test build scripts consistent with the sample modules.
package io.github.simonschiller.permissioncheck.testutil
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| * | ||
| * It returns [TaskConfiguratorV1], as only V1 is supported for AGP 7.0.0+ (including 9.0.0). | ||
| */ | ||
| internal object TaskConfiguratorFactory { |
There was a problem hiding this comment.
Do we really need the factory? Maybe we can remove it directly
🎟️ Jira ticket
ANDROID-17380
🥅 What's the goal?
Add support for gradle 9 & agp 9.
🚧 How do we do it?
VersionNumberas it has been removed.To run the plugin locally with the sample app:
checkPermissions.To run the tests:
Tests also run on CI.