gradle/gradle · error · GradleException

Expected all requested coordinates to resolve to the same co

Error message

Expected all requested coordinates to resolve to the same component coordinates.

What it means

When publishing resolved dependency coordinates, ResolutionBackedPublicationDependencyResolver walks first-level edges of the published variant and asserts that one requested module identifier always resolves to the same component coordinates across edges; a mismatch throws GradleException. It is an internal consistency invariant: the same module resolving to different components within a single publish is unsupported.

Source

Thrown at platforms/software/publish/src/main/java/org/gradle/api/publish/internal/mapping/ResolutionBackedPublicationDependencyResolver.java:118

        Set<ModuleDependencyKey> incompatibleModuleDeps = new HashSet<>();
        Set<ProjectDependencyKey> incompatibleProjectDeps = new HashSet<>();

        Map<ModuleIdentifier, ModuleVersionIdentifier> resolvedModuleComponents = new HashMap<>();
        Map<Path, ModuleVersionIdentifier> resolvedProjectComponents = new HashMap<>();

        Map<ModuleDependencyKey, ModuleVersionIdentifier> resolvedModuleVariants = new HashMap<>();
        Map<ProjectDependencyKey, ModuleVersionIdentifier> resolvedProjectVariants = new HashMap<>();

        visitFirstLevelEdges(rootComponent, rootVariant, edge -> {

            ComponentSelector requested = edge.getRequested();
            CoordinatePair coordinates = getResolvedCoordinates(edge.getResolvedVariant(), projectDependencyResolver, moduleIdentifierFactory);
            if (requested instanceof ModuleComponentSelector) {
                ModuleComponentSelector requestedModule = (ModuleComponentSelector) requested;

                ModuleVersionIdentifier existingComponent = resolvedModuleComponents.put(requestedModule.getModuleIdentifier(), coordinates.componentCoordinates);
                if (existingComponent != null && !existingComponent.equals(coordinates.componentCoordinates)) {
                    throw new GradleException("Expected all requested coordinates to resolve to the same component coordinates.");
                }

                ModuleDependencyKey key = new ModuleDependencyKey(requestedModule.getModuleIdentifier(), ModuleDependencyDetails.from(requested));
                if (incompatibleModuleDeps.contains(key)) {
                    return;
                }

                ModuleVersionIdentifier existingVariant = resolvedModuleVariants.put(key, coordinates.variantCoordinates);
                if (existingVariant != null && !existingVariant.equals(coordinates.variantCoordinates)) {
                    resolvedModuleVariants.remove(key);
                    incompatibleModuleDeps.add(key);
                }
            } else if (requested instanceof ProjectComponentSelector) {
                ProjectComponentSelectorInternal requestedProject = (ProjectComponentSelectorInternal) requested;

                ModuleVersionIdentifier existingComponent = resolvedProjectComponents.put(requestedProject.getIdentityPath(), coordinates.componentCoordinates);
                if (existingComponent != null && !existingComponent.equals(coordinates.componentCoordinates)) {
                    throw new GradleException("Expected all requested projects to resolve to the same component coordinates.");

View on GitHub (pinned to 534f27719b)

Solutions

  1. Inspect the resolved graph of the resolution configuration (gradle dependencies --configuration <config> and dependencyInsight --dependency <module-from-the-stack-trace>)
  2. Make substitution/replacement rules apply consistently to every edge (resolutionStrategy.eachDependency / dependencySubstitution on all relevant configurations)
  3. Verify every repository serving that GAV returns identical content; exclude the repository that serves the divergent component
  4. If the inconsistency is unavoidable, fall back to publishing declared coordinates by disabling publishResolvedCoordinates
Defensive patterns

Strategy: fallback

Validate before calling

configurations.named('mappedRuntimeElements') {
    it.incoming.afterResolve {
        it.resolutionResult.allComponents.each { c ->
            logger.lifecycle "resolved: ${c.id}"
        }
    }
}

Prevention

When it happens

Trigger: The same module identifier requested with different selectors/attributes on different edges resolving to different component coordinates - typically caused by dependency substitution rules applied inconsistently, capability conflicts resolved differently per edge, or multiple repositories serving different content for the same GAV.

Common situations: Composite builds substituting a module on one edge while another edge resolves the external artifact; repository content filters or exclusive-repository rules splitting resolution; custom resolutionStrategy rules that fire only for some configurations.

Related errors


AI-assisted analysis of gradle/gradle@534f27719b (2026-08-22). Data as JSON: /api/errors/def88c8bc6320100. Report an issue: GitHub.