Package: jgo
jgo: painless Java component executionSummaryMavenis a great tool. It manages dependencies so
that Java projects become reusable "building blocks" in a robust way, likepipfor Python,npmfor JavaScript,gemfor Ruby,cpanfor Perl, etc.
And theMaven Central repositorycontains a
tremendous wealth of code, ripe for reuse in your own projects.Unfortunately, Maven provides no easy way to actuallylaunch codefrom the
beautifully managed dependencies stored so lovingly into~/.m2/repository.This project fills that gap:jgolaunches Java code. You do not need to
download or install any JARs; you just specify an "endpoint" consisting of aMaven artifactidentifier, plus
a main class if needed/desired, andjgouses Maven to obtain and run it.To do this,jgobuilds the local environment on demand, caching it into a
subfolder of~/.jgo, so that the endpoint's particular dependencies are
available in one place.InstallationThejgoproject began life as a shell script, but was later translated into
Python, so that tools such asscyjavacould leverage its environment-building capabilities.As such, there are now two implementations from which to choose!
Each has pros and cons.Prerequisitesjgousesmvnandjavafor the heavy lifting.
The shell script version needs some common utilities (e.g.,cat).
If you are missing anything, the script will tell you.The shell scriptThejgo.shshell script requires a POSIX-friendly system. It is known to
work on Linux, macOS,Cygwin, Microsoft'sWindows Subsystem for Linux,
and Git BASH from theGit for Windowsproject.Installing the shell scriptJust clone this repo and symlinkjgo.shinto your favoritebindirectory.For example, assuming~/binis on your PATH:cdgitclonehttps://github.com/scijava/jgocdbin
ln-s../jgo/jgo.shjgo
jgo--helpThe Python moduleThe Python version ofjgooffers ajgoconsole script, as
well as ajgomodule for programmatically creating endpoints.Installing with pippipinstalljgoInstalling with condacondainstall-cconda-forgejgoInstalling from sourcegitclonehttps://github.com/scijava/jgocdjgo# install globally (not recommended unless using a virtual environment)pipinstall.# install into ~/.local (see pip install --help for details)pipinstall--user.# install into $PREFIXpipinstall--prefix=$PREFIX.# install globally in developer mode (hot linked to working copy folder)pipinstall-e.UsageUsage: jgo [-v] [-u] [-U] [-m] <jvm-args> <endpoint> <main-args>

  -v          : verbose mode flag
  -u          : update/regenerate cached environment
  -U          : force update from remote Maven repositories (implies -u)
  -m          : use endpoints for dependency management (see "Pitfalls" below)
  <jvm-args>  : any list of arguments to the JVM
  <endpoint>  : the artifact(s) + main class to execute
  <main-args> : any list of arguments to the main class

The endpoint should have one of the following formats:

- groupId:artifactId
- groupId:artifactId:version
- groupId:artifactId:mainClass
- groupId:artifactId:version:mainClass
- groupId:artifactId:version:classifier:mainClass

If version is omitted, then RELEASE is used.
If mainClass is omitted, it is auto-detected.
You can also write part of a class beginning with an @ sign,
and it will be auto-completed.

Multiple artifacts can be concatenated with pluses,
and all of them will be included on the classpath.
However, you should not specify multiple main classes.ExamplesProgramCommandJython REPLjgo org.python:jython-standaloneJRuby evalecho "puts 'Hello Ruby'" | jgo org.jruby:jruby-complete:@jruby.MainGroovy REPLjgo org.codehaus.groovy:groovy-groovysh:@shell.Main+commons-cli:commons-cli:1.3.1SciJava REPL with JRubyjgo org.scijava:scijava-common:@ScriptREPL+org.scijava:scripting-jrubySciJava REPL with Jythonjgo org.scijava:scijava-common:@ScriptREPL+org.scijava:scripting-jythonSciJava REPL with Groovyjgo org.scijava:scijava-common:@ScriptREPL+org.scijava:scripting-groovySciJava REPL with Clojurejgo org.scijava:scijava-common:@ScriptREPL+org.scijava:scripting-clojureSciJava REPL with JavaScriptjgo org.scijava:scijava-common:@ScriptREPL+org.scijava:scripting-javascriptNote the usage of the+syntax as needed to append elements to the classpath.FAQIs it fast?Endpoints are synthesized in a local cache under~/.jgo.
So invoking the same endpoint a second time is really quick.What does "no installation" mean?Classpath elements arehard-linkedinto~/.jgofrom~/.m2/repositoryrather than copied, so the~/.jgofolder has a tiny footprint even if you execute lots of different endpoints.What if an endpoint has a new version?Pass the-Uflag tojgoto rebuild the endpoint.
Note that unlikemvn, though,jgodoes not check for updates otherwise.ConfigurationYou can configure the behavior ofjgousing the~/.jgorcfile.RepositoriesYou can define additional remote Maven repositories,
from which artifacts will be retrieved. E.g.:[repositories]scijava.public=https://maven.scijava.org/content/groups/publicIf you need more control over where artifacts come from—for example, if you
want to use your own remote Maven repository as a mirror of Maven Central—you
can do it using Maven's usual~/.m2/settings.xml; seeUsing Mirrors for
Repositories.ShortcutsYou can define shortcuts for launching commonly used programs:[shortcuts]repl=imagej:org.scijava.script.ScriptREPLimagej=net.imagej:imagejfiji=sc.fiji:fiji:LATESTscifio=io.scif:scifio-cliShortcuts are substituted verbatim from the beginning of the endpoint,
single-pass in the order they are defined. So e.g. now you can run:jgoreplNote that with thereplshortcut above, the main class
(org.scijava.script.ScriptREPL) comes from adifferentartifact than
the toplevel artifact (net.imagej:imagej). This is intentional, so that
all ofImageJ, including all of the various SciJavascripting-<foo>plugins, is included in the classpath of the REPL.SettingsThere are a few configurable settings:[settings]m2Repo=/path/to/.m2Repo (default ~/.m2/repository)cacheDir=/path/to/.jgo (default ~/.jgo)links=soft (options: hard, soft, none; default hard)Note that thejgocache dir can also be set via theJGO_CACHE_DIRenvironment
variable when usingPythonjgo. The precedence of reading the cache dir, from
highest to lowest:JGO_CACHE_DIRenvironment variablecacheDirinsettingssections in~/.jgorcdefault to~/.jgoPitfallsDependency managementMaven has a feature whereby a project can override the versions of transitive
(a.k.a. inherited) dependencies, via a<dependencyManagement>configuration.
The problem is: a library may then believe it depends on components at
particular versions as defined by its<dependencyManagement>, but downstream
projects which depend on that library will resolve to different versions.
Seethis SO threadandthis gistfor full details.To work around this issue, you can pass-mto jgo, which
causes it to add all endpoints to the synthesized POM's<dependencyManagement>section usingimport scope.
By doing this, the versions of transitive dependencies used in the synthesized
project should more precisely match those of each endpoint itself—although in
the case of multiple endpoints concatenated via the+operator with
conflicting dependency management, the earlier endpoints will win because they
will be declared earlier in the POM. See alsoissue #9in the jgo issue tracker.DevelopmentCode stylejgousesblackfor its code style.Afterpip install tox, you can lint the code with:tox-elintAlternativesJBangmvnxJPM4J(discontinued)Mop(unmaintained)marun(unmaintained, Python 2 only)