gnodet commented on code in PR #1983:
URL: https://github.com/apache/maven-resolver/pull/1983#discussion_r3789505360


##########
maven-resolver-tools/src/main/java/org/eclipse/aether/tools/ConfigurationCollectorDoclet.java:
##########
@@ -262,19 +382,15 @@ private void processMavenField(
             configurationType = 
configurationType.substring("java.util.".length());
         }
 
-        String description = docComment != null ? 
renderContent(docComment.getFullBody(), field, docComment, true) : "";
-        description = description.replace("*", "\\*");
-
-        Map<String, String> entry = new LinkedHashMap<>();
-        entry.put("key", String.valueOf(field.getConstantValue()));
-        entry.put("defaultValue", Objects.toString(defaultValue, ""));
-        entry.put("fqName", "");
-        entry.put("description", Objects.toString(description, ""));
-        entry.put("since", Objects.toString(getSince(type, docComment, field), 
""));
-        entry.put("configurationSource", source);
-        entry.put("configurationType", configurationType);
-        entry.put("supportRepoIdSuffix", "");
-        discovered.add(entry);
+        return new ConfigurationEntry(
+                String.valueOf(field.getConstantValue()),
+                path.getDocComment() != null ? getFullBodyContent(path) : "",
+                Objects.toString(defaultValue, ""),
+                getFullyQualifiedName(field),
+                Objects.toString(getSince(path), ""),

Review Comment:
   Bug: `Objects.toString(getSince(path), "")` is incorrect because 
`getSince()` returns `Optional<String>`. Since `Optional.empty()` is never 
null, `Objects.toString` calls `Optional.toString()` producing the literal 
string "Optional.empty" instead of "". The resolver-mode counterpart at line 
311 correctly uses `.orElse("")`.
   
   ```suggestion
                       getSince(path).orElse(""),
   ```



##########
maven-resolver-tools/src/main/java/org/eclipse/aether/tools/ConfigurationCollectorDoclet.java:
##########
@@ -115,18 +151,31 @@ public String getName() {
     @Override
     public Set<? extends Option> getSupportedOptions() {
         return Set.of(
-                new SimpleOption(
+                new SingleArgumentOption(
                         List.of("--output", "-o"),
-                        1,
                         "The intermediate properties file to write discovered 
keys to",
                         "<file>",
-                        args -> output = Paths.get(args.get(0))),
-                new SimpleOption(
-                        List.of("--mode", "-m"),
-                        1,
-                        "The scanning mode, either 'resolver' or 'maven'",
-                        "<mode>",
-                        args -> mode = args.get(0)));
+                        arg -> {
+                            try {
+                                output = Paths.get(arg);
+                            } catch (InvalidPathException e) {
+                                throw new IllegalArgumentException("Invalid 
output file path: " + arg, e);
+                            }
+                        }),
+                new SingleArgumentOption(
+                        List.of("--mode", "-m"), "The scanning mode, either 
'resolver' or 'maven'", "<mode>", arg -> {
+                            try {
+                                Mode.valueOf(arg.toUpperCase(Locale.ROOT));

Review Comment:
   Bug: `Mode.valueOf()` result is discarded — the `mode` field stays at 
`RESOLVER` regardless of the `--mode` argument, silently breaking maven mode 
scanning.
   
   ```suggestion
                                   mode = 
Mode.valueOf(arg.toUpperCase(Locale.ROOT));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to