Maven Bin Plugin

Install and run executable libraries from Maven repos.

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

me.andrz.maven
ArtifactId

ArtifactId

maven-bin-maven-plugin
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

Maven Bin Plugin
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-maven-plugin

How to add to project

<plugin>
    <groupId>me.andrz.maven</groupId>
    <artifactId>maven-bin-maven-plugin</artifactId>
    <version>1.0.0</version>
</plugin>

Dependencies

compile (4)

Group / Artifact Type Version
me.andrz.maven : maven-bin-core jar 1.0.0
org.codehaus.groovy : groovy-all jar 2.4.2
org.slf4j : slf4j-simple jar 1.7.10
org.apache.maven : maven-plugin-api jar 3.3.1

provided (1)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.4

test (2)

Group / Artifact Type Version
junit : junit jar 4.11
org.apache.maven.plugin-testing : maven-plugin-testing-harness jar 3.3.0

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