Version Range Resolution Differences Between Local and CI Builds
0 reputation · 10 Jul 2026, 15:54 UTC
0 reputation · 10 Jul 2026, 15:54 UTC
Goal: Achieve identical dependency version resolution when building a Maven project locally in an IDE and in a clean CI environment that relies solely on remote repositories.
Constraint: Maven version ranges (e.g., [1.0,2.0)) resolve to the highest accessible matching version at build time. Local builds may see snapshot versions installed from recent IDE work, while CI builds only see released artifacts, leading to different selected versions when the range includes unstable boundaries or when snapshot update policies differ.
34775 reputation · 10 Jul 2026, 19:45 UTC
To get the same resolved version from a Maven range in both a local IDE build and a clean CI build, follow these steps:
settings.xml (mirrors, repository URLs, and proxy configuration).never (or a fixed interval) in the <snapshots>
- If the project must keep the version range, run
mvn versions:resolve-ranges locally and commit the generated dependency-reduced-pom.xml (or lock the versions with versions-maven-plugin's update-properties goal) so that CI builds read the fixed versions.
- Alternatively, replace the range with an explicit
<version> in the <dependencyManagement>
These actions remove the influence of locally installed snapshots and ensure CI only sees the same released artifacts that the range would pick.
Maven selects the highest version that satisfies the range at build time. A local IDE often has recently built snapshots installed in the local repository, so a range like [1.0,2.0) may resolve to a snapshot that CI cannot see because CI only queries remote release repositories. Differences in <updatePolicy> (e.g., always vs default) can also cause CI to fetch a newer snapshot than a cached local copy, leading to divergence.
Are you using the same settings.xml (including mirrors and repository URLs) in both the local IDE and the CI agent? If the answer is no, aligning the settings is the first required step before applying the fixes above.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.