Maven Bin CLI

Install and run executable libraries from Maven repos.

License

License

Categories

Categories

Maven Build Tools CLI User Interface
GroupId

GroupId

me.andrz.maven
ArtifactId

ArtifactId

maven-bin-cli
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

Maven Bin CLI
Install and run executable libraries from Maven repos.
Project URL

Project URL

https://github.com/adjohnson916/maven-bin
Source Code Management

Source Code Management

https://github.com/adjohnson916/maven-bin

Download maven-bin-cli

How to add to project

<!-- https://jarcasting.com/artifacts/me.andrz.maven/maven-bin-cli/ -->
<dependency>
    <groupId>me.andrz.maven</groupId>
    <artifactId>maven-bin-cli</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/me.andrz.maven/maven-bin-cli/
implementation 'me.andrz.maven:maven-bin-cli:1.0.0'
// https://jarcasting.com/artifacts/me.andrz.maven/maven-bin-cli/
implementation ("me.andrz.maven:maven-bin-cli:1.0.0")
'me.andrz.maven:maven-bin-cli:jar:1.0.0'
<dependency org="me.andrz.maven" name="maven-bin-cli" rev="1.0.0">
  <artifact name="maven-bin-cli" type="jar" />
</dependency>
@Grapes(
@Grab(group='me.andrz.maven', module='maven-bin-cli', version='1.0.0')
)
libraryDependencies += "me.andrz.maven" % "maven-bin-cli" % "1.0.0"
[me.andrz.maven/maven-bin-cli "1.0.0"]

Dependencies

test (1)

Group / Artifact Type Version
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

maven-bin

Maven Central Travis Appveyor Codecov

A CLI to install & run executable libraries from Maven repositories, with automagic classpathing of dependencies, and aliases on your global path. Sort of like npm's install --global.

Features

  • With a single command, install JARs and execute their main classes.
  • Install from any Maven repo, off or on-prem, e.g. Bintray, Artifactory, Archiva, or Nexus, via settings.xml.

Use

Executing

Executing a library will be sure it and all its dependencies are downloaded, then run a class in the JAR, defaulting to its main class.

mvbn org.apache.ant:ant -help

Or the long way:

mvn me.andrz.maven:maven-bin-maven-plugin:exec "-Dartifact=org.apache.ant:ant" "-Darguments=-help"

Non-Main Classes

Non-main classes can be specified with an @... suffix on the artifact coordinates, e.g.:

mvbn org.antlr:[email protected]

Installing

Installing a library will first download as above, then create an executable script file as a shortcut to execute it.

mvbn -i org.apache.ant:ant

Or the long way:

mvn me.andrz.maven:maven-bin-maven-plugin:install "-Dartifact=org.apache.ant:ant"

Now, you'll have a command for it, e.g.:

ant--org.apache.ant--1.9.6

But you'll probably want to specify aliases.

Aliases

mvbn -i -a ant org.apache.ant:ant

Or the long way:

mvn me.andrz.maven:maven-bin-maven-plugin:install "-Dartifact=org.apache.ant:ant" "-Dalias=ant"

Now, you'll have a command for it:

ant

Classpaths

Get the classpath for an artifact:

mvbn -c org.antlr:antlr4

For example, to use when compiling:

javac -cp "$(mvbn -c org.antlr:antlr4)" MyGrammar*.java

Install

General

To install maven-bin:

1. Install Core

mvn me.andrz.maven:maven-bin-maven-plugin:installSelf

2. Add to PATH

Add ~/.mvbn/bin to your system executable PATH.

Unix (macOS, Linux, etc.)

In your shell startup script (e.g. .profile, .bashrc, .bash_profile, .zshrc), add something like:

MAVEN_BIN="${HOME}/.mvbn/bin"
if [ -d "${MAVEN_BIN}" ]; then
  export PATH="${MAVEN_BIN}:$PATH"
fi
Windows

In your PowerShell profile, add something like:

$env:Path = $env:Path + ";${env:UserProfile}\.mvbn\bin;"

Development

git clone https://github.com/AndersDJohnson/maven-bin.git
cd maven-bin
mvn install

Wishlist

  • Aliasing (default group ID and versions)
    • Add aliased command executables to global path
  • Auto-complete CLI
    • Maybe via a generic Groovy CliBuilder completion integration for Bash, zsh, PowerShell, etc.?
  • Search repos

Dev

Set log level for slf4j simple:

Just this package:

org.slf4j.simpleLogger.log.me.andrz.maven.bin=debug

Or default (all packages):

-Dorg.slf4j.simpleLogger.defaultLogLevel=debug

Research

mvn dependency:copy "-Dartifact=org.apache.ant:ant:RELEASE" "-DoutputDirectory=./bin"
mvn dependency:get "-Dartifact=org.apache.ant:ant:RELEASE"
mvn -f "C:\Users\Anders\.m2\repository\com\google\guava\guava\18.0\guava-18.0.pom" org.apache.maven.plugins:maven-dependency-plugin:2.10:build-classpath
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:build-classpath "-Dmdep.outputFile=foo"
mvn -f .\mvn help:effective-pom

Versions

Version
1.0.0