-
Notifications
You must be signed in to change notification settings - Fork 599
Refactor to Factory pattern and use modern Android Variant API #3503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
… Variant API This major refactor modernizes the Wire Gradle plugin by decoupling task creation from the core plugin logic and adopting the modern Android Gradle Plugin (AGP) APIs. Key changes: - Introduced WireTaskFactory and a sealed Source hierarchy (Android, Kotlin Multiplatform, JVM) to handle task registration across different project types, replacing the legacy WireSourceDirectorySet. - Migrated Android task generation from the deprecated BaseExtension to the modern AndroidComponentsExtension using the onVariants and variant.sources APIs. - Refactored WirePlugin to delegate task setup to the appropriate factory, significantly reducing core plugin complexity and improving maintainability. - Centralized common task configuration in setupWireTask within SourceRoots.kt, providing a unified way to configure WireTask properties, inputs, and outputs. - Enhanced WireTask to use DirectoryProperty for outputs, improving support for configuration avoidance and better integration with Gradle's task graph. - Cleaned up deprecated Kotlin API usage, such as replacing capitalize() with replaceFirstChar.
liutikas
reviewed
Jan 22, 2026
wire-gradle-plugin/src/main/kotlin/com/squareup/wire/gradle/kotlin/SourceRoots.kt
Outdated
Show resolved
Hide resolved
wire-gradle-plugin/src/main/kotlin/com/squareup/wire/gradle/WirePlugin.kt
Show resolved
Hide resolved
wire-gradle-plugin/src/main/kotlin/com/squareup/wire/gradle/kotlin/SourceRoots.kt
Outdated
Show resolved
Hide resolved
wire-gradle-plugin/src/main/kotlin/com/squareup/wire/gradle/kotlin/SourceRoots.kt
Outdated
Show resolved
Hide resolved
wire-gradle-plugin/src/main/kotlin/com/squareup/wire/gradle/kotlin/SourceRoots.kt
Outdated
Show resolved
Hide resolved
wire-gradle-plugin/src/main/kotlin/com/squareup/wire/gradle/kotlin/SourceRoots.kt
Outdated
Show resolved
Hide resolved
wire-gradle-plugin/src/main/kotlin/com/squareup/wire/gradle/kotlin/SourceRoots.kt
Outdated
Show resolved
Hide resolved
* Removed manual configuration of `JavaCompile` and `KotlinCompile` tasks, along with the associated reflection hacks, in favor of using standard Gradle and Android source registration APIs. * Replaced the WireTaskFactory abstraction with a simpler forEachWireSource loop.
wire-gradle-plugin/src/main/kotlin/com/squareup/wire/gradle/kotlin/SourceRoots.kt
Outdated
Show resolved
Hide resolved
wire-gradle-plugin/src/main/kotlin/com/squareup/wire/gradle/WirePlugin.kt
Outdated
Show resolved
Hide resolved
wire-gradle-plugin/src/main/kotlin/com/squareup/wire/gradle/kotlin/SourceRoots.kt
Outdated
Show resolved
Hide resolved
oldergod
approved these changes
Jan 23, 2026
wire-gradle-plugin/src/main/kotlin/com/squareup/wire/gradle/WirePlugin.kt
Outdated
Show resolved
Hide resolved
Refactored source registration in the Wire Gradle plugin to be aware of the target type (Java, Kotlin, Custom, etc), ensuring generated code is registered with the appropriate source sets.
martinbonnin
approved these changes
Jan 23, 2026
Member
|
🚀 |
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.
This refactor modernizes the Wire Gradle plugin by decoupling task creation from the core plugin logic and adopting the modern Android Gradle Plugin (AGP) APIs.
Key changes:
TESTED: ran ./gradlew clean check
FIXES: Issue #3371