Gum: the Gradle/Maven wrapper

I’m happy to announce the immediate availability of Gum, a Gradle/Maven wrapper written in Go. Gum is inspired on the popular gdub script by Doug Borg, which was ported to Go by Sten Roger Sandvik some time ago. The main difference from Sten’s version is that Gum also supports the Maven wrapper, coming up as part of Maven core 3.7!

The basic idea behind Gum is to prefer the tool wrapper over the plain tool, if the wrapper is configured. It also allows you invoke the build tool from any place withing the project’s codebase. There are a few additions and improvements such as:

Gradle

  • Detect if the filename follows the standard naming convention or if it’s named after the containing directory.
  • Support Groovy and Kotlin extensions.
  • Support running a specific build file if -b or –build-file is given (skips calculation of target build file).
  • If no build file is found then run from directory that contains the settings file.
  • Run the root build by default unless nearest (-gn) is set.

Maven

  • Same features as its Gradle counterpart.
  • Support running a specific build file if -f or –file is given (skips calculation of target build file).
  • Run the root pom.xml unless nearest (-gn) is set.

Gum will attempt to run the right command for you depending on the files it finds, attempting first Gradle then Maven. You can force the tool choice by specifying -gg for Gradle and -gm for Maven, in which case Gum will exit immediately if the build is not of the chosen type.

There are a couple of ways to install Gum depending on your preference. If you have Go installed then you can install Gum directly from its repository

$ go install github.com/kordmap/gm

Or you can clone the repository and build it yourself. If you’re into Homebrew the you can install it from the Kordamp tap

$ brew install kordamp/tap/gum

You can also snap it to install it on Linux

$ sudo snap install gum

Additionally you can download a pre-compiled binary from the releases page.

Note that the executable name is gm even though the project name is Gum. Why? One less character to type. Once you have Gum installed you use the gm command instead of gradlew, gradle, mvnw, or mvn, for example on a Maven build it’s enough to invoke

$ gm verify

To build artifacts and run checks. For a Gradle build you would invoke

$ gm build

In other words, gm takes all arguments and passes them to the underlying build tool once it has been resolved.

Gum supports the following flags

  • -gg force Gradle build
  • -gh displays help information
  • -gm force Maven build
  • -gn executes nearest build file
  • -gq run gm in quiet mode
  • -gv displays version information

Gum will execute the build based on the root build file unless -gn is specified, in which case the nearest build file will be selected. If a specific build file is given (-b, –build-file for Gradle; -f, –file for Maven) then that file will be used instead

Keep on coding!

 

Liked it? Take a second to support aalmiray on Patreon!

5 comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

ˆ Back To Top