apache / mina-sshd

Apache MINA sshd is a comprehensive Java library for client- and server-side SSH.
https://mina.apache.org/sshd-project/
Apache License 2.0
847 stars 353 forks source link

Support for Java 9+ modules #497

Closed rich7409 closed 1 month ago

rich7409 commented 1 month ago

Description

Hello. I'm trying to switch over from JSch to Mina SSHD but it's playing havoc with the Java 9 module system. There are packages in both sshd-core and sshd-common, and the modules system won't play ball with that. For example:

error: module spring.integration.sftp reads package org.apache.sshd.common.auth from both org.apache.sshd.core and org.apache.sshd.common

Do you have plans to make a Java 9 or greater release of SSHD that has full module-info.java in each part of the system?

Thanks, Richard.

Motivation

To be able to use Mina SSHD with Java9+ module path without errors.

Alternatives considered

Forking and moving the classes myself, then building with module-info.java in the source and building for Java 11.

Additional context

No response

tomaswolf commented 1 month ago

I agree this is a mess. That split into core and common was done in an awkward way that introduced split packages. Those are problematic not only with the Java module system but also in OSGi.

There is the org.apache.sshd.osgi artifact; it avoids this split package problem by re-combining core and common into one. For OSGi that works; it might also work for Java modules. However, if you use not OSGi with package imports only but a plain "fat jar" platform, you should probably override dependencies of other bundles (for instance, of "sftp") by excluding the "core" and "common" dependencies and adding the "osgi" dependency instead.

rich7409 commented 1 month ago

Thanks for the tip. Excluding core and common and using osgi instead has stopped it complaining about the modules.

I'll look forward to future versions with full module support. We're a lot of releases since Java 9 first came out but it's still a struggle with the modules because quite a few third party libraries don't have them included. I'm still not sure my code is working properly when they are enforced.