{"record":{"id":"11d6512cb4ce80da","repo":"quarkusio/quarkus","slug":"dependency-version-alignment-check-failed-error","errorCode":null,"errorMessage":"Dependency version alignment check failed:\n${errors}","messagePattern":"Dependency version alignment check failed:\n(.+?)","errorType":"validation","errorClass":"EnforcerRuleException","httpStatus":null,"severity":"error","filePath":"independent-projects/enforcer-rules/src/main/java/io/quarkus/enforcer/DependencyAlignmentRule.java","lineNumber":135,"sourceCode":"                } else {\n                    getLog().debug(\"Artifact '%s' not found in project (skipping)\".formatted(artifact));\n                }\n                continue;\n            }\n\n            if (!expectedVersion.equals(actualVersion)) {\n                errors.append(\"\"\"\n                          - Version mismatch for '%s':\n                            Project declares version '%s'\n                            but reference artifact expects '%s'\n                        \"\"\".formatted(artifact, actualVersion, expectedVersion));\n            } else {\n                getLog().debug(\"✓ %s version %s is aligned\".formatted(artifact, actualVersion));\n            }\n        }\n\n        if (!errors.isEmpty()) {\n            throw new EnforcerRuleException(\"Dependency version alignment check failed:\\n\" + errors);\n        }\n    }\n\n    /**\n     * Extracts dependency versions from the project's dependencyManagement and dependencies sections.\n     *\n     * @param project the Maven project\n     * @return a map of \"groupId:artifactId\" to version\n     */\n    private Map<String, String> getProjectDependencyVersions(MavenProject project) {\n        Map<String, String> versions = new HashMap<>();\n\n        // First, check dependencyManagement section\n        if (project.getDependencyManagement() != null\n                && project.getDependencyManagement().getDependencies() != null) {\n            project.getDependencyManagement().getDependencies().forEach(dep -> {\n                String key = dep.getGroupId() + \":\" + dep.getArtifactId();\n                if (dep.getVersion() != null) {","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/enforcer-rules/src/main/java/io/quarkus/enforcer/DependencyAlignmentRule.java#L117-L153","documentation":"After comparing each configured dependency's actual version against the version declared by the reference artifact, DependencyAlignmentRule collects all mismatches into an errors list and, if any exist, throws EnforcerRuleException with the full report. This is the rule's primary purpose: failing the build when managed versions drift from the platform/BOM.","triggerScenarios":"mvn enforcer:enforce runs while one or more configured <dependencies> have a version that differs from the version resolved in the reference artifact's dependencyManagement (e.g. a module overrides hibernate-core 7.3.1 while the platform pins 7.3.0.Final).","commonSituations":"A module pins a newer patch to get a bugfix; a dependency management import overrides the platform; a merge updated one version but not its aligned siblings; automation bumped versions inconsistently.","solutions":["Align the reported dependency versions to the reference artifact's versions (remove explicit version overrides so dependencyManagement wins)","If the newer version is intentional, update the reference platform artifact to a version that includes it","If the mismatch is acceptable, remove that artifact from the rule's <dependencies> configuration or use the rule's skip/exclude options","Run mvn enforcer:enforce -X to see per-artifact debug output of expected vs actual versions"],"exampleFix":"// before: version drifts from platform\n<dependency><groupId>org.hibernate.orm</groupId><artifactId>hibernate-core</artifactId><version>7.3.1.Final</version></dependency>\n// after: aligned via platform dependencyManagement\n<dependency><groupId>org.hibernate.orm</groupId><artifactId>hibernate-core</artifactId></dependency>","handlingStrategy":"validation","validationCode":"# Compare managed versions against the platform before enforcing\nmvn dependency:tree -Dverbose | grep -E '(version managed from|omitted for conflict)'\nmvn dependency:list | grep -E 'hibernate|aligned-artifact'","typeGuard":null,"tryCatchPattern":"// Enforcer fails the build with the report; process it in CI\nif (!mvnVerify()) {\n    def mismatches = parseEnforcerReport(\"target/enforcer-report\")\n    mismatches.each { alignVersion(it.artifact, it.expectedVersion) }\n}","preventionTips":["Let dependencyManagement from the platform/BOM set versions; omit explicit <version> in modules","When bumping one aligned artifact, check the platform release for sibling updates","Keep the referenceArtifact platform version current in the same PR as dependency bumps","Run enforcer locally before pushing"],"tags":["maven","enforcer","dependency-management","version-alignment"],"backgroundTag":"dependency-version-misalignment","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}