Gum 0.7.2 delivers more bang for your buck

A bang, like in JBang! That's right, JBang is the new kid on the block in the Java command line tool space. Initially taking advantage of JEP-330 that enhances the Java launcher to support single source files, JBang builds on top of that idea and adds dependency resolution, JShell integration, launch executable JARs, launch scripts from trusted URLs, and a few other goodies. In other words, JBang is not constrained by JEP-330 (which requires Java 11) as it also let's you run scripts with Java 8. Taking a hint from Gradle and Maven, JBang also adds a wrapper to help you bootstrap and launch Java scripts on the go.

Gum is now able to launch JBang scripts whether there's a JBang wrapper in the current directory or if JBang is available in your system. Don't have JBang installed yet on your system? Give it a go with SDKMAN! There are other ways to install JBang as well. Now, Gum adds a bit more flavor to running JBang scripts, typically if running local files (*.java, *.jsh, *.jar) you'd have to specify the file you want to run, but depending on the situation Gum will help you out. If the current directory contains a single *.java, *.jsh, or *.jar then that file becomes the target. Thus instead of invoking

$ ls
$ jbang jbang runs jbang
Hello World [jbang, runs, jbang]

You can do this

$ gm gum runs jbang
Hello World [gum, runs, jbang]

And if the JBang wrapper happens to be in the same directory then it will be invoked instead of the globally available JBang binary. You may be asking what if I have 2 files or more? Well the first in alphabetical order will be chosen for you. What if there's a mix of *.java, *.jsh, and *jar files? Gum will invoke the first *.java file that it finds. You can of course specify the target file if Gum guesses wrong. You may also force Gum to treat the current directory as a JBang "project" using the -gj flag which will allow you to invoke JBang scripts that are found inside a Maven or Gradle project, neat!

Speaking of Gradle, Gum 0.7.2 also adds the option to replace task names per project. In past releases Gum would allow you to invoke the install goal and have it mapped to publishToMavenLocal but only if the goal was not prefixed by a project path, that is, invoking

$ gm install

However the following would fail as Gum would miss replacing the goal altogether.

$ gm :project1:install

This problem has been corrected in the latest release. As always, feedback is appreciated. If you find an issue or face a missing feature with Gum please head to and file a ticket.

Keep on coding!

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

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