Make Protobuf Gradle Plugin AGP 9 compatible#797
Open
omarismail94 wants to merge 3 commits intogoogle:masterfrom
Open
Make Protobuf Gradle Plugin AGP 9 compatible#797omarismail94 wants to merge 3 commits intogoogle:masterfrom
omarismail94 wants to merge 3 commits intogoogle:masterfrom
Conversation
- Upgrade Gradle Wrapper to 8.9 in project and examples. - Update build.gradle dependencies and configuration for Gradle 8.9 compatibility. - Update Spock to version 2.3-groovy-3.0. - Fix CodeNarc violations and resolve Groovy static compilation issues. - Update Android test projects to use 'namespace' DSL and remove 'package' attribute from manifests to support Android Gradle Plugin 8.0+. - Update test matrices to use AGP versions compatible with Gradle 8.9 (e.g., 8.1.0, 8.3.0, 8.13.0). - Fix 'assertJavaCompileHasProtoGeneratedDir' verification in test projects to work with configuration caching changes.
- Upgrade project dependency to Android Gradle Plugin 8.7.3. - Migrate `ProtobufPlugin` to use the `AndroidComponentsExtension` (Variant API) instead of the deprecated `BaseVariant` API. - Replace `registerJavaGeneratingTask` with `variant.sources.java.addGeneratedSourceDirectory` for source registration. - Remove `ProjectExt` and legacy variant iteration logic. - Remove deprecated `AndroidSourceSet` extension in Kotlin.
liutikas
reviewed
Jan 30, 2026
src/main/groovy/com/google/protobuf/gradle/ProtobufAndroidSupport.groovy
Show resolved
Hide resolved
src/main/groovy/com/google/protobuf/gradle/ProtobufAndroidSupport.groovy
Show resolved
Hide resolved
src/main/groovy/com/google/protobuf/gradle/ProtobufAndroidSupport.groovy
Show resolved
Hide resolved
src/main/groovy/com/google/protobuf/gradle/ProtobufAndroidSupport.groovy
Outdated
Show resolved
Hide resolved
src/main/groovy/com/google/protobuf/gradle/ProtobufAndroidSupport.groovy
Outdated
Show resolved
Hide resolved
src/main/groovy/com/google/protobuf/gradle/ProtobufAndroidSupport.groovy
Outdated
Show resolved
Hide resolved
Refactors ProtobufAndroidSupport.groovy to improve readability and maintainability. - Uses HostTest and DeviceTest for variant type checks. - Simplified source set inclusion logic. - Updated ProtobufExtension to expose mainSourceSet. - Bumped minimum Gradle and Android Plugin versions in tests to handle inclusion of HostTest and DeviceTest classes
|
Hello, wondering if this is merge ready, or we need something to be done? This is the last blocker for us to move to AGP9 fully. Thanks! |
Author
|
@michnovka Im just waiting for someone from the owning team to review the change. The regular reviewer is out of office this week, but will try to find someone else. If I don't, then expect it to be reviewed next week |
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.
Establish AGP 8.7 as the minimum supported version and adhere to the new Variant APIs. This ensures forward compatibility with AGP 9.0 while optimizing for the majority of the active ecosystem.
To achieve forward compatibility with AGP 9, the plugin must eliminate all reliance on the "Old Variant API" (BaseVariant, AppExtension, registerJavaGeneratingTask).
The PR does the following
In the first commit, we upgrade to Gradle 8.9 and Java 17
In the second commit we upgrade to AGP 8.7.3 and migrate to the variant API:
ProtobufPluginto use theAndroidComponentsExtension(Variant API) instead of the deprecatedBaseVariantAPI.registerJavaGeneratingTaskwithvariant.sources.java.addGeneratedSourceDirectoryfor source registration.ProjectExtand legacy variant iteration logic.AndroidSourceSetextension in Kotlin.FIXES: Issue #787 , #793
TESTED:
android.newDslto true and the build passed. See here