in tooling/camel-upgrade/src/main/java/org/apache/camel/karaf/tooling/upgrade/WrapperHandler.java [94:125]
protected static String getParentPomWithComponent(String pom, String component) {
Matcher matcher = MODULE_IN_PARENT_POM.matcher(pom);
StringBuilder result = new StringBuilder();
int start = 0;
boolean added = false;
while (matcher.find(start)) {
String module = matcher.group(1);
if (module.equals(component)) {
// Already in the parent pom
return pom;
} else if (module.equals("NA")) {
result.append(pom, 0, matcher.start());
result.append("<module>%s</module>".formatted(component));
added = true;
start = matcher.end();
break;
} else if (module.compareTo(component) > 0) {
result.append(pom, 0, matcher.start());
result.append("<module>%s</module>%n ".formatted(component));
added = true;
start = matcher.start();
break;
}
start = matcher.end();
}
if (!added) {
result.append(pom, 0, start);
result.append("%n <module>%s</module>".formatted(component));
}
result.append(pom, start, pom.length());
return result.toString();
}