gnodet-bot commented on code in PR #1234:
URL: 
https://github.com/apache/maven-plugin-tools/pull/1234#discussion_r4294369512


##########
maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/datamodel/ResolutionAnnotationContent.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+package org.apache.maven.tools.plugin.extractor.annotations.datamodel;
+
+/** Holds a Maven 4 {@code @Resolution} annotation and its field name. */
+public class ResolutionAnnotationContent {
+    private final String fieldName;
+
+    private String pathScope = "";
+
+    private String requestType = "";
+
+    public ResolutionAnnotationContent(String fieldName) {
+        this.fieldName = fieldName;
+    }
+
+    public String getFieldName() {
+        return fieldName;
+    }
+
+    public String pathScope() {
+        return pathScope;
+    }
+
+    public void pathScope(String pathScope) {
+        this.pathScope = pathScope;
+    }
+
+    public String requestType() {
+        return requestType;
+    }
+
+    public void requestType(String requestType) {
+        this.requestType = requestType;
+    }
+}

Review Comment:
   💡 **Missing `toString()` override**
   
   Every other `*AnnotationContent` class in this package implements 
`toString()`. `MojoAnnotatedClass.toString()` now appends the `resolutions` map 
(added in this PR), so without an override the output will show 
`ResolutionAnnotationContent@<hex>` in debug logs — not useful.
   
   Consider adding:
   ```java
   @Override
   public String toString() {
       return "ResolutionAnnotationContent{fieldName='" + fieldName + "', 
pathScope='" + pathScope
               + "', requestType='" + requestType + "'}";
   }
   ```



##########
maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorFilesGenerator.java:
##########
@@ -356,6 +356,20 @@ protected void processMojoDescriptor(
                 }
                 w.endElement(); // afterLinks
             }
+
+            List<ExtendedMojoDescriptor.ResolutionEntry> resolutions =
+                    ((ExtendedMojoDescriptor) mojoDescriptor).getResolutions();
+            if (!resolutions.isEmpty()) {
+                w.startElement("resolutions");
+                for (ExtendedMojoDescriptor.ResolutionEntry resolution : 
resolutions) {
+                    w.startElement("resolution");
+                    GeneratorUtils.element(w, "field", resolution.getField());
+                    GeneratorUtils.element(w, "pathScope", 
resolution.getPathScope());
+                    GeneratorUtils.element(w, "requestType", 
resolution.getRequestType());

Review Comment:
   ⚠️ **Empty `<requestType/>` unconditionally written to XML**
   
   `requestType` defaults to `""` and there is no null/empty guard here, so 
every resolution entry in the plugin descriptor will include 
`<requestType></requestType>` even when the annotation doesn't specify a 
request type. Compare with the `afterLink` handling elsewhere in this file 
which conditionally skips null/empty elements.
   
   Consider only emitting the element when non-empty:
   ```java
   if (resolution.getRequestType() != null && 
!resolution.getRequestType().isEmpty()) {
       GeneratorUtils.element(w, "requestType", resolution.getRequestType());
   }
   ```



-- 
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