From 55f31a8fc7eef2694c9c9c9a4025d20194594e40 Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Sun, 9 Nov 2025 00:04:23 +0100 Subject: [PATCH 1/3] RAT-442: Update to commons-cli 1.10.0 --- .../src/main/java/org/apache/rat/OptionCollection.java | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apache-rat-core/src/main/java/org/apache/rat/OptionCollection.java b/apache-rat-core/src/main/java/org/apache/rat/OptionCollection.java index 7a993cb99..d7e51bc42 100644 --- a/apache-rat-core/src/main/java/org/apache/rat/OptionCollection.java +++ b/apache-rat-core/src/main/java/org/apache/rat/OptionCollection.java @@ -130,7 +130,7 @@ public static ReportConfiguration parseCommands(final File workingDirectory, fin CommandLine commandLine; try { commandLine = DefaultParser.builder().setDeprecatedHandler(DeprecationReporter.getLogReporter()) - .setAllowPartialMatching(true).build().parse(opts, args); + .setAllowPartialMatching(true).get().parse(opts, args); } catch (ParseException e) { DefaultLog.getInstance().error(e.getMessage()); DefaultLog.getInstance().error("Please use the \"--help\" option to see a list of valid commands and options.", e); diff --git a/pom.xml b/pom.xml index 31c78b8a1..d276d5c17 100644 --- a/pom.xml +++ b/pom.xml @@ -123,7 +123,7 @@ agnostic home for software distribution comprehension and audit tools. commons-cli commons-cli - 1.8.0 + 1.10.0 org.apache.commons From 0bedba6d61bee86d7aa818e4725a8d1839bf8f73 Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Sun, 9 Nov 2025 00:23:30 +0100 Subject: [PATCH 2/3] RAT-442: Improve debugging after migration to CLI 1.10.0 --- .../test/java/org/apache/rat/help/HelpTest.java | 4 ++-- .../java/org/apache/rat/testhelpers/TextUtils.java | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/apache-rat-core/src/test/java/org/apache/rat/help/HelpTest.java b/apache-rat-core/src/test/java/org/apache/rat/help/HelpTest.java index e3e994765..a844d7b0a 100644 --- a/apache-rat-core/src/test/java/org/apache/rat/help/HelpTest.java +++ b/apache-rat-core/src/test/java/org/apache/rat/help/HelpTest.java @@ -42,10 +42,10 @@ public void verifyAllOptionsListed() { for (Option option : opts.getOptions()) { if (option.getOpt() != null) { - TextUtils.assertContains("-" + option.getOpt() + (option.getLongOpt() == null ? " " : ","), result); + TextUtils.assertContains(option, "-" + option.getOpt() + (option.getLongOpt() == null ? " " : ","), result); } if (option.getLongOpt() != null) { - TextUtils.assertContains("--" + option.getLongOpt() + " ", result); + TextUtils.assertContains(option, "--" + option.getLongOpt() + " ", result); } } diff --git a/apache-rat-core/src/test/java/org/apache/rat/testhelpers/TextUtils.java b/apache-rat-core/src/test/java/org/apache/rat/testhelpers/TextUtils.java index e90a30b9c..68e31a5f7 100644 --- a/apache-rat-core/src/test/java/org/apache/rat/testhelpers/TextUtils.java +++ b/apache-rat-core/src/test/java/org/apache/rat/testhelpers/TextUtils.java @@ -26,6 +26,8 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.regex.Pattern; + +import org.apache.commons.cli.Option; import org.apache.commons.io.IOUtils; /** @@ -78,6 +80,18 @@ public static void assertContains(final String find, final String target) { .isTrue(); } + /** + * Asserts that a string is contained within another string and allows to print the related option. + * @param option The current option to search in via parameter find. + * @param find The string to find. + * @param target The string to search. + */ + public static void assertContains(final Option option, final String find, final String target) { + assertThat(target.contains(find)).as(() -> + format("Target option '%s' is not properly found in the text: %s%n%s", option, find, target)) + .isTrue(); + } + /** * Asserts that a string is contained exactly a specified number of times within another string. * @param times The number of times to find the string in the target. From a44ffb6ff68fd27e7bc56e3f6ae978aaf967b906 Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Sat, 15 Nov 2025 11:06:53 +0100 Subject: [PATCH 3/3] RAT-442: Update to commons-cli 1.11.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d276d5c17..13918d541 100644 --- a/pom.xml +++ b/pom.xml @@ -123,7 +123,7 @@ agnostic home for software distribution comprehension and audit tools. commons-cli commons-cli - 1.10.0 + 1.11.0 org.apache.commons