This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-scm.git


The following commit(s) were added to refs/heads/master by this push:
     new 092eed6bf Use SSHD 2.16.0
092eed6bf is described below

commit 092eed6bfca4921fe223d451a54a993fd6a33894
Author: Konrad Windszus <k...@apache.org>
AuthorDate: Tue Sep 16 15:28:29 2025 +0200

    Use SSHD 2.16.0
    
    This removes the need for shipping a custom GitPackCommand as
    https://github.com/apache/mina-sshd/issues/793 is fixed there.
    
    Force JGit 5 to use newer SSHD too.
---
 .../maven-scm-provider-gittest/pom.xml             |   5 -
 .../maven/scm/provider/git/GitSshServer.java       |   3 +-
 .../provider/git/sshd/git/pack/GitPackCommand.java | 109 ---------------------
 .../git/sshd/git/pack/GitPackCommandFactory.java   |  65 ------------
 .../scm/provider/git/sshd/git/pack/README.txt      |   5 -
 .../maven-scm-provider-jgit/pom.xml                |  16 +++
 .../maven-scm-providers-git/pom.xml                |   4 +
 7 files changed, 21 insertions(+), 186 deletions(-)

diff --git 
a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/pom.xml
 
b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/pom.xml
index f5e99d3dc..8d6071c9d 100644
--- 
a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/pom.xml
+++ 
b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/pom.xml
@@ -31,11 +31,6 @@
   <name>Maven SCM Git Provider TCK Tests</name>
   <description>Tests library for SCM Git Provider.</description>
 
-  <properties>
-    <!-- newer versions clash with Sshd dependencies from JGit 5.x-->
-    <minaSshdVersion>2.11.0</minaSshdVersion>
-  </properties>
-
   <dependencies>
     <dependency>
       <groupId>org.apache.maven.scm</groupId>
diff --git 
a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/GitSshServer.java
 
b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/GitSshServer.java
index 514ce09ef..a58525907 100644
--- 
a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/GitSshServer.java
+++ 
b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/GitSshServer.java
@@ -31,11 +31,11 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.maven.scm.provider.git.sshd.git.pack.GitPackCommandFactory;
 import org.apache.sshd.common.config.keys.KeyUtils;
 import 
org.apache.sshd.common.config.keys.writer.openssh.OpenSSHKeyEncryptionContext;
 import 
org.apache.sshd.common.config.keys.writer.openssh.OpenSSHKeyPairResourceWriter;
 import org.apache.sshd.git.GitLocationResolver;
+import org.apache.sshd.git.pack.GitPackCommandFactory;
 import org.apache.sshd.server.SshServer;
 import org.apache.sshd.server.auth.pubkey.KeySetPublickeyAuthenticator;
 import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
@@ -132,7 +132,6 @@ public Path resolveRootDirectory(String command, String[] 
args, ServerSession se
                 return repositoryRoot;
             }
         };
-        // use patched version of GitPackCommandFactory including 
https://github.com/apache/mina-sshd/pull/794
         sshServer.setCommandFactory(new 
GitPackCommandFactory(gitLocationResolver));
         sshServer.start();
     }
diff --git 
a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/sshd/git/pack/GitPackCommand.java
 
b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/sshd/git/pack/GitPackCommand.java
deleted file mode 100644
index 614a680e9..000000000
--- 
a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/sshd/git/pack/GitPackCommand.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.scm.provider.git.sshd.git.pack;
-
-import java.io.IOException;
-import java.nio.file.Path;
-import java.util.List;
-
-import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.common.util.ValidateUtils;
-import org.apache.sshd.common.util.threads.CloseableExecutorService;
-import org.apache.sshd.git.AbstractGitCommand;
-import org.apache.sshd.git.GitLocationResolver;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.lib.RepositoryCache;
-import org.eclipse.jgit.transport.ReceivePack;
-import org.eclipse.jgit.transport.RemoteConfig;
-import org.eclipse.jgit.transport.UploadPack;
-import org.eclipse.jgit.util.FS;
-
-/**
- * TODO Add javadoc.
- *
- * @author <a href="mailto:d...@mina.apache.org";>Apache MINA SSHD Project</a>
- */
-public class GitPackCommand extends AbstractGitCommand {
-    /**
-     * @param rootDirResolver resolver for GIT root directory
-     * @param command         command to execute
-     * @param executorService an {@link CloseableExecutorService} to be used 
when
-     *                        {@code start(ChannelSession, Environment)}-ing 
execution. If {@code null} an ad-hoc
-     *                        single-threaded service is created and used.
-     */
-    public GitPackCommand(
-            GitLocationResolver rootDirResolver, String command, 
CloseableExecutorService executorService) {
-        super(rootDirResolver, command, executorService);
-    }
-
-    @Override
-    public void run() {
-        String command = getCommand();
-        try {
-            List<String> strs = parseDelimitedString(command, " ", true);
-            String[] args = strs.toArray(new String[strs.size()]);
-            for (int i = 0; i < args.length; i++) {
-                String argVal = args[i];
-                if (argVal.startsWith("'") && argVal.endsWith("'")) {
-                    args[i] = argVal.substring(1, argVal.length() - 1);
-                    argVal = args[i];
-                }
-                if (argVal.startsWith("\"") && argVal.endsWith("\"")) {
-                    args[i] = argVal.substring(1, argVal.length() - 1);
-                }
-            }
-
-            if (args.length != 2) {
-                throw new IllegalArgumentException("Invalid git command line 
(no arguments): " + command);
-            }
-
-            Path rootDir = resolveRootDirectory(command, args);
-            RepositoryCache.FileKey key = 
RepositoryCache.FileKey.lenient(rootDir.toFile(), FS.DETECTED);
-            try (Repository db = key.open(true /* must exist */)) {
-                String subCommand = args[0];
-                if (RemoteConfig.DEFAULT_UPLOAD_PACK.equals(subCommand)) {
-                    new UploadPack(db).upload(getInputStream(), 
getOutputStream(), getErrorStream());
-                } else if 
(RemoteConfig.DEFAULT_RECEIVE_PACK.equals(subCommand)) {
-                    new ReceivePack(db).receive(getInputStream(), 
getOutputStream(), getErrorStream());
-                } else {
-                    throw new IllegalArgumentException("Unknown git command: " 
+ command);
-                }
-            }
-            onExit(0);
-        } catch (Throwable t) {
-            onExit(-1, t.getClass().getSimpleName());
-        }
-    }
-
-    protected Path resolveRootDirectory(String command, String[] args) throws 
IOException {
-        GitLocationResolver resolver = getGitLocationResolver();
-        Path rootDir = resolver.resolveRootDirectory(command, args, 
getServerSession(), getFileSystem());
-        ValidateUtils.checkState(rootDir != null, "No root directory provided 
for %s command", command);
-
-        String pathArg = args[1];
-        int len = GenericUtils.length(pathArg);
-        // Strip any leading path separator since we use relative to root
-        if ((len > 0) && (pathArg.charAt(0) == '/')) {
-            pathArg = pathArg.substring(1);
-        }
-
-        ValidateUtils.checkNotNullAndNotEmpty(pathArg, "No %s command sub-path 
specified", args[0]);
-        return rootDir.resolve(pathArg);
-    }
-}
diff --git 
a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/sshd/git/pack/GitPackCommandFactory.java
 
b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/sshd/git/pack/GitPackCommandFactory.java
deleted file mode 100644
index ea5e6bc42..000000000
--- 
a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/sshd/git/pack/GitPackCommandFactory.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.scm.provider.git.sshd.git.pack;
-
-import java.util.function.Supplier;
-
-import org.apache.sshd.common.util.threads.CloseableExecutorService;
-import org.apache.sshd.git.AbstractGitCommandFactory;
-import org.apache.sshd.git.GitLocationResolver;
-import org.apache.sshd.server.command.CommandFactory;
-
-/**
- * TODO Add javadoc.
- *
- * @author <a href="mailto:d...@mina.apache.org";>Apache MINA SSHD Project</a>
- */
-public class GitPackCommandFactory extends AbstractGitCommandFactory {
-    public static final String GIT_FACTORY_NAME = "git-pack";
-    public static final String GIT_COMMAND_PREFIX = "git-";
-
-    public GitPackCommandFactory() {
-        this(null);
-    }
-
-    public GitPackCommandFactory(GitLocationResolver resolver) {
-        super(GIT_FACTORY_NAME, GIT_COMMAND_PREFIX);
-        withGitLocationResolver(resolver);
-    }
-
-    @Override
-    public GitPackCommandFactory withDelegate(CommandFactory delegate) {
-        return (GitPackCommandFactory) super.withDelegate(delegate);
-    }
-
-    @Override
-    public GitPackCommandFactory withGitLocationResolver(GitLocationResolver 
rootDirResolver) {
-        return (GitPackCommandFactory) 
super.withGitLocationResolver(rootDirResolver);
-    }
-
-    @Override
-    public GitPackCommandFactory withExecutorServiceProvider(Supplier<? 
extends CloseableExecutorService> provider) {
-        return (GitPackCommandFactory) 
super.withExecutorServiceProvider(provider);
-    }
-
-    @Override
-    public GitPackCommand createGitCommand(String command) {
-        return new GitPackCommand(getGitLocationResolver(), command, 
resolveExecutorService(command));
-    }
-}
diff --git 
a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/sshd/git/pack/README.txt
 
b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/sshd/git/pack/README.txt
deleted file mode 100644
index 616060a96..000000000
--- 
a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/sshd/git/pack/README.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-This is just a minimum fork of 
https://github.com/apache/mina-sshd/tree/sshd-2.11.0/sshd-git/src/main/java/org/apache/sshd/git/pack
-to include the patch https://github.com/apache/mina-sshd/pull/794.
-
-Otherwise, the SSH server cannot be used on Windows as it leaves files open.
-TODO: Remove once a Mina SSHD release is available that includes this patch.
\ No newline at end of file
diff --git 
a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/pom.xml 
b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/pom.xml
index c457eb38a..5a6d98098 100644
--- 
a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/pom.xml
+++ 
b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/pom.xml
@@ -35,6 +35,22 @@
     <!-- version 6+ requires Java 11 -->
     <jgitVersion>5.13.3.202401111512-r</jgitVersion>
   </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <!-- upgrade SSHD used in JGit to newer version for being compatible 
with ITs -->
+      <dependency>
+        <groupId>org.apache.sshd</groupId>
+        <artifactId>sshd-sftp</artifactId>
+        <version>${minaSshdVersion}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.sshd</groupId>
+        <artifactId>sshd-osgi</artifactId>
+        <version>${minaSshdVersion}</version>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
   <dependencies>
     <dependency>
       <groupId>javax.inject</groupId>
diff --git a/maven-scm-providers/maven-scm-providers-git/pom.xml 
b/maven-scm-providers/maven-scm-providers-git/pom.xml
index 6e4c35006..08e893adf 100644
--- a/maven-scm-providers/maven-scm-providers-git/pom.xml
+++ b/maven-scm-providers/maven-scm-providers-git/pom.xml
@@ -39,6 +39,10 @@
     <module>maven-scm-provider-jgit</module>
   </modules>
 
+  <properties>
+    <minaSshdVersion>2.16.0</minaSshdVersion>
+  </properties>
+
   <profiles>
     <profile>
       <id>tck-git</id>

Reply via email to