Maven to install distribution

imagej

#1

Hi everybody,

I started having start scripts for various ‘command line tools’ in my bin directory that run Java tools. E.g. those in this repository:

These startscripts use a maven generated class-path in my local $HOME/.m2 repository to start the respective main class. One example:

#!/bin/bash

JAR=$HOME/.m2/repository/org/saalfeldlab/n5-utils/0.0.2-SNAPSHOT/n5-utils-0.0.2-SNAPSHOT.jar

java \
  -Xmx24g \
  -cp $JAR:$HOME/.m2/repository/args4j/args4j/2.0.29/args4j-2.0.29.jar:$HOME/.m2/repository/net/imglib2/imglib2/4.6.1/imglib2-4.6.1.jar:$HOME/.m2/repository/com/google/code/gson/gson/2.8.2/gson-2.8.2.jar:$HOME/.m2/repository/sc/fiji/bigdataviewer-core/4.3.2/bigdataviewer-core-4.3.2.jar:$HOME/.m2/repository/net/imglib2/imglib2-ui/2.0.0-beta-33/imglib2-ui-2.0.0-beta-33.jar:$HOME/.m2/repository/net/imglib2/imglib2-algorithm/0.8.2/imglib2-algorithm-0.8.2.jar:$HOME/.m2/repository/net/imglib2/imglib2-roi/0.4.7/imglib2-roi-0.4.7.jar:$HOME/.m2/repository/net/imagej/imagej-common/0.24.9/imagej-common-0.24.9.jar:$HOME/.m2/repository/edu/ucar/udunits/4.3.18/udunits-4.3.18.jar:$HOME/.m2/repository/net/sf/trove4j/trove4j/3.0.3/trove4j-3.0.3.jar:$HOME/.m2/repository/org/ojalgo/ojalgo/43.0/ojalgo-43.0.jar:$HOME/.m2/repository/sc/fiji/spim_data/2.2.1/spim_data-2.2.1.jar:$HOME/.m2/repository/cisd/jhdf5/14.12.6/jhdf5-14.12.6.jar:$HOME/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar:$HOME/.m2/repository/commons-io/commons-io/2.6/commons-io-2.6.jar:$HOME/.m2/repository/org/jdom/jdom2/2.0.6/jdom2-2.0.6.jar:$HOME/.m2/repository/org/scijava/ui-behaviour/1.3.0/ui-behaviour-1.3.0.jar:$HOME/.m2/repository/org/yaml/snakeyaml/1.13/snakeyaml-1.13.jar:$HOME/.m2/repository/org/janelia/saalfeldlab/n5/2.0.1/n5-2.0.1.jar:$HOME/.m2/repository/org/tukaani/xz/1.6/xz-1.6.jar:$HOME/.m2/repository/org/apache/commons/commons-compress/1.14/commons-compress-1.14.jar:$HOME/.m2/repository/net/jpountz/lz4/lz4/1.3.0/lz4-1.3.0.jar:$HOME/.m2/repository/org/scijava/scijava-common/2.69.0/scijava-common-2.69.0.jar:$HOME/.m2/repository/org/scijava/parsington/1.0.1/parsington-1.0.1.jar:$HOME/.m2/repository/com/googlecode/gentyref/gentyref/1.1.0/gentyref-1.1.0.jar:$HOME/.m2/repository/org/bushe/eventbus/1.4/eventbus-1.4.jar:$HOME/.m2/repository/org/janelia/saalfeldlab/n5-imglib2/2.0.0/n5-imglib2-2.0.0.jar:$HOME/.m2/repository/sc/fiji/bigdataviewer-vistools/1.0.0-beta-10/bigdataviewer-vistools-1.0.0-beta-10.jar:$HOME/.m2/repository/net/imglib2/imglib2-cache/1.0.0-beta-7/imglib2-cache-1.0.0-beta-7.jar:$HOME/.m2/repository/com/github/ben-manes/caffeine/caffeine/2.4.0/caffeine-2.4.0.jar:$HOME/.m2/repository/net/imglib2/imglib2-realtransform/2.0.0-beta-38/imglib2-realtransform-2.0.0-beta-38.jar:$HOME/.m2/repository/gov/nist/math/jama/1.0.3/jama-1.0.3.jar:$HOME/.m2/repository/jitk/jitk-tps/3.0.0/jitk-tps-3.0.0.jar:$HOME/.m2/repository/com/googlecode/efficient-java-matrix-library/ejml/0.24/ejml-0.24.jar:$HOME/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar:$HOME/.m2/repository/junit/junit/4.11/junit-4.11.jar:$HOME/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:$HOME/.m2/repository/org/janelia/saalfeldlab/n5-hdf5/1.0.1/n5-hdf5-1.0.1.jar \
  org.saalfeldlab.Copy \
  $@

You get the idea…

Now I would like to ‘distribute’ these tools to folks that really don’t or like understand or like Java, and do not want to checkout the source repository and build the project with maven. They can install maven though, because they are all on Ubuntu, i.e. sudo apt-get install maven isn’t asked too much. So, instead of running mvn install in the source repository, I would like to have a simple install command that fetches the jars from some maven repository and installs them. I have found this:

which uses mvn dependency:go-offline on a pom file with everything listed as dependencies to do the job. This would require me to maintain two pom files with the same content, not nice. I assume that there must be a simple way to do the exact same thing with the original pom file fetched from GitHub but without building the artifact, like

mvn install https://github.com/saalfeldlab/n5-utils/blob/master/pom.xml

Is there?

Thanks a lot for any help in advance.


#2

Two ideas immediately spring to mind:

  1. Publish your artifact to a Maven repository as usual, then tell your colleagues to use jrun. Then you can simply add a short illustration to your README; see parsington for an example.
  2. Use the appassembler Maven plugin; see scifio-cli for an example.

#3

Thanks @ctrueden. If I understand this correctly, jrun actually runs maven with all its significant overhead at start time, and the appassembler makes a fat jar—correct?


#4

Only the first time, to synthesize the endpoint. To actually run the program, it just invokes java.

Nope—at least not the way we used it for scifio-cli:

$ ls -R target/appassembler
bin/  repo/

target/appassembler/bin:
scifio*     scifio.bat

target/appassembler/repo:
args4j-2.0.25.jar                    scifio-0.30.0.jar
eventbus-1.4.jar                     scifio-cli-0.3.3-SNAPSHOT.jar
gentyref-1.1.0.jar                   scifio-jai-imageio-1.1.0.jar
imagej-common-0.24.1.jar             scijava-common-2.61.0.jar
imglib2-3.2.1.jar                    scijava-expression-parser-3.1.0.jar
imglib2-roi-0.4.4.jar                trove4j-3.0.3.jar
mapdb-1.0.3.jar                      udunits-4.3.18.jar