Scrivio Interview library
LeadershipAdvanced6 min read · updated 12 November 2026

How should internal shared libraries be versioned so that 200 services can upgrade safely?

Version shared libraries with semantic versioning, so a new major version is the only place breaking changes appear, and check API compatibility automatically in the build with tools such as japicmp or revapi. Deprecate before removing, with a published timeline, support the previous major for a set period, and automate upgrade pull requests across the 200 services. Services that deploy continuously can use simple build-number versions, but libraries need semantic versions because other code depends on what they promise.

Why this question is asked

An internal library used by 200 services is a contract with 200 teams. If an upgrade silently breaks them, teams stop upgrading, and within a year the company runs eleven versions of the same library, each with different bugs and security fixes. If upgrades are safe and cheap, everyone stays current. Interviewers ask this to see whether we can design a versioning policy that makes upgrades safe by construction. In this answer, we will recap semantic versioning, automate compatibility checks, define deprecation and support rules, automate upgrades, and explain why services and libraries deserve different versioning.

1A Quick Recap of Semantic Versioning

Semantic versioning gives each part of a version number a meaning. In 3.7.2, the major version 3 changes only for incompatible API changes, the minor version 7 for new, backwards-compatible features, and the patch version 2 for backwards-compatible fixes. So a team on 3.4 knows that 3.7 is safe to take without code changes, and that 4.0 may need work.

The scheme is only useful if the promise is kept. A minor release that removes a public method breaks every caller and destroys trust in all future minor releases. So for 200 services, the key is not choosing semantic versioning, which is easy, but enforcing it.

2Checking Compatibility Automatically

Humans are bad at spotting incompatible changes. Changing a parameter from int to long, adding a method to an interface that services implement, or making a class final all compile fine in the library and break consumers. Tools such as japicmp and revapi compare the library's new jar with the last released version and report binary and source incompatibilities. We run them in every library build.

XML
<plugin>
<groupId>com.github.siom79.japicmp</groupId>
<artifactId>japicmp-maven-plugin</artifactId>
<configuration>
<oldVersion>
<dependency>
<groupId>com.acme</groupId><artifactId>acme-http-client</artifactId>
<version>3.7.2</version> <!-- last release -->
</dependency>
</oldVersion>
<parameter>
<breakBuildOnBinaryIncompatibleModifications>true</breakBuildOnBinaryIncompatibleModifications>
<breakBuildBasedOnSemanticVersioning>true</breakBuildBasedOnSemanticVersioning>
</parameter>
</configuration>
</plugin>
// building 3.8.0 after removing HttpClient.get(String):
// [ERROR] METHOD_REMOVED: com.acme.http.HttpClient.get(java.lang.String)
// incompatible change requires a new major version

With breakBuildBasedOnSemanticVersioning, the plugin compares the kind of change with the version number: an incompatible change in a minor release fails the build, while the same change in 4.0.0 is allowed. The exact option names should be checked against the plugin's documentation. Notice what this achieves: the promise of semantic versioning is now checked by a machine on every change, not remembered by people.

3Deprecate Before Removing

Breaking changes should almost never be a surprise. When we want to remove or change an API, we first add the replacement in a minor release and mark the old one deprecated, with a clear pointer to the new way and a planned removal version.

Java
/**
* @deprecated since 3.6, use {@link #send(Request)}; removal planned in 4.0 (Q2 2027).
*/
@Deprecated(since = "3.6", forRemoval = true)
public Response get(String url) { return send(Request.get(url)); }
// consumers compiling against 3.6 see:
// warning: [removal] get(String) in HttpClient has been deprecated and marked for removal

forRemoval = true makes the compiler issue a removal warning, which is stronger than an ordinary deprecation warning. The published timeline, on the library's changelog or wiki, tells teams how long they have. When 4.0 ships, the removed API has been deprecated for months, and every team has had warnings pointing at the exact lines to change.

4Support the Previous Major and Automate Upgrades

Even with warnings, 200 teams cannot all migrate on the day 4.0 is released. So we support the previous major for a set period, for example six months of bug and security fixes on 3.x after 4.0 is out. This gives teams a predictable window and keeps the number of supported lines at two.

Then we make upgrading cheap. A dependency bot such as Renovate or Dependabot opens upgrade pull requests in every service for new minor and patch releases; if the service's tests pass, the team merges, often automatically for patch versions. For major versions, the library team can ship an automated migration, for example an OpenRewrite recipe that rewrites calls from get(url) to send(Request.get(url)), and run it across all services, so most teams only review a generated pull request. Tracking which version each service uses, from the dependency graph of each build, shows who is falling behind before support ends.

Step throughLife of a breaking change in a shared library
  1. Add the new API in 3.6old API marked @Deprecated(forRemoval = true)
  2. Publish the timelineremoval planned in 4.0, Q2 2027
  3. Bots and recipes migrate callersRenovate PRs, OpenRewrite recipe
  4. Release 4.0japicmp allows the break only in a major
  5. Support 3.x for six monthsfixes backported, usage tracked
  6. Services still on 3.x?
    YesHelp those teams directlyNoEnd 3.x support

6 steps in order. Play them, or step through them one at a time.

Each step makes the next upgrade cheaper for the 200 consuming services.

5Why Services and Libraries Version Differently

Not everything needs semantic versions. A service that deploys continuously is consumed through its network API, not through its jar, so its artifact version only needs to identify a build: a CI build number or commit-based version such as 1.4812.0 is perfect. Its API compatibility is a separate concern, handled with API versioning and contract tests.

A library is different, because other code compiles against it, and the version number is the only message the library can send to that code about what changed. That is why libraries need semantic versions with enforced compatibility, while services can use simple build numbers. Mixing these up causes trouble in both directions: semantic versions on services become meaningless bureaucracy, and build numbers on libraries tell consumers nothing.

Versioning by kind of artifact
ArtifactVersion schemeWhy
Shared librarysemantic: 3.7.2consumers compile against it; major means breaking
Servicebuild number: 1.4812.0consumed over the network; version identifies a build
Service APIAPI version: /v2, or schema versionscompatibility handled by contracts
Platform BOMsemantic or calendar: 2026.11a tested set of library versions
The version number has to carry the message each kind of consumer needs.

6Follow-up questions

Should a company BOM pin all library versions?

A BOM, a bill of materials POM that manages versions, is a good way to publish a tested combination of internal libraries, similar to the Spring Boot dependency BOM. Services import one BOM version instead of choosing a dozen versions, which avoids incompatible combinations. The BOM itself is then the main thing bots upgrade.

What counts as the public API of a library?

Everything consumers can reach: public classes and methods, configuration properties, and behaviour they rely on. Packages named internal or annotated as not public API can be excluded from compatibility checks, but only if consumers are actually prevented from using them, for example with an ArchUnit rule.

How often should we release a new major?

As rarely as possible, perhaps once or twice a year, batching breaking changes together. Each major costs 200 teams some migration work, so it should bring enough value to justify it.

7Conclusion

In this answer, we designed versioning for a library used by 200 services: semantic versioning so that only majors break, automated compatibility checks with japicmp or revapi in every build, deprecation with forRemoval and a published timeline before removal, support of the previous major for a set period with automated upgrade pull requests and migration recipes, and simple build-number versions for continuously deployed services while libraries keep semantic versions.

What to say in the interviewAbout 90 seconds aloud

Open with

I would use semantic versioning for the libraries, but enforced, not just declared. Major means breaking, minor means new compatible features, patch means fixes, and the build checks it: japicmp or revapi compare each new build with the last release, and an incompatible change in a minor or patch fails the build, so the promise is kept by a machine.

Then, if they want more

Breaking changes go through deprecation first: add the replacement in a minor release, mark the old API Deprecated with forRemoval true and a since version, and publish the planned removal date, so every team sees compiler warnings months before the major ships.

After a new major is released, I would support the previous one for a fixed period, say six months of fixes, so there are at most two supported lines.

Upgrades must be cheap: Renovate or Dependabot opens pull requests in all 200 services for minor and patch versions, and for majors we provide an OpenRewrite recipe that does most of the migration. We track which version each service uses so we can help teams who fall behind.

And I would be clear that services that deploy continuously do not need semantic versions; a build number is enough there, because consumers use their API over the network, while libraries need semantic versions because code compiles against them.

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.
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 "How should internal shared libraries be versioned so that 200 services can upgrade safely?": https://scrivio-interview-library.netlify.app/java/version-control-and-ci/1706f7d9a5/