Skip to content
Permalink
Browse files
GenerateCamelKafkaConnectorsMojo : Added possibility to exclude conne…
…ctors from automatic deletion during generation.
  • Loading branch information
valdar committed Oct 30, 2021
1 parent 95516c6 commit fd25e49824f5798ff1a2570a37a0e8d3246a2556
Showing 2 changed files with 15 additions and 4 deletions.
@@ -148,6 +148,12 @@ public class GenerateCamelKafkaConnectorsMojo extends AbstractCamelKafkaConnecto
@Parameter(defaultValue = "", readonly = true)
private List excludedComponents = Collections.EMPTY_LIST;

/**
* The Exclusion List of connectors that must be skipped while deleting kafka connector.
*/
@Parameter(defaultValue = "", readonly = true)
private List excludedConnectorsFromDeletion = Collections.EMPTY_LIST;

@Component
private ProjectDependenciesResolver projectDependenciesResolver;

@@ -335,13 +341,15 @@ protected void executeAll() throws MojoExecutionException, IOException, Resource
if (existingConnectorNames != null) {
List<String> connectorsToRemove = Stream.of(existingConnectorNames).sorted().filter(filename -> {
String componentName = extractComponentName(filename);
// set to remove connectors that are not generated from camel components or a kamelet
return !sanitizedGeneratedFromComponentsConnectorsNames.contains(componentName) && !sanitizedGeneratedFromKameletsConnectorsNames.contains(componentName);
// set to remove connectors that are not generated from camel components or a kamelet and are not excluded in excludedConnectorsFromDeletion
return !sanitizedGeneratedFromComponentsConnectorsNames.contains(componentName)
&& !sanitizedGeneratedFromKameletsConnectorsNames.contains(componentName)
&& !excludedConnectorsFromDeletion.contains(componentName);
}).collect(Collectors.toList());

getLog().info("Connectors previously generated found to be removed: " + connectorsToRemove);

for (String component: connectorsToRemove) {
for (String connectorToBeRemoved: connectorsToRemove) {

executeMojo(
plugin(
@@ -351,7 +359,7 @@ protected void executeAll() throws MojoExecutionException, IOException, Resource
),
goal("camel-kafka-connector-delete"),
configuration(
element(name("name"), component),
element(name("name"), connectorToBeRemoved),
element(name("connectorsProjectName"), connectorsProjectName)
),
executionEnvironment(
@@ -131,6 +131,9 @@
<param>ref</param>
<param>robotframework</param>
</excludedComponents>
<excludedConnectorsFromDeletion>
<param>test</param>
</excludedConnectorsFromDeletion>
</configuration>
<executions>
<execution>

0 comments on commit fd25e49

Please sign in to comment.