Quick revision
The short answer
The maven-release-plugin edits the POM version, commits, tags and commits again for every release, which suits libraries released occasionally but is slow and noisy when a service releases on every merge. CI-friendly versions let the pipeline set the version through ${revision}, for example from a build number or git describe, with no commits at all. With ${revision} we add the flatten-maven-plugin so the published POMs contain the resolved version, and we tag the commit of each release so it stays traceable.
What to remember
In this answer, we compared the two approaches. The maven-release-plugin commits version changes and a tag for every release and builds twice, which suits occasional library releases but is slow and noisy on every merge. CI-friendly versions let the pipeline set ${revision} from a build number or git describe without commits, the flatten-maven-plugin makes the published POMs contain the resolved version, and tagging each released commit keeps every version traceable.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
The maven-release-plugin edits the POM version, commits, tags and commits again for every release, which suits libraries released occasionally but is slow and noisy when a service releases on every merge. CI-friendly versions let the pipeline set the version through ${revision}, for example from a build number or git describe, with no commits at all. With ${revision} we add the flatten-maven-plugin so the published POMs contain the resolved version, and we tag the commit of each release so it stays traceable.
Why this question is asked
A service that deploys on every merge to main may produce twenty releases a day. Whatever versioning scheme we choose runs twenty times a day, so its cost, its noise in git history and its failure modes matter. Interviewers ask this comparison to see whether we know how both approaches work inside, not just their names. In this answer, we will walk through what the release plugin does, see why it hurts at high frequency, set up CI-friendly versions, explain why flattening is needed, and finish with tagging and a recommendation.
1What the maven-release-plugin Does
The release plugin automates the classic Maven release in two goals. release:prepare checks that there are no uncommitted changes and no SNAPSHOT dependencies, changes the version in every POM from 1.4.0-SNAPSHOT to 1.4.0, runs the build, commits, creates a tag v1.4.0, then changes the version to the next development version, 1.4.1-SNAPSHOT, and commits again. release:perform checks out the tag and runs deploy to publish the artifacts.
For a library released once a month, this is a good fit: the version lives in the POM, every release is a tagged commit, and the main branch always carries the next SNAPSHOT version, which is what developers of the library want.
2Why It Hurts on Every Merge
Now imagine this on every merge to main. Each release adds two commits to main that a bot pushed, so history fills with prepare release and next development iteration messages. The pipeline needs credentials to push to a protected main branch, which weakens branch protection. If two merges arrive close together, the second pipeline may find that main has moved under it and fail to push. And the build runs at least twice, once in prepare and again in perform, doubling the time.
There is also a conceptual mismatch. For a service, the version is not a decision a human makes; it just identifies which build this is. Storing it in the source and committing it back is ceremony without benefit.
3Setting Up CI-Friendly Versions
Maven supports a small set of properties that may be used in the version element: ${revision}, ${sha1} and ${changelist}. We write the version as a property with a default for local builds, and the pipeline overrides it on the command line. Nothing is committed.
Notice that the version is derived from data the pipeline already has: a commit count, a CI build number, or git describe, which names the nearest tag plus the number of commits since it and the short commit hash. Every merge gets a unique version, and main's history contains only real changes. In a multi-module build, child modules reference the parent with the same ${revision}, so one property sets the version everywhere.
4Why the Published POM Needs Flattening
There is a catch. With Maven 3, the POM that gets installed and deployed is the file we wrote, still containing ${revision}. Anyone who later depends on orders-service-client 1.4812.0 downloads that POM, and their Maven does not know what ${revision} was, so resolving its parent or sibling modules fails. The flatten-maven-plugin solves this by writing a resolved copy of the POM, with the real version filled in, and making that the POM that is published.
| Aspect | maven-release-plugin | CI-friendly ${revision} |
|---|---|---|
| Version lives in | the POM, committed | the pipeline, passed as -Drevision |
| Commits per release | two bot commits plus a tag | none, only a tag |
| Needs push to main | yes | only to push the tag |
| Build runs | twice (prepare and perform) | once |
| Published POM | already has the real version | needs flatten-maven-plugin on Maven 3 |
| Best fit | libraries released occasionally | services released on every merge |
The mode resolveCiFriendliesOnly replaces just the CI-friendly properties and leaves the rest of the POM as written. Maven 4 builds a separate consumer POM for publishing and resolves these properties itself, so the plugin may no longer be needed there; check your Maven version.
5Tagging Each Release for Traceability
Without commits, we still need a way back from a version to its source. So the pipeline tags the commit it built, for example git tag v1.4812.0 followed by git push origin v1.4812.0, using a credential that may only create tags, not push to main. It also records the commit hash in the artifact itself, for example in the jar manifest or through Spring Boot's build info and git properties, so the actuator info endpoint of a running service shows exactly which commit it is. Given any version in production, we can find the tag, the commit and the pull request in seconds.
6Follow-up questions
Can we still use semantic versions with ${revision}?
Yes. A common approach is to keep the major and minor in a file or a tag and let the pipeline add the patch from the build number, for example 2.3.<build>. Tools that derive the next version from tags and commit messages can also feed -Drevision. For a service, a simple increasing number is usually enough.
Does ${revision} work with the release plugin?
They do not combine well, because the release plugin wants to rewrite literal versions in the POM. A project chooses one approach: the release plugin with literal versions, or CI-friendly properties with the pipeline in charge.
What about the version of a SNAPSHOT build on a branch?
Pull request builds can use a version such as 0-pr123-SNAPSHOT or skip deploying entirely. Only main produces published versions, which keeps the repository clean.
7Conclusion
In this answer, we compared the two approaches. The maven-release-plugin commits version changes and a tag for every release and builds twice, which suits occasional library releases but is slow and noisy on every merge. CI-friendly versions let the pipeline set ${revision} from a build number or git describe without commits, the flatten-maven-plugin makes the published POMs contain the resolved version, and tagging each released commit keeps every version traceable.
Open with
For a service that releases on every merge I would use CI-friendly versions. The release plugin does release:prepare, which edits the POM to the release version, commits, tags, bumps to the next SNAPSHOT and commits again, and then release:perform checks out the tag and builds again.
Then, if they want more
That is fine for a library released every few weeks, but on every merge it fills main with bot commits, needs push rights to a protected branch, races when merges are close together, and runs the build twice.
With CI-friendly versions the POM says version is dollar revision, with a local default like 0-SNAPSHOT, and the pipeline passes minus D revision, computed from the build number, a commit count or git describe. Nothing is committed and the build runs once.
The one catch on Maven 3 is that the deployed POM would still contain the placeholder, so consumers cannot resolve it; the flatten-maven-plugin in resolveCiFriendliesOnly mode publishes a POM with the real version. Maven 4's consumer POM handles this itself.
Finally, the pipeline tags the commit it released and puts the commit hash in the build info, so any version in production leads straight back to its source.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Apache Maven guides, Gradle user manual
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Compare the maven-release-plugin with CI-friendly versions (${revision}) for releasing a...": https://scrivio-interview-library.netlify.app/java/version-control-and-ci/9f19e60942/