maartenc commented on code in PR #114:
URL: https://github.com/apache/ant-ivy/pull/114#discussion_r2283098586


##########
src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java:
##########
@@ -103,53 +103,69 @@ public static void write(ModuleDescriptor md, File 
output, PomWriterOptions opti
                 variables.setVariable("ivy.pom.license", 
options.getLicenseHeader(), true);
             }
             if (options.isPrintIvyInfo()) {
-                String header = "<!--\n" + "   Apache Maven 2 POM generated by 
Apache Ivy\n"
-                        + "   " + Ivy.getIvyHomeURL() + "\n" + "   Apache Ivy 
version: "
-                        + Ivy.getIvyVersion() + " " + Ivy.getIvyDate() + "\n" 
+ "-->";
+                String header
+                    = "<!--\n" // TODO: replace \n with lineSeparator()
+                    + "   Apache Maven 2 POM generated by Apache Ivy\n"
+                    + "   " + Ivy.getIvyHomeURL() + "\n"
+                    + "   Apache Ivy version: " + Ivy.getIvyVersion() + " " + 
Ivy.getIvyDate() + "\n"
+                    + "-->";
                 variables.setVariable("ivy.pom.header", header, true);
             }
 
             setModuleVariables(md, variables, options);
 
+            boolean dependencyManagement = false;
             boolean dependenciesPrinted = false;
+            boolean overridesPrinted = false;
 
             int lastIndent = 0;
             int indent = 0;
-            String line = in.readLine();
-            while (line != null) {
+            String line;
+            while ((line = in.readLine()) != null) {
                 line = IvyPatternHelper.substituteVariables(line, variables);
                 if (line.contains(SKIP_LINE)) {
                     // skip this line
-                    line = in.readLine();
                     continue;
                 }
 
-                if (line.trim().isEmpty()) {
-                    // empty line
-                    out.println(line);
-                    line = in.readLine();
-                    continue;
-                }
+                if (!line.trim().isEmpty()) {
+                    lastIndent = indent;
+                    indent = line.indexOf('<');
 
-                lastIndent = indent;
-                indent = line.indexOf('<');
+                    if (line.contains("<dependencyManagement>")) {
+                        dependencyManagement = true;
+                    }
 
-                if (!dependenciesPrinted && line.contains("</dependencies>")) {
-                    printDependencies(md, out, options, indent, false);
-                    dependenciesPrinted = true;
-                }
+                    if (line.contains("</dependencyManagement>")) {
+                        dependencyManagement = false;

Review Comment:
   I think you should also check here that any overrides are printed.
   This to tackle the case where the template contains an empty 
`<dependencyManagent>` element (without `<dependencies>` subelement)



-- 
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: dev-unsubscr...@ant.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org
For additional commands, e-mail: dev-h...@ant.apache.org

Reply via email to