maartenc commented on code in PR #120:
URL: https://github.com/apache/ant-ivy/pull/120#discussion_r3405262214
##########
src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java:
##########
@@ -103,53 +99,60 @@ 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;
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;
+ }
- if (!dependenciesPrinted && line.contains("</project>")) {
- printDependencies(md, out, options, lastIndent, true);
- dependenciesPrinted = true;
- }
+ if (line.contains("</dependencies>")) {
+ if (!dependenciesPrinted && !dependencyManagement) {
Review Comment:
please change this back into 1 if statement
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]