{"record":{"id":"def88c8bc6320100","repo":"gradle/gradle","slug":"expected-all-requested-coordinates-to-resolve-to-t","errorCode":null,"errorMessage":"Expected all requested coordinates to resolve to the same component coordinates.","messagePattern":"Expected all requested coordinates to resolve to the same component coordinates\\.","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"platforms/software/publish/src/main/java/org/gradle/api/publish/internal/mapping/ResolutionBackedPublicationDependencyResolver.java","lineNumber":118,"sourceCode":"        Set<ModuleDependencyKey> incompatibleModuleDeps = new HashSet<>();\n        Set<ProjectDependencyKey> incompatibleProjectDeps = new HashSet<>();\n\n        Map<ModuleIdentifier, ModuleVersionIdentifier> resolvedModuleComponents = new HashMap<>();\n        Map<Path, ModuleVersionIdentifier> resolvedProjectComponents = new HashMap<>();\n\n        Map<ModuleDependencyKey, ModuleVersionIdentifier> resolvedModuleVariants = new HashMap<>();\n        Map<ProjectDependencyKey, ModuleVersionIdentifier> resolvedProjectVariants = new HashMap<>();\n\n        visitFirstLevelEdges(rootComponent, rootVariant, edge -> {\n\n            ComponentSelector requested = edge.getRequested();\n            CoordinatePair coordinates = getResolvedCoordinates(edge.getResolvedVariant(), projectDependencyResolver, moduleIdentifierFactory);\n            if (requested instanceof ModuleComponentSelector) {\n                ModuleComponentSelector requestedModule = (ModuleComponentSelector) requested;\n\n                ModuleVersionIdentifier existingComponent = resolvedModuleComponents.put(requestedModule.getModuleIdentifier(), coordinates.componentCoordinates);\n                if (existingComponent != null && !existingComponent.equals(coordinates.componentCoordinates)) {\n                    throw new GradleException(\"Expected all requested coordinates to resolve to the same component coordinates.\");\n                }\n\n                ModuleDependencyKey key = new ModuleDependencyKey(requestedModule.getModuleIdentifier(), ModuleDependencyDetails.from(requested));\n                if (incompatibleModuleDeps.contains(key)) {\n                    return;\n                }\n\n                ModuleVersionIdentifier existingVariant = resolvedModuleVariants.put(key, coordinates.variantCoordinates);\n                if (existingVariant != null && !existingVariant.equals(coordinates.variantCoordinates)) {\n                    resolvedModuleVariants.remove(key);\n                    incompatibleModuleDeps.add(key);\n                }\n            } else if (requested instanceof ProjectComponentSelector) {\n                ProjectComponentSelectorInternal requestedProject = (ProjectComponentSelectorInternal) requested;\n\n                ModuleVersionIdentifier existingComponent = resolvedProjectComponents.put(requestedProject.getIdentityPath(), coordinates.componentCoordinates);\n                if (existingComponent != null && !existingComponent.equals(coordinates.componentCoordinates)) {\n                    throw new GradleException(\"Expected all requested projects to resolve to the same component coordinates.\");","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/gradle/gradle/blob/534f27719b66953f95cc907aae7f2c1b12f5482d/platforms/software/publish/src/main/java/org/gradle/api/publish/internal/mapping/ResolutionBackedPublicationDependencyResolver.java#L100-L136","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the resolved graph of the resolution configuration (gradle dependencies --configuration <config> and dependencyInsight --dependency <module-from-the-stack-trace>)","Make substitution/replacement rules apply consistently to every edge (resolutionStrategy.eachDependency / dependencySubstitution on all relevant configurations)","Verify every repository serving that GAV returns identical content; exclude the repository that serves the divergent component","If the inconsistency is unavoidable, fall back to publishing declared coordinates by disabling publishResolvedCoordinates"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"configurations.named('mappedRuntimeElements') {\n    it.incoming.afterResolve {\n        it.resolutionResult.allComponents.each { c ->\n            logger.lifecycle \"resolved: ${c.id}\"\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check the resolution graph of the published configuration before enabling publishResolvedCoordinates","Apply dependency substitution rules uniformly to all configurations involved in the publish","Ensure all repositories serve identical content for a given GAV","Keep publishResolvedCoordinates = false when the graph cannot be made consistent"],"tags":["publishing","gradle","dependency-resolution","invariant"],"backgroundTag":"inconsistent-dependency-resolution","analyzedSha":"534f27719b66953f95cc907aae7f2c1b12f5482d","analyzedAt":"2026-08-22T08:09:12.375Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}