Upgrading to Spring Boot 1.4.4 with Rug

Automating Your Upgrade Across Multiple Projects

Russ Miles
4 min readJan 30, 2017

Yesterday the folks in the Spring Team announced that Spring Boot 1.4.4 was available and that it would be A Good Idea™ to upgrade, especially as there are a number of bug fixes included.

The upgrade should be super-easy as it’s completely API compatible with the Spring Boot 1.4.x family, but you will need to change your pom.xml dependencies to pick up the new version.

Everywhere you have that Spring Boot version specified. Across all repositories that contain Spring Boot projects…

…all of them…

…everywhere…

It’s time to write a Rug editor for this!

The full code for this article is available in the spring-boot-editors Rug archive.

First, the Spring Upgrade Rug Test

First step, as always, is to create a Rug test. The editor that we’re going to write is going to upgrade Spring Boot to 1.4.4.RELEASE by amending the parent block in any Spring Boot projects and our test looks like:

We’re asserting the result of two scenarios in this Rug test:

  • That a specific version is applied.
  • That no change occurs if we can’t detect Spring Boot being present as the parent of the project.

Second, the Spring Upgrade Editor

We can now write an editor to meet the assertions of the SetSpringBootParentVersion test:

This Rug is pretty straightforward, so here are the highlights:

  • Line 23: Here we’re using JavaScript to amend the contents of the current parent block
  • Line 25: We’re accessing the pom.xml files as they are found throughout the project using the EveryPom type, and then ensuring that we only work on pom.xml files that already contain a spring-boot-starter-parent.

To prove this new editor works, beyond the test itself, we then applied this very editor to the default project contained within the spring-boot-editors Rug archive and it worked like a charm:

$ rug edit atomist-rugs:spring-boot-editors:SetSpringBootParentVersion -R -C default-spring-boot-project -lResolving dependencies for atomist-rugs:spring-boot-editors:0.5.0 ← local completedLoading atomist-rugs:spring-boot-editors:0.5.0 ← local into runtime completedRunning editor SetSpringBootParentVersion of atomist-rugs:spring-boot-editors:0.5.0 ← local completedProject~/code/src/github.com/atomist-rugs/spring-boot-editors/default-spring-boot-project/ (104 kb in 91 files)Changes├── pom.xml updated (2 kb)└── .atomist.yml created (317 bytes)

But I want to do this on ALL my projects!?

When you want a Rug to be applied to multiple repositories and projects, and possibly even to bring in extra information from elsewhere in your system, then editors just won’t cut it. An editor works at the level of a single project, and while you could apply an editor across multiple local repositories with a little bash scripting, we can do better than that.

Enter the Executor!

Pre-warning! Executor syntax, especially the TypeScript approach, is in early Alpha in Atomist and so is likely to change. We’ll make sure we update this article accordingly, and then delete this message, as things mature around executors and their reactive cousins, handlers.

An executor brings is a new concept in Atomist and it represents a higher-level concept than an editor. The executor brings together one or more project repositories to then apply one or more editors to evolve all those projects. There are several examples of executors gradually appearing in the atomist-rugs Rug archives.

Executors are perfect for making amendments to more than one project repository at once, which is exactly what we want to do when we want to automate setting the Spring Boot version across multiple projects and services all at once.

The following executor closes out our work by ensuring we can execute our SetSpringBootParentVersion to upgrade to Spring Boot 1.4.4.RELEASE across all our projects:

Now you can kick off this executor using the Atomist Bot (this is available to folks on our Alpha Programme) which will result in a GitHub pull request on the projects you apply the executor to. You can then choose to merge that pull request whenever you’re ready to apply your Spring Boot version upgrade!

In Summary

Hot on the heels of the release announcement for Spring Boot 1.4.4 we have rapidly created a way of applying this upgrade to multiple projects and services across our real-estate.

This is a nice demonstration of how Atomist automates those annoying, manual code edits across a single project and across multiple projects as well.

In future articles we’ll dive deeper into Rug executors, and the even-newer handlers, that really show you how Atomist can be made to automate the many annoyances of your particular software development flow.

--

--

Russ Miles

People, Team and Organizational Developer. Writer, psychologist, speaker and humanistic Head of Engineering. https://twitter.com/russmiles