Skip to content

Conversation

@omarismail94
Copy link
Collaborator

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:

  • 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.

TESTED: ran ./gradlew clean check
FIXES: Issue #3371

… 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.
@oldergod oldergod requested a review from martinbonnin January 22, 2026 22:27
* 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.
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.
@oldergod oldergod merged commit 35a8de9 into square:master Jan 23, 2026
9 checks passed
@oldergod
Copy link
Member

🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants