in tooling/camel-kafka-connector-generator-maven-plugin/src/main/java/org/apache/camel/kafkaconnector/maven/CamelKafkaConnectorKameletUpdateMojo.java [200:252]
private void updateConnector() throws Exception {
KameletModel kamelet = YamlKameletMapper.parseKameletYaml(kameletYaml);
String sanitizedName = sanitizeMavenArtifactId(name);
// create the connector directory
File connectorDir = new File(projectDir, "camel-" + sanitizedName + KAFKA_CONNECTORS_SUFFIX);
if (!connectorDir.exists() || !connectorDir.isDirectory()) {
getLog().info("Connector " + name + " can not be updated since directory " + connectorDir.getAbsolutePath() + " dose not exist or is not a directory (maybe use camel-kafka-connector-kamelet-create first).");
throw new MojoFailureException("Directory dose not already exists or is not a directory: " + connectorDir);
}
// create the base pom.xml
Document pom = createBasePom(connectorDir);
// Apply changes to the connector pomDocument pom
Set<String> dependencies = new HashSet<>();
dependencies.addAll(getKameletDependencies(kamelet));
dependencies.addAll(getAdditionalDependencies(additionalDependencies));
if (!dependencies.isEmpty()) {
getLog().debug("The following dependencies will be added to the connector: " + dependencies);
MavenUtils.addDependencies(pom, dependencies, GENERATED_SECTION_START, GENERATED_SECTION_END);
}
fixAdditionalRepositories(pom);
// Write the connector pom
File pomFile = new File(connectorDir, "pom.xml");
writeXmlFormatted(pom, pomFile, getLog());
// write package
Document pkg = createPackageFile();
File pkgFile = new File(connectorDir, "src/main/assembly/package.xml");
writeXmlFormatted(pkg, pkgFile, getLog());
// write LICENSE, USAGE
writeStaticFiles(connectorDir);
// write kamlete yaml file
File docFolder = new File(connectorDir, "src/main/resources/kamelets");
File docFile = new File(docFolder, name + ".kamelet.yaml");
updateFile(docFile, kameletYaml);
// generate classes
String kameletType = kamelet.getType().toLowerCase();
switch (kameletType) {
case "source":
createClassesAndDocumentation(sanitizedName, connectorDir, kamelet, ConnectorType.SOURCE);
break;
case "sink":
createClassesAndDocumentation(sanitizedName, connectorDir, kamelet, ConnectorType.SINK);
break;
default:
getLog().warn("Unsupported kamelet type: " + kameletType);
}
}