pzygielo commented on code in PR #405:
URL: https://github.com/apache/maven-help-plugin/pull/405#discussion_r3741825991


##########
src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java:
##########
@@ -197,6 +197,16 @@ private void writeEffectivePom(MavenProject project, 
XMLWriter writer) throws Mo
         // This removes the XML declaration written by MavenXpp3Writer
         String effectivePom = prettyFormat(sWriter.toString(), null, true);
 
+        // MavenXpp3Writer omits packaging when it is null or "jar" (the 
default).
+        // Ensure it is always present so users can see the effective 
packaging value.
+        if (pom.getPackaging() == null || "jar".equals(pom.getPackaging())) {
+            String packaging = pom.getPackaging() != null ? pom.getPackaging() 
: project.getPackaging();
+            String packagingTag = "  <packaging>" + packaging + "</packaging>";
+            if (!effectivePom.contains(packagingTag)) {
+                effectivePom = effectivePom.replace("</version>" + LS, 
"</version>" + LS + packagingTag + LS);

Review Comment:
   I updated IT presented here with:
   ```diff
   diff --git a/src/it/projects/effective-pom-packaging/pom.xml 
b/src/it/projects/effective-pom-packaging/pom.xml
   index 6622e25..a97aed6 100644
   --- a/src/it/projects/effective-pom-packaging/pom.xml
   +++ b/src/it/projects/effective-pom-packaging/pom.xml
   @@ -21,7 +21,11 @@ under the License.
    
    <project>
      <modelVersion>4.0.0</modelVersion>
   -
   +<parent>
   +<groupId>org.apache.maven</groupId>
   +<artifactId>maven-parent</artifactId>
   +<version>49</version>
   +</parent>
      <groupId>org.apache.maven.its.help</groupId>
      <artifactId>mph-217</artifactId>
      <version>1.0-SNAPSHOT</version>
   ```
   
   And here is test result: SUCCESS.
   
   But here is the goal result:
   ```
   <project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
     <modelVersion>4.0.0</modelVersion>
     <parent>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-parent</artifactId>
       <version>49</version>
       <packaging>jar</packaging>
     </parent>
     <groupId>org.apache.maven.its.help</groupId>
     <artifactId>mph-217</artifactId>
     <version>1.0-SNAPSHOT</version>
     <packaging>jar</packaging>
   ```
   
   This is of course non-sense for parent.
   
   And, perhaps according to `String.replace` javadoc (_Replaces **each** 
substring of this string that matches the literal target sequence_), every 
`</version>`, including plugins' - has explicit `<packaging>jar</packaging>` 
companion now.
   
   I don't think it's correct...



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