How to convert a Maven project to Gradle in real life

Gradle uses an elephant as its logo. Photo by Magda Ehlers from Pexels
Maven, as an Apache project, uses a feather as its logo. Photo by Evie Shaffer from Pexels.

Code Formatter, Contract Scaffolding, and Version Bumping

Well-maintained software may provide a Maven plugin and a Gradle one simultaneously. For example, the code formatter Spotless has a Maven edition and a Gradle edition. Across both build tools, Spotless recognizes the same set of configurations, so all you need to do is to translate some XML to Groovy — a trivial task.

Screenshot from its repo.
# Managed by the plugin `gradle-release`. Edit with caution.
version=0.0.1-SNAPSHOT

Publishing to a Maven Repository

Releasing and publishing often go hands in hands. Since you’re migrating a project from Maven, chances are that you are publishing its artifacts to a Maven Repository.

Maven’s use of a feather as its logo led me to envision a Maven Repository as a pile of feather. Photo by Nadejda Bostanova from Pexels.

Defining your own Maven Repository server

Your organization may have an internal Maven Repository. In that case, your pom.xml might have been configured with a Distribution Management tag:

Authenticating for Maven Repository

Pardon the cliche of using a stock photo of a key to represent the idea of authentication. Photo by PhotoMIX Company on Pexels.

Generate code from OpenAPI contracts

If you’re building API servers in 2022, you may be practicing Contract-First Development, with your contract adhering to OpenAPI Specification.

Parting Words

You may be surprised to learn how differently the two build tools grow their ecosystems. For many features, Maven boasts official plugins, whereas Gradle users rely on community efforts. Migrating from Maven to Gradle is no easy work.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ming

Ming

Tech writer with creative analogies. Website: https://myli.page | Donate: https://ko-fi.com/mingyli