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:
- 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.
- 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!
As far as I can tell, there’s no usage instructions. How are you supposed to use this sucker?
Hi Matt, Gum is a replacement for gdub, so it’s used in the same way as gdub is, for example
// on a Maven build
$ gm verify
// on a Gradle build
$ gm build
Effectively Gum passes all command args to the underlying build tool (gradlew. gradle, mvnw, mvn) plus it handles specific Gum flags as shown at https://github.com/kordamp/gm
I’ve never understood why I would want to use a wrapper. It just seems like an extra layer of maintenance for the repo maintainer. What’s so hard about ‘mvn install’?
Mike, the short answer is to bootstrap the build tool on a system that does not have the build tool installed. A longer answer can be found at https://andresalmiray.com/why-do-the-gradle-maven-wrappers-matter/
It improves reproducability.