in tooling/camel-kafka-connector-generator-maven-plugin/src/main/java/org/apache/camel/kafkaconnector/maven/CamelKafkaConnectorUpdateMojo.java [334:361]
private Document createBasePom(File connectorDir) throws IOException, SAXException, ParserConfigurationException {
File pomFile = new File(connectorDir, "pom.xml");
if (pomFile.exists()) {
try (InputStream in = new FileInputStream(pomFile)) {
String content = IOUtils.toString(in, StandardCharsets.UTF_8);
boolean editablePom = content.contains(GENERATED_SECTION_START_COMMENT);
if (editablePom) {
content = MavenUtils.removeGeneratedSections(content, GENERATED_SECTION_START_COMMENT, GENERATED_SECTION_END_COMMENT, 10);
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document pom;
try (InputStream contentIn = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))) {
pom = builder.parse(contentIn);
}
getLog().debug("Reusing the existing pom.xml for the connector");
return pom;
} else {
getLog().error("Cannot use the existing pom.xml file since it is not editable. It does not contain " + GENERATED_SECTION_START_COMMENT);
throw new UnsupportedOperationException("Cannot use the existing pom.xml file since it is not editable. It does not contain "
+ GENERATED_SECTION_START_COMMENT);
}
}
} else {
getLog().error("The pom.xml file is not present, please use camel-kafka-connector-create first.");
throw new UnsupportedOperationException("The pom.xml file is not present, please use camel-kafka-connector-create first.");
}
}