mqtt-cli icon indicating copy to clipboard operation
mqtt-cli copied to clipboard

jbang mqtt-cli@hivemq ?

Open maxandersen opened this issue 1 month ago • 1 comments

Problem or use case

I would like to suggest to enable and document how to run/install mqtt using jbang.

jbang can run any jar directly:

jbang https://github.com/hivemq/mqtt-cli/releases/download/v4.47.0/mqtt-cli-4.47.0.jar

or if there was a mqtt-cli published to maven central it could be:

jbang com.hivemq:hivemq-mqtt-cli:RELEASE

in both cases you can do jbang app install <mqtt-cli.jar> and mqtt-cli will be available on the path to run.

To mimic the naming mqtt-cli has you would do jbang app install --name mqtt <mqtt-cli.jar> and it would be mqtt on the classpath.

The advantage over the "fat-jar" and the maven coordinates is that the latter will result in you only downloading the bits you don't already have in in your maven repository (if any).

To simplify all these long names and specific version installs I would suggest creating a jbang-catalog which allows for a shorter name, i.e. jbang mqtt@hivemq and if the cli would be published to maven central users could use jbang com.hivemq:hivemq-mqtt-cli:RELEASE if they wanted explict control over the version.

Preferred solution or suggestions

  1. make a jbang-catalog.json (I can provide initial PR for this), either in hivemq/mqtt-cli or hivemq/jbang-catalog. The latter is a new repository which allow to have the shortest name possible (mqtt@hivemq vs mqtt@hivemq/mqtt-cli)

  2. (optionally but recommended) publish mqtt-cli to maven central to allow for easy and more efficient maven GAV references

  3. if not doing no. 2, have a stable named mqtt-cli.jar attached to releases so one can use jbang https://github.com/hivemq/mqtt-cli/releases/latest/download/mqtt-cli.jar to get latest.

advantage of this is:

  1. easier way to try out mqtt without having to manually download artifacts from releases (jbang mqtt@hivemind if you already have jbang, or curl -Ls https://sh.jbang.dev | bash -s - mqtt@hivemind to get java/jbang and mqtt as needed.
  2. much smaller download for those who already have java/jbang installed
  3. ability to reuse the artifacts you already have downloaded as jbang will resolve and fetch only what is needed from maven metadata.

wdyt?

maxandersen avatar Dec 12 '25 00:12 maxandersen