I spent the first 17 years of my career as a consultant, going from project to project. As a Developer Advocate, I worked on products but wasn’t closely involved in releases. In mid-2025, I started to work on a product as an engineer. I created a plugin for the product and became its main developer/release manager/product owner.
Like many engineers with their first product experience, I made a lot of mistakes. I probably am still doing a lot. However, I learned some lessons. In this post, I want to describe how I naïvely created too many branches, got slowed down because of organizational friction, and solved it with a complex build.
The context
My company provides a Java-based platform whose development started around two decades ago and spans many (many!) versions. Along the way, someone decided to add a plugin-based architecture. Plugins have two main benefits:
- Customers can extend the platform’s features on their own
- The professional services team can meet the customers’ needs faster than the product team
In this context, I was tasked with migrating a bunch of proprietary scripts to a regular plugin project. I did that, and was happy about the result. Then I was asked to backport the code to really old versions: in essence, the oldest version run by customers. Trouble started then.
Most products follow a “standard” lifecycle. They start by targeting a specific JDK version. Over time, they may upgrade the version, balancing several factors: the desire to leverage the latest and greatest, the cost of upgrading, the risk of staying on unsupported legacy versions, the push of their community, etc.
However, you may bump the JDK version, and if things don’t break (they rarely do in Java), keep the same code. Hence, the JDK version and the product version are orthogonal. In general, your development capacity limits how many versions you can maintain in parallel.
The problem
My problem was very different. I started from the most recent version running on Java 21, and had to make it compatible all the way back to Java 8. Here are the issues I had to handle:
- Java construct changes, e.g.,
var - Java API changes, e.g.,
LocalDate - Platform API changes
- CI job configuration changes. Fortunately, the infrastructure team only needed a configuration PR.
In the end, I successfully kept it to five maintenance branches, one per supported platform version.
I was happy, then reality hit in the form of Renovate PRs.
I planned for a few features and bug fixes, but I got plenty of dependency upgrade PRs.
I had to approve each one on master, then cherry-pick it to every other branch.
Cherry-picking was fine at first.
We even have a bot for it on GitHub.
Type /cherry-pick <branch-name> on the merged PR, and your friendly neighbourhood bot creates one.
Then, someone decided the cherry-picked PR had to be approved like any other regular PR.
I had to bother colleagues and beg them for approvals.
I didn’t want to impose it on my team.
The solutions
There was no single solution, but one per problem category.
Coping with Java and Java API changes
One solution would have been to migrate the whole codebase to Java 8. Actually, one branch was already Java 8-compatible. However, it would have resulted in a project everyone would have hated to work on, me included. I thought about using Multi-Release Jar Files, but the feature starts from version 9 of the JDK.
It was time for something radically “new”: Kotlin. Kotlin isn’t new to the company, since we already use it in Gradle build files. However, it wasn’t used for source code. I talked with my manager, and he was really supportive of the idea.
Migration was quite smooth with the help of AI, which converted the Java code to Kotlin. I started with the test harness, increased the mutation score so the tests would catch regressions, then I migrated the production code. The only thing left was to configure the build to target Java 8 bytecode, which is backward-compatible.
I hoped I could get one single branch, but another issue prevented me from succeeding.
Coping with the platform changes
As I mentioned, the platform is quite old and has evolved a lot. Fortunately, breaking changes are rare. Yet, I had to cope with one early on. It seemed to me like I had to keep branches anyway, but then I thought about leveraging Gradle.
Before I go further, I need to mention that we build one JAR for each platform version. Our CI jobs are matrix-like.
I’m not a big Gradle fan (to say the least), because its vaunted flexibility is the opposite of what I care for in my builds: simplicity. In this case, however, flexibility was an advantage. In case you are wondering, I already mentioned it in 2013.
A more technical reason I’ve heard is that Spring must be compatible with different Java versions, and Maven cannot address that.
Spring’s choice is to trade off a more complex build for the ability to ship a single artifact that spans multiple Java versions. I kept the build simple by using Kotlin to address the Java API version gaps. However, I had to take the complex Gradle route to address the platform API version gaps.
In essence, the idea was simple:
- keep the source code compatible with the current versions in the regular
src/main/kotlin - add a source root,
src/legacy/kotlin - for each breaking change:
- create a facade method that hides the underlying details in a dedicated file
- create a file with the same name and method signature addressing the old API in a subfolder of
src/legacy/kotlin
- at build time, if the built version targets the legacy API, copy the legacy file over the facade file in
buildbefore the compilation phase
That’s it.
Gradle offers the option to put script code in a buildSrc directory.
It allows a kind of master/detail view and makes the build file smaller and more declarative.
I moved my Kotlin build code there for this reason.
I designed this system so it can accommodate more breaking changes in the future.
Conclusion
Engineering is all about trade-offs, and software engineering is no exception. In this real-world use case, I accepted a more complex build and a slightly different language to get the benefits of a single branch. To this day, I don’t regret my decision. If the context changes, I’ll revisit it and perhaps make other trade-offs.