Repository navigation
Align Wire artifacts in the dependency graph to the plugin version - #3831
Merged
oldergod merged 4 commits intoDec 1, 2026
Merged
Conversation
The Wire Gradle plugin now adds dependency constraints for the Wire artifacts which a project can have on its classpath. A constraint requires the plugin version and only applies to a module which is already in the graph, so it adds no artifact and a higher version still wins. The constraints go to the same configuration as the wire-runtime dependency and are skipped in the Wire repo.
A module added to the BOM only would not be aligned by the plugin. The test reads the constraints of wire-bom and compares them with wireAlignedModules.
A Wire artifact declared by the project below the plugin version is raised by the constraints without a message, and a pin such as resolutionStrategy.force can keep it older, also without a message. The plugin now logs one warning per module for each case. It listens to resolutions which happen anyway, and never resolves a configuration itself.
sahuadarsh0
reviewed
Nov 28, 2026
A dynamic version such as 8.+ or latest.release, or a range such as [7.0, 9.0), can cover the plugin version, so it is not an older version. The fixtures now separate extra dependencies with ';' so a test can pass a range.
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.
The Wire Gradle plugin adds
wire-runtimeto the project, but it did not align any other Wire artifact.A project could resolve
wire-grpc-client,wire-moshi-adapterand others at an older version.An older published protos jar, or an older
wire-bombrought by another BOM, can cause this.Wire 8 generated code then fails to compile, for example with
No parameter with name 'requestStreaming' found.The plugin now adds Gradle dependency constraints next to the
wire-runtimedependency.Each constraint is a plain
requireof the plugin version.A constraint applies only to a module that is already in the dependency graph.
The plugin adds no new Wire artifact, and a higher version still wins.
Constraints are not
strictly, and the plugin does not add the BOM.A project that pins a Wire artifact with
strictlyto an older version now fails to resolve.Before, only a
strictlypin ofwire-runtimeconflicted with the plugin.The plugin uses constraints and not
platform("com.squareup.wire:wire-bom:$wireVersion").A platform in
commonMainhas caused problems on JS and native targets.A platform also depends on the BOM listing the same modules as the constraints, and it adds a BOM node to every graph.
Constraints give the same alignment and add no module.
Aligned modules:
wire-runtime,wire-grpc-client,wire-moshi-adapter,wire-gson-support,wire-reflector,wire-schema,wire-schema-tests,wire-grpc-mockwebserver, and the-jvmvariants of the Kotlin Multiplatform modules.The plugin also aligns
wire-compiler,wire-java-generator,wire-kotlin-generatorandwire-swift-generator.A project that writes a custom handler can have these on its classpath, and they call
wire-schemaAPIs.The plugin does not align
wire-gradle-plugin, because it is on the build classpath and not on the project classpath.WireAlignedModulesTestchecks that this list matches the constraints ofwire-bom, so a module added to the BOM only fails the build.The plugin logs a warning when a Wire version is not the one the build asked for.
The first warning is for a Wire artifact that the project declares itself at a version below the plugin version, for example
api("com.squareup.wire:wire-grpc-client:7.2.2").The constraint raises it to the plugin version, and the warning names the module, the declared version, the resolved version and the configuration.
The warning says how to silence it: declare the plugin version or newer.
A lower version that only a transitive dependency or a transitive BOM requests does not warn, because that is normal Gradle conflict resolution.
The second warning is for a Wire artifact that resolves below the plugin version for any reason, such as
resolutionStrategy.force,eachDependency { useVersion }orenforcedPlatform.The warning names the module, the resolved version, the plugin version and the configuration, gives the Gradle selection reason, and says that generated code needs the plugin version or newer.
The plugin warns at most once for each module and case.
It listens with
incoming.afterResolveon the configurations that extend the one with the constraints, so it never resolves a configuration itself.It does not capture
Project, and it is skipped in the Wire repo like the constraints.With the configuration cache, the warning shows on the run that configures the build, and not on a run that reuses the cache entry, because the plugin is not applied then.
The constraints go to the same configuration as the runtime dependency:
api,implementation, orcommonMainApifor Kotlin Multiplatform.They reach the compile and runtime classpaths, and the JVM, Android, JS and native variants.
A library that applies the plugin publishes them in its Gradle module metadata, in
dependencyConstraintsof the API and runtime variants.The POM lists them in
dependencyManagementand not independencies, so Maven consumers get no new dependency.The plugin skips the constraints in the Wire repo (
com.squareup.wire.internal), where project dependencies are used.It also skips them when the project has no Java or Kotlin output, like the runtime dependency.
Release note: The Wire Gradle plugin now aligns the version of every Wire artifact that is already in a project's dependency graph to at least the plugin version.
It uses Gradle dependency constraints, so it does not add an artifact that the project does not depend on, and a higher version still wins.
This fixes build failures when an older
wire-bomor an older published library brings an olderwire-grpc-clientor other Wire artifact.A
strictlypin of a Wire artifact to an older version now fails to resolve.Before, only a
strictlypin ofwire-runtimeconflicted with the plugin.The plugin also logs a warning when a project declares a Wire artifact below the plugin version and the plugin raises it, or when a pin such as
forcekeeps a Wire artifact below the plugin version.