Skip to content

Align Wire artifacts in the dependency graph to the plugin version - #3831

Merged
oldergod merged 4 commits into
masterfrom
bquenaudon.2026-11-26.plugin-align-wire-versions
Dec 1, 2026
Merged

oldergod merged 4 commits into
masterfrom
bquenaudon.2026-11-26.plugin-align-wire-versions

Conversation

@oldergod

@oldergod oldergod commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

The Wire Gradle plugin adds wire-runtime to the project, but it did not align any other Wire artifact.
A project could resolve wire-grpc-client, wire-moshi-adapter and others at an older version.
An older published protos jar, or an older wire-bom brought 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-runtime dependency.
Each constraint is a plain require of 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 strictly to an older version now fails to resolve.
Before, only a strictly pin of wire-runtime conflicted with the plugin.

The plugin uses constraints and not platform("com.squareup.wire:wire-bom:$wireVersion").
A platform in commonMain has 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 -jvm variants of the Kotlin Multiplatform modules.
The plugin also aligns wire-compiler, wire-java-generator, wire-kotlin-generator and wire-swift-generator.
A project that writes a custom handler can have these on its classpath, and they call wire-schema APIs.
The plugin does not align wire-gradle-plugin, because it is on the build classpath and not on the project classpath.
WireAlignedModulesTest checks that this list matches the constraints of wire-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 } or enforcedPlatform.
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.afterResolve on 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, or commonMainApi for 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 dependencyConstraints of the API and runtime variants.
The POM lists them in dependencyManagement and not in dependencies, 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-bom or an older published library brings an older wire-grpc-client or other Wire artifact.
A strictly pin of a Wire artifact to an older version now fails to resolve.
Before, only a strictly pin of wire-runtime conflicted 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 force keeps a Wire artifact below the plugin version.

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.
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.
@oldergod
oldergod merged commit 36ed11e into master Dec 1, 2026
18 checks passed
@oldergod
oldergod deleted the bquenaudon.2026-11-26.plugin-align-wire-versions branch December 1, 2026 13:22
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.

2 participants