diff --git a/apache-maven/src/assembly/component.xml b/apache-maven/src/assembly/component.xml
index 347dee1d5cd1..9a6d61dc5cc5 100644
--- a/apache-maven/src/assembly/component.xml
+++ b/apache-maven/src/assembly/component.xml
@@ -85,6 +85,7 @@ under the License.
mvn
mvnenc
mvnDebug
+ mvnencDebug
mvnyjp
diff --git a/apache-maven/src/assembly/maven/bin/mvnencDebug b/apache-maven/src/assembly/maven/bin/mvnencDebug
new file mode 100644
index 000000000000..50b3e6749250
--- /dev/null
+++ b/apache-maven/src/assembly/maven/bin/mvnencDebug
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# 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.
+
+# -----------------------------------------------------------------------------
+# Apache Maven Debug Script
+#
+# Environment Variable Prerequisites
+#
+# JAVA_HOME (Optional) Points to a Java installation.
+# MAVEN_OPTS (Optional) Java runtime options used when Maven is executed.
+# MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files.
+# MAVEN_DEBUG_ADDRESS (Optional) Set the debug address. Default value is localhost:8000
+# -----------------------------------------------------------------------------
+
+MAVEN_DEBUG_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${MAVEN_DEBUG_ADDRESS:-localhost:8000}"
+
+echo Preparing to execute Maven in debug mode
+
+env MAVEN_OPTS="$MAVEN_OPTS" MAVEN_DEBUG_OPTS="$MAVEN_DEBUG_OPTS" "`dirname "$0"`/mvnenc" "$@"
diff --git a/apache-maven/src/assembly/maven/bin/mvnencDebug.cmd b/apache-maven/src/assembly/maven/bin/mvnencDebug.cmd
new file mode 100644
index 000000000000..22a869cd5bd9
--- /dev/null
+++ b/apache-maven/src/assembly/maven/bin/mvnencDebug.cmd
@@ -0,0 +1,44 @@
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements. See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership. The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License. You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied. See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+
+@REM -----------------------------------------------------------------------------
+@REM Apache Maven Debug Script
+@REM
+@REM Environment Variable Prerequisites
+@REM
+@REM JAVA_HOME (Optional) Points to a Java installation.
+@REM MAVEN_BATCH_ECHO (Optional) Set to 'on' to enable the echoing of the batch commands.
+@REM MAVEN_BATCH_PAUSE (Optional) set to 'on' to wait for a key stroke before ending.
+@REM MAVEN_OPTS (Optional) Java runtime options used when Maven is executed.
+@REM MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files.
+@REM MAVEN_DEBUG_ADDRESS (Optional) Set the debug address. Default value is localhost:8000
+@REM -----------------------------------------------------------------------------
+
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM set title of command window
+title %0
+@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%"=="on" echo %MAVEN_BATCH_ECHO%
+
+@setlocal
+
+if "%MAVEN_DEBUG_ADDRESS%"=="" @set MAVEN_DEBUG_ADDRESS=localhost:8000
+
+@set MAVEN_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%MAVEN_DEBUG_ADDRESS%
+
+@call "%~dp0"mvnenc.cmd %*
diff --git a/api/maven-api-cli/src/main/java/org/apache/maven/api/cli/mvnenc/EncryptOptions.java b/api/maven-api-cli/src/main/java/org/apache/maven/api/cli/mvnenc/EncryptOptions.java
index a70e856e3a3e..910d0375eaaf 100644
--- a/api/maven-api-cli/src/main/java/org/apache/maven/api/cli/mvnenc/EncryptOptions.java
+++ b/api/maven-api-cli/src/main/java/org/apache/maven/api/cli/mvnenc/EncryptOptions.java
@@ -36,28 +36,18 @@
@Experimental
public interface EncryptOptions extends Options {
/**
- * Returns the cipher that the user wants to use for non-dispatched encryption.
+ * Should the operation be forced (ie overwrite existing config, if any).
*
- * @return an {@link Optional} containing the cipher string, or empty if not specified
+ * @return an {@link Optional} containing the boolean value {@code true} if specified, or empty
*/
- @Nonnull
- Optional cipher();
+ Optional force();
/**
- * Returns the master source that the user wants to use for non-dispatched encryption.
+ * Should imply "yes" to all questions.
*
- * @return an {@link Optional} containing the master source string, or empty if not specified
+ * @return an {@link Optional} containing the boolean value {@code true} if specified, or empty
*/
- @Nonnull
- Optional masterSource();
-
- /**
- * Returns the dispatcher to use for dispatched encryption.
- *
- * @return an {@link Optional} containing the dispatcher string, or empty if not specified
- */
- @Nonnull
- Optional dispatcher();
+ Optional yes();
/**
* Returns the list of encryption goals to be executed.
diff --git a/maven-cli/pom.xml b/maven-cli/pom.xml
index 1ce18d63d50e..8c79d44942d2 100644
--- a/maven-cli/pom.xml
+++ b/maven-cli/pom.xml
@@ -92,6 +92,10 @@ under the License.
+
+ org.eclipse.sisu
+ sisu-maven-plugin
+
org.apache.maven.plugins
maven-jar-plugin
diff --git a/maven-cli/src/main/java/org/apache/maven/cling/ClingSupport.java b/maven-cli/src/main/java/org/apache/maven/cling/ClingSupport.java
index 5ea9ec72dbae..ba65331388fe 100644
--- a/maven-cli/src/main/java/org/apache/maven/cling/ClingSupport.java
+++ b/maven-cli/src/main/java/org/apache/maven/cling/ClingSupport.java
@@ -25,7 +25,6 @@
import org.apache.maven.api.cli.InvokerRequest;
import org.apache.maven.api.cli.Options;
import org.apache.maven.api.cli.ParserException;
-import org.apache.maven.jline.MessageUtils;
import org.codehaus.plexus.classworlds.ClassWorld;
import static java.util.Objects.requireNonNull;
@@ -65,8 +64,6 @@ private ClingSupport(ClassWorld classWorld, boolean classWorldManaged) {
* The main entry point.
*/
public int run(String[] args) throws IOException {
- MessageUtils.systemInstall();
- MessageUtils.registerShutdownHook();
try (Invoker invoker = createInvoker()) {
return invoker.invoke(parseArguments(args));
} catch (ParserException e) {
@@ -75,12 +72,8 @@ public int run(String[] args) throws IOException {
} catch (InvokerException e) {
return 1;
} finally {
- try {
- if (classWorldManaged) {
- classWorld.close();
- }
- } finally {
- MessageUtils.systemUninstall();
+ if (classWorldManaged) {
+ classWorld.close();
}
}
}
diff --git a/maven-cli/src/main/java/org/apache/maven/cling/MavenCling.java b/maven-cli/src/main/java/org/apache/maven/cling/MavenCling.java
index b8b204d5f470..691f207fb53d 100644
--- a/maven-cli/src/main/java/org/apache/maven/cling/MavenCling.java
+++ b/maven-cli/src/main/java/org/apache/maven/cling/MavenCling.java
@@ -29,6 +29,7 @@
import org.apache.maven.cling.invoker.mvn.DefaultMavenParser;
import org.apache.maven.cling.invoker.mvn.local.DefaultLocalMavenInvoker;
import org.apache.maven.jline.JLineMessageBuilderFactory;
+import org.apache.maven.jline.MessageUtils;
import org.codehaus.plexus.classworlds.ClassWorld;
/**
@@ -59,6 +60,17 @@ public MavenCling(ClassWorld classWorld) {
super(classWorld);
}
+ @Override
+ public int run(String[] args) throws IOException {
+ MessageUtils.systemInstall();
+ MessageUtils.registerShutdownHook();
+ try {
+ return super.run(args);
+ } finally {
+ MessageUtils.systemUninstall();
+ }
+ }
+
@Override
protected Invoker> createInvoker() {
return new DefaultLocalMavenInvoker(
diff --git a/maven-cli/src/main/java/org/apache/maven/cling/MavenEncCling.java b/maven-cli/src/main/java/org/apache/maven/cling/MavenEncCling.java
index 488eb9eae44a..72cb51ea2c76 100644
--- a/maven-cli/src/main/java/org/apache/maven/cling/MavenEncCling.java
+++ b/maven-cli/src/main/java/org/apache/maven/cling/MavenEncCling.java
@@ -30,7 +30,10 @@
import org.apache.maven.cling.invoker.mvnenc.DefaultEncryptInvoker;
import org.apache.maven.cling.invoker.mvnenc.DefaultEncryptParser;
import org.apache.maven.jline.JLineMessageBuilderFactory;
+import org.apache.maven.jline.MessageUtils;
import org.codehaus.plexus.classworlds.ClassWorld;
+import org.jline.terminal.Terminal;
+import org.jline.terminal.TerminalBuilder;
/**
* Maven encrypt CLI "new-gen".
@@ -52,6 +55,8 @@ public static int main(String[] args, ClassWorld world) throws IOException {
return new MavenEncCling(world).run(args);
}
+ private Terminal terminal;
+
public MavenEncCling() {
super();
}
@@ -60,10 +65,24 @@ public MavenEncCling(ClassWorld classWorld) {
super(classWorld);
}
+ @Override
+ public int run(String[] args) throws IOException {
+ terminal = TerminalBuilder.builder().build();
+ MessageUtils.systemInstall(terminal);
+ MessageUtils.registerShutdownHook();
+ try {
+ return super.run(args);
+ } finally {
+ MessageUtils.systemUninstall();
+ }
+ }
+
@Override
protected Invoker createInvoker() {
- return new DefaultEncryptInvoker(
- ProtoLookup.builder().addMapping(ClassWorld.class, classWorld).build());
+ return new DefaultEncryptInvoker(ProtoLookup.builder()
+ .addMapping(ClassWorld.class, classWorld)
+ .addMapping(Terminal.class, terminal)
+ .build());
}
@Override
diff --git a/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnenc/CommonsCliEncryptOptions.java b/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnenc/CommonsCliEncryptOptions.java
index c1fdb3e76a48..fcf964fee85c 100644
--- a/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnenc/CommonsCliEncryptOptions.java
+++ b/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnenc/CommonsCliEncryptOptions.java
@@ -72,25 +72,17 @@ private static CommonsCliEncryptOptions interpolate(
}
@Override
- public Optional cipher() {
- if (commandLine.hasOption(CLIManager.CIPHER)) {
- return Optional.of(commandLine.getOptionValue(CLIManager.CIPHER));
+ public Optional force() {
+ if (commandLine.hasOption(CLIManager.FORCE)) {
+ return Optional.of(Boolean.TRUE);
}
return Optional.empty();
}
@Override
- public Optional masterSource() {
- if (commandLine.hasOption(CLIManager.MASTER_SOURCE)) {
- return Optional.of(commandLine.getOptionValue(CLIManager.MASTER_SOURCE));
- }
- return Optional.empty();
- }
-
- @Override
- public Optional dispatcher() {
- if (commandLine.hasOption(CLIManager.DISPATCHER)) {
- return Optional.of(commandLine.getOptionValue(CLIManager.DISPATCHER));
+ public Optional yes() {
+ if (commandLine.hasOption(CLIManager.YES)) {
+ return Optional.of(Boolean.TRUE);
}
return Optional.empty();
}
@@ -109,24 +101,19 @@ public EncryptOptions interpolate(Collection