diff --git a/maven-cli/src/main/java/org/apache/maven/cling/invoker/CommonsCliOptions.java b/maven-cli/src/main/java/org/apache/maven/cling/invoker/CommonsCliOptions.java index 3c076a4eaf..3acc2fa956 100644 --- a/maven-cli/src/main/java/org/apache/maven/cling/invoker/CommonsCliOptions.java +++ b/maven-cli/src/main/java/org/apache/maven/cling/invoker/CommonsCliOptions.java @@ -437,7 +437,7 @@ public abstract class CommonsCliOptions implements Options { formatter.printHelp( pw, width, - command + " [args]", + commandLineSyntax(command), System.lineSeparator() + "Options:", options, HelpFormatter.DEFAULT_LEFT_PAD, @@ -447,5 +447,9 @@ public abstract class CommonsCliOptions implements Options { pw.flush(); } + + protected String commandLineSyntax(String command) { + return command + " [options] [goals]"; + } } } diff --git a/maven-cli/src/main/java/org/apache/maven/cling/invoker/PlexusContainerCapsuleFactory.java b/maven-cli/src/main/java/org/apache/maven/cling/invoker/PlexusContainerCapsuleFactory.java index 6595c06b11..49b2c7c9e5 100644 --- a/maven-cli/src/main/java/org/apache/maven/cling/invoker/PlexusContainerCapsuleFactory.java +++ b/maven-cli/src/main/java/org/apache/maven/cling/invoker/PlexusContainerCapsuleFactory.java @@ -99,13 +99,10 @@ public class PlexusContainerCapsuleFactory< .setName("maven"); customizeContainerConfiguration(context, cc); - Set exportedArtifacts = new HashSet<>(coreEntry.getExportedArtifacts()); - Set exportedPackages = new HashSet<>(coreEntry.getExportedPackages()); - for (CoreExtensionEntry extension : extensions) { - exportedArtifacts.addAll(extension.getExportedArtifacts()); - exportedPackages.addAll(extension.getExportedPackages()); - } - CoreExports exports = new CoreExports(containerRealm, exportedArtifacts, exportedPackages); + CoreExports exports = new CoreExports( + containerRealm, + collectExportedArtifacts(coreEntry, extensions), + collectExportedPackages(coreEntry, extensions)); Thread.currentThread().setContextClassLoader(containerRealm); DefaultPlexusContainer container = new DefaultPlexusContainer(cc, getCustomModule(context, exports)); @@ -153,6 +150,24 @@ public class PlexusContainerCapsuleFactory< return container; } + protected Set collectExportedArtifacts( + CoreExtensionEntry coreEntry, List extensionEntries) { + Set exportedArtifacts = new HashSet<>(coreEntry.getExportedArtifacts()); + for (CoreExtensionEntry extension : extensionEntries) { + exportedArtifacts.addAll(extension.getExportedArtifacts()); + } + return exportedArtifacts; + } + + protected Set collectExportedPackages( + CoreExtensionEntry coreEntry, List extensionEntries) { + Set exportedPackages = new HashSet<>(coreEntry.getExportedPackages()); + for (CoreExtensionEntry extension : extensionEntries) { + exportedPackages.addAll(extension.getExportedPackages()); + } + return exportedPackages; + } + /** * Note: overriding this method should be avoided. Preferred way to replace Maven components is the "normal" way * where the components are on index (are annotated with JSR330 annotations and Sisu index is created) and, they 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 fcf964fee8..9ee6ecd1f5 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 @@ -116,5 +116,10 @@ public class CommonsCliEncryptOptions extends CommonsCliOptions implements Encry .desc("Should imply user answered \"yes\" to all incoming questions?") .build()); } + + @Override + protected String commandLineSyntax(String command) { + return command + " [options] [goal]"; + } } }