From f6ef2f620110d1e62b69f3cfca017bac2784e6fb Mon Sep 17 00:00:00 2001 From: Thomas Wolf Date: Sun, 31 Oct 2021 14:57:30 +0100 Subject: [PATCH] [doc] Add README and package-info to the SSH bundles Explain in the JSch bundle that it is essentially unmaintained. Add descriptions in both bundles explaining how to use it, or how to use an alternate implementation. Change-Id: Idaf46c33b14543279f78a55cb7c6bd42b06ee6b8 Signed-off-by: Thomas Wolf --- org.eclipse.jgit.ssh.apache/README.md | 61 +++++++++++++++++++ .../jgit/transport/sshd/package-info.java | 6 ++ org.eclipse.jgit.ssh.jsch/README.md | 59 ++++++++++++++++++ .../jgit/transport/ssh/jsch/package-info.java | 14 +++++ 4 files changed, 140 insertions(+) create mode 100644 org.eclipse.jgit.ssh.apache/README.md create mode 100644 org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/package-info.java create mode 100644 org.eclipse.jgit.ssh.jsch/README.md create mode 100644 org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/ssh/jsch/package-info.java diff --git a/org.eclipse.jgit.ssh.apache/README.md b/org.eclipse.jgit.ssh.apache/README.md new file mode 100644 index 000000000..3bbda523b --- /dev/null +++ b/org.eclipse.jgit.ssh.apache/README.md @@ -0,0 +1,61 @@ +# JGit SSH support via Apache MINA sshd + +This bundle provides an implementation of git transport over SSH implemented via +[Apache MINA sshd](https://mina.apache.org/sshd-project/). + +## Service registration + +This bundle declares a service for the `java.util.ServiceLoader` for interface +`org.eclipse.jgit.transport.ssh.SshSessionFactory`. The core JGit bundle uses the service +loader to pick up an implementation of that interface. + +Note that JGit simply uses the first `SshSessionFactory` provided by the `ServiceLoader`. + +If the service loader cannot find the session factory, either ensure that the service +declaration is on the Classpath of bundle `org.eclipse.jgit`, or set the factory explicitly +(see below). + +In an OSGi environment, one might need a service loader bridge, or have a little OSGi +fragment for bundle `org.eclipse.jgit` that puts the right service declaration onto the +Classpath of that bundle. (OSGi fragments become part of the Classpath of their host +bundle.) + +## Configuring an SSH implementation for JGit + +The simplest way to set an SSH implementation for JGit is to install it globally via +`SshSessionFactory.setInstance()`. This instance will be used by JGit for all SSH +connections by default. + +It is also possible to set the SSH implementation individually for any git command +that needs a transport (`TransportCommand`) via a `org.eclipse.jgit.api.TransportConfigCallback`. + +To do so, set the wanted `SshSessionFactory` on the SSH transport, like: + +```java +SshSessionFactory customFactory = ...; // Get it from wherever +FetchCommand fetch = git.fetch() + .setTransportConfigCallback(transport -> { + if (transport instanceof SshTransport) { + ((SshTransport) transport).setSshSessionFactory(customFactory); + } + }) + ... + .call(); +``` + +## Using a different SSH implementation + +To use a different SSH implementation: + +* Do not include this bundle in your product. +* Include the bundle of the alternate implementation. + * If the service loader finds the alternate implementation, nothing more is needed. + * Otherwise ensure the service declaration from the other bundle is on the Classpath of bundle `org.eclipse.jgit`, + * or set the `SshSessionFactory` for JGit explicitly (see above). + +## Using an external SSH executable + +JGit has built-in support for not using any Java SSH implementation but an external SSH +executable. To use an external SSH executable, set environment variable **GIT_SSH** to +the path of the executable. JGit will create a sub-process to run the executable and +communicate with this sup-process to perform the git operation. diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/package-info.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/package-info.java new file mode 100644 index 000000000..926234a3b --- /dev/null +++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/package-info.java @@ -0,0 +1,6 @@ +/** + * Provides a JGit {@link org.eclipse.jgit.transport.SshSessionFactory} + * implemented via Apache MINA + * sshd. + */ +package org.eclipse.jgit.transport.sshd; diff --git a/org.eclipse.jgit.ssh.jsch/README.md b/org.eclipse.jgit.ssh.jsch/README.md new file mode 100644 index 000000000..48f43f0f8 --- /dev/null +++ b/org.eclipse.jgit.ssh.jsch/README.md @@ -0,0 +1,59 @@ +# JGit SSH support via JSch + +This bundle provides an implementation of git transport over SSH implemented via JSch. + +**This bundle should be considered deprecated**. It is essentially unmaintained, and +the JGit project may decide anytime to remove it completely without further ado. + +The officially supported SSH transport is in bundle `org.eclipse.jgit.ssh.apache` and is +built upon [Apache MINA sshd](https://mina.apache.org/sshd-project/). + +## Service registration + +This bundle declares a service for the `java.util.ServiceLoader` for interface +`org.eclipse.jgit.transport.ssh.SshSessionFactory`. The core JGit bundle uses the service +loader to pick up an implementation of that interface. The bundle in an OSGi fragment +to ensure that the service loader works in an OSGi environment without the need to +install a service loader bridge. + +Note that JGit simply uses the first `SshSessionFactory` provided by the `ServiceLoader`. + +## Using a different SSH implementation + +To use a different SSH implementation: + +* Do not include this bundle in your product. +* Include the bundle of the alternate implementation. + * If the service loader finds the alternate implementation, nothing more is needed. + * Otherwise ensure the service declaration from the other bundle is on the Classpath of bundle `org.eclipse.jgit`, + * or set the `SshSessionFactory` for JGit explicitly (see below). + +## Configuring an SSH implementation for JGit + +The simplest way to set an SSH implementation for JGit is to install it globally via +`SshSessionFactory.setInstance()`. This instance will be used by JGit for all SSH +connections by default. + +It is also possible to set the SSH implementation individually for any git command +that needs a transport (`TransportCommand`) via a `org.eclipse.jgit.api.TransportConfigCallback`. + +To do so, set the wanted `SshSessionFactory` on the SSH transport, like: + +```java +SshSessionFactory customFactory = ...; // Get it from wherever +FetchCommand fetch = git.fetch() + .setTransportConfigCallback(transport -> { + if (transport instanceof SshTransport) { + ((SshTransport) transport).setSshSessionFactory(customFactory); + } + }) + ... + .call(); +``` + +## Using an external SSH executable + +JGit has built-in support for not using any Java SSH implementation but an external SSH +executable. To use an external SSH executable, set environment variable **GIT_SSH** to +the path of the executable. JGit will create a sub-process to run the executable and +communicate with this sup-process to perform the git operation. diff --git a/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/ssh/jsch/package-info.java b/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/ssh/jsch/package-info.java new file mode 100644 index 000000000..dc2915a09 --- /dev/null +++ b/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/ssh/jsch/package-info.java @@ -0,0 +1,14 @@ +/** + * Provides a JGit {@link org.eclipse.jgit.transport.SshSessionFactory} + * implemented via JSch. + *

+ * This package should be considered deprecated. It is essentially + * unmaintained and the JGit project may decide to remove it completely without + * further ado at any time. + *

+ *

+ * The officially supported Java SSH implementation for JGit is in bundle + * {@code org.eclipse.jgit.ssh.apache} and is built upon + * Apache MINA sshd. + */ +package org.eclipse.jgit.transport.ssh.jsch;