Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void displayHelp(ParserRequest request, Consumer<String> printStream) {
printStream.accept(
" -a, --all Apply all upgrades (equivalent to --model-version 4.1.0 --infer --model --plugins)");
printStream.accept("");
printStream.accept("Default behavior: --model and --plugins are applied if no other options are specified");
printStream.accept("Default behavior: --model --plugins --infer are applied if no other options are specified");
printStream.accept("");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@
*/
package org.apache.maven.cling.invoker.mvnup;

import java.io.ByteArrayOutputStream;
import java.nio.charset.StandardCharsets;

import org.apache.commons.cli.ParseException;
import org.apache.maven.api.cli.mvnup.UpgradeOptions;
import org.apache.maven.cling.MavenUpCling;
import org.codehaus.plexus.classworlds.ClassWorld;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -190,4 +195,25 @@ void testInterpolationWithPluginsOption() throws ParseException {
assertTrue(interpolated.plugins().isPresent(), "Interpolated options should preserve --plugins");
assertTrue(interpolated.plugins().get(), "Interpolated --plugins should be true");
}

@Test
void helpMentionsInferInDefault() throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayOutputStream err = new ByteArrayOutputStream();

int exit = MavenUpCling.main(
new String[] {"--help"},
new ClassWorld("plexus.core", Thread.currentThread().getContextClassLoader()),
null,
out,
err);

String help = out.toString(StandardCharsets.UTF_8);
assertEquals(0, exit, "mvnup --help should exit 0");
assertTrue(
help.contains("Default behavior: --model --plugins --infer"),
"Help footer should advertise --infer as part of the defaults");
assertFalse(
help.contains("Default behavior: --model and --plugins"), "Old/incorrect default text must be gone");
}
}
Loading