diff --git a/impl/maven-executor/src/main/java/org/apache/maven/api/cli/Executor.java b/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/Executor.java similarity index 98% rename from impl/maven-executor/src/main/java/org/apache/maven/api/cli/Executor.java rename to impl/maven-executor/src/main/java/org/apache/maven/cling/executor/Executor.java index 90c439195d0f..80107a9b8c87 100644 --- a/impl/maven-executor/src/main/java/org/apache/maven/api/cli/Executor.java +++ b/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/Executor.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.maven.api.cli; +package org.apache.maven.cling.executor; import org.apache.maven.api.annotations.Experimental; import org.apache.maven.api.annotations.Nonnull; diff --git a/impl/maven-executor/src/main/java/org/apache/maven/api/cli/ExecutorException.java b/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/ExecutorException.java similarity index 97% rename from impl/maven-executor/src/main/java/org/apache/maven/api/cli/ExecutorException.java rename to impl/maven-executor/src/main/java/org/apache/maven/cling/executor/ExecutorException.java index d1c4a918c1f0..8d8fbfde43fb 100644 --- a/impl/maven-executor/src/main/java/org/apache/maven/api/cli/ExecutorException.java +++ b/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/ExecutorException.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.maven.api.cli; +package org.apache.maven.cling.executor; import org.apache.maven.api.annotations.Experimental; import org.apache.maven.api.annotations.Nullable; diff --git a/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/ExecutorHelper.java b/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/ExecutorHelper.java index c6dc27feb0ae..8aea8b2a528c 100644 --- a/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/ExecutorHelper.java +++ b/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/ExecutorHelper.java @@ -19,9 +19,6 @@ package org.apache.maven.cling.executor; import org.apache.maven.api.annotations.Nonnull; -import org.apache.maven.api.cli.Executor; -import org.apache.maven.api.cli.ExecutorException; -import org.apache.maven.api.cli.ExecutorRequest; /** * Helper class for routing Maven execution based on preferences and/or issued execution requests. diff --git a/impl/maven-executor/src/main/java/org/apache/maven/api/cli/ExecutorRequest.java b/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/ExecutorRequest.java similarity index 99% rename from impl/maven-executor/src/main/java/org/apache/maven/api/cli/ExecutorRequest.java rename to impl/maven-executor/src/main/java/org/apache/maven/cling/executor/ExecutorRequest.java index b056c0f8454c..1e7118f0b627 100644 --- a/impl/maven-executor/src/main/java/org/apache/maven/api/cli/ExecutorRequest.java +++ b/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/ExecutorRequest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.maven.api.cli; +package org.apache.maven.cling.executor; import java.io.InputStream; import java.io.OutputStream; diff --git a/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/ExecutorTool.java b/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/ExecutorTool.java index 4bfe4be44804..4a9776742ff8 100644 --- a/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/ExecutorTool.java +++ b/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/ExecutorTool.java @@ -21,8 +21,6 @@ import java.util.Map; import org.apache.maven.api.annotations.Nullable; -import org.apache.maven.api.cli.ExecutorException; -import org.apache.maven.api.cli.ExecutorRequest; /** * A tool implementing some common Maven operations. diff --git a/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/embedded/EmbeddedMavenExecutor.java b/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/embedded/EmbeddedMavenExecutor.java index e5eda275d566..0e2ddaa4f6e1 100644 --- a/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/embedded/EmbeddedMavenExecutor.java +++ b/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/embedded/EmbeddedMavenExecutor.java @@ -45,9 +45,9 @@ import java.util.function.Function; import java.util.stream.Stream; -import org.apache.maven.api.cli.Executor; -import org.apache.maven.api.cli.ExecutorException; -import org.apache.maven.api.cli.ExecutorRequest; +import org.apache.maven.cling.executor.Executor; +import org.apache.maven.cling.executor.ExecutorException; +import org.apache.maven.cling.executor.ExecutorRequest; import static java.util.Objects.requireNonNull; @@ -267,7 +267,11 @@ protected Context doCreate(Path mavenHome, ExecutorRequest executorRequest) { throw new IllegalArgumentException(getClass().getSimpleName() + " w/ mvn3 does not support command " + executorRequest.command()); } - keepAlive.add(cliClass.getClassLoader().loadClass("org.fusesource.jansi.internal.JansiLoader")); + // 3.9.x + mayAddToKeepAlive(keepAlive, cliClass, "org.fusesource.jansi.internal.JansiLoader"); + // 3.10.x + mayAddToKeepAlive(keepAlive, cliClass, "org.jline.nativ.JLineNativeLoader"); + Constructor newMavenCli = cliClass.getConstructor(classWorld.getClass()); Object mavenCli = newMavenCli.newInstance(classWorld); Class[] parameterTypes = {String[].class, String.class, PrintStream.class, PrintStream.class}; @@ -292,7 +296,7 @@ protected Context doCreate(Path mavenHome, ExecutorRequest executorRequest) { }); } else { // assume 4.x - keepAlive.add(cliClass.getClassLoader().loadClass("org.jline.nativ.JLineNativeLoader")); + mayAddToKeepAlive(keepAlive, cliClass, "org.jline.nativ.JLineNativeLoader"); for (Map.Entry cmdEntry : MVN4_MAIN_CLASSES.entrySet()) { Class cmdClass = cliClass.getClassLoader().loadClass(cmdEntry.getValue()); Method mainMethod = cmdClass.getMethod( @@ -337,6 +341,15 @@ protected Context doCreate(Path mavenHome, ExecutorRequest executorRequest) { } } + private boolean mayAddToKeepAlive(List keepAlive, Class cliClass, String className) { + try { + keepAlive.add(cliClass.getClassLoader().loadClass(className)); + return true; + } catch (ClassNotFoundException e) { + return false; + } + } + protected Properties prepareProperties(ExecutorRequest request) { System.setProperties(null); // this "inits" them! diff --git a/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/forked/ForkedMavenExecutor.java b/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/forked/ForkedMavenExecutor.java index a559a24baf1b..4671c7427622 100644 --- a/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/forked/ForkedMavenExecutor.java +++ b/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/forked/ForkedMavenExecutor.java @@ -33,12 +33,12 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.maven.api.cli.Executor; -import org.apache.maven.api.cli.ExecutorException; -import org.apache.maven.api.cli.ExecutorRequest; +import org.apache.maven.cling.executor.Executor; +import org.apache.maven.cling.executor.ExecutorException; +import org.apache.maven.cling.executor.ExecutorRequest; import static java.util.Objects.requireNonNull; -import static org.apache.maven.api.cli.ExecutorRequest.getCanonicalPath; +import static org.apache.maven.cling.executor.ExecutorRequest.getCanonicalPath; /** * Forked executor implementation, that spawns a subprocess with Maven from the installation directory. Very costly diff --git a/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/internal/HelperImpl.java b/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/internal/HelperImpl.java index 8ba932cabf1b..d8109ba3e252 100644 --- a/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/internal/HelperImpl.java +++ b/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/internal/HelperImpl.java @@ -23,10 +23,10 @@ import java.util.concurrent.ConcurrentHashMap; import org.apache.maven.api.annotations.Nullable; -import org.apache.maven.api.cli.Executor; -import org.apache.maven.api.cli.ExecutorException; -import org.apache.maven.api.cli.ExecutorRequest; +import org.apache.maven.cling.executor.Executor; +import org.apache.maven.cling.executor.ExecutorException; import org.apache.maven.cling.executor.ExecutorHelper; +import org.apache.maven.cling.executor.ExecutorRequest; import static java.util.Objects.requireNonNull; diff --git a/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/internal/ToolboxTool.java b/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/internal/ToolboxTool.java index ad2569a84910..2adc21c43819 100644 --- a/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/internal/ToolboxTool.java +++ b/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/internal/ToolboxTool.java @@ -26,9 +26,9 @@ import java.util.Properties; import java.util.stream.Collectors; -import org.apache.maven.api.cli.ExecutorException; -import org.apache.maven.api.cli.ExecutorRequest; +import org.apache.maven.cling.executor.ExecutorException; import org.apache.maven.cling.executor.ExecutorHelper; +import org.apache.maven.cling.executor.ExecutorRequest; import org.apache.maven.cling.executor.ExecutorTool; import static java.util.Objects.requireNonNull; diff --git a/impl/maven-executor/src/test/java/org/apache/maven/cling/executor/MavenExecutorTestSupport.java b/impl/maven-executor/src/test/java/org/apache/maven/cling/executor/MavenExecutorTestSupport.java index 028efb029d8f..a2a095271cf6 100644 --- a/impl/maven-executor/src/test/java/org/apache/maven/cling/executor/MavenExecutorTestSupport.java +++ b/impl/maven-executor/src/test/java/org/apache/maven/cling/executor/MavenExecutorTestSupport.java @@ -28,8 +28,6 @@ import eu.maveniverse.maven.mimir.testing.MimirInfuser; import org.apache.maven.api.annotations.Nullable; -import org.apache.maven.api.cli.Executor; -import org.apache.maven.api.cli.ExecutorRequest; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/impl/maven-executor/src/test/java/org/apache/maven/cling/executor/embedded/EmbeddedMavenExecutorTest.java b/impl/maven-executor/src/test/java/org/apache/maven/cling/executor/embedded/EmbeddedMavenExecutorTest.java index c214fc6ffea7..6433235b6927 100644 --- a/impl/maven-executor/src/test/java/org/apache/maven/cling/executor/embedded/EmbeddedMavenExecutorTest.java +++ b/impl/maven-executor/src/test/java/org/apache/maven/cling/executor/embedded/EmbeddedMavenExecutorTest.java @@ -18,7 +18,7 @@ */ package org.apache.maven.cling.executor.embedded; -import org.apache.maven.api.cli.Executor; +import org.apache.maven.cling.executor.Executor; import org.apache.maven.cling.executor.MavenExecutorTestSupport; /** diff --git a/impl/maven-executor/src/test/java/org/apache/maven/cling/executor/forked/ForkedMavenExecutorTest.java b/impl/maven-executor/src/test/java/org/apache/maven/cling/executor/forked/ForkedMavenExecutorTest.java index 5555e0ba3494..a1f4362eac9b 100644 --- a/impl/maven-executor/src/test/java/org/apache/maven/cling/executor/forked/ForkedMavenExecutorTest.java +++ b/impl/maven-executor/src/test/java/org/apache/maven/cling/executor/forked/ForkedMavenExecutorTest.java @@ -18,7 +18,7 @@ */ package org.apache.maven.cling.executor.forked; -import org.apache.maven.api.cli.Executor; +import org.apache.maven.cling.executor.Executor; import org.apache.maven.cling.executor.MavenExecutorTestSupport; /** diff --git a/impl/maven-executor/src/test/java/org/apache/maven/cling/executor/impl/ToolboxToolTest.java b/impl/maven-executor/src/test/java/org/apache/maven/cling/executor/impl/ToolboxToolTest.java index 8152f2a790a2..fc856268248c 100644 --- a/impl/maven-executor/src/test/java/org/apache/maven/cling/executor/impl/ToolboxToolTest.java +++ b/impl/maven-executor/src/test/java/org/apache/maven/cling/executor/impl/ToolboxToolTest.java @@ -25,10 +25,10 @@ import java.util.Map; import eu.maveniverse.maven.mimir.testing.MimirInfuser; -import org.apache.maven.api.cli.Executor; -import org.apache.maven.api.cli.ExecutorRequest; import org.apache.maven.cling.executor.Environment; +import org.apache.maven.cling.executor.Executor; import org.apache.maven.cling.executor.ExecutorHelper; +import org.apache.maven.cling.executor.ExecutorRequest; import org.apache.maven.cling.executor.embedded.EmbeddedMavenExecutor; import org.apache.maven.cling.executor.forked.ForkedMavenExecutor; import org.apache.maven.cling.executor.internal.HelperImpl; diff --git a/its/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/Verifier.java b/its/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/Verifier.java index 32bc85f8f6bb..c0f29a2b3d16 100644 --- a/its/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/Verifier.java +++ b/its/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/Verifier.java @@ -45,8 +45,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.apache.maven.api.cli.ExecutorException; -import org.apache.maven.api.cli.ExecutorRequest; +import org.apache.maven.cling.executor.ExecutorException; +import org.apache.maven.cling.executor.ExecutorRequest; import org.apache.maven.cling.executor.ExecutorHelper; import org.apache.maven.cling.executor.ExecutorTool; import org.apache.maven.cling.executor.embedded.EmbeddedMavenExecutor;