You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/06/17 17:21:23 UTC

[camel-kafka-connector] branch fix-component-exclusion updated (0f957db -> 2350124)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch fix-component-exclusion
in repository https://gitbox.apache.org/repos/asf/camel-kafka-connector.git.


    omit 0f957db  Fixed component exclusion in combination with filter
     new 2350124  Fixed component exclusion in combination with filter

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (0f957db)
            \
             N -- N -- N   refs/heads/fix-component-exclusion (2350124)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 connectors/pom.xml                                                    | 1 -
 docs/modules/ROOT/pages/connectors.adoc                               | 3 +--
 .../camel/kafkaconnector/maven/GenerateCamelKafkaConnectorsMojo.java  | 4 ++--
 3 files changed, 3 insertions(+), 5 deletions(-)


[camel-kafka-connector] 01/01: Fixed component exclusion in combination with filter

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch fix-component-exclusion
in repository https://gitbox.apache.org/repos/asf/camel-kafka-connector.git

commit 235012402c43e9e62b131d2197e468a5d258ead8
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Jun 17 19:07:30 2020 +0200

    Fixed component exclusion in combination with filter
---
 .../maven/GenerateCamelKafkaConnectorsMojo.java    | 32 +++++++++++++++++-----
 1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/tooling/camel-kafka-connector-generator-maven-plugin/src/main/java/org/apache/camel/kafkaconnector/maven/GenerateCamelKafkaConnectorsMojo.java b/tooling/camel-kafka-connector-generator-maven-plugin/src/main/java/org/apache/camel/kafkaconnector/maven/GenerateCamelKafkaConnectorsMojo.java
index 9ad226c..2535165 100644
--- a/tooling/camel-kafka-connector-generator-maven-plugin/src/main/java/org/apache/camel/kafkaconnector/maven/GenerateCamelKafkaConnectorsMojo.java
+++ b/tooling/camel-kafka-connector-generator-maven-plugin/src/main/java/org/apache/camel/kafkaconnector/maven/GenerateCamelKafkaConnectorsMojo.java
@@ -18,9 +18,12 @@ package org.apache.camel.kafkaconnector.maven;
 
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Properties;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 import org.apache.camel.catalog.CamelCatalog;
@@ -76,11 +79,17 @@ public class GenerateCamelKafkaConnectorsMojo extends AbstractCamelKafkaConnecto
 
     @Component
     private BuildPluginManager pluginManager;
-
+    
     /**
      * The Camel Component Filter to select for which components generate the corresponding camel kafka connector.
      */
     @Parameter(defaultValue = "", readonly = true)
+    private String filter;
+
+    /**
+     * The Camel Component Exclusion List to select for which components must be skipped while generating kafka connector.
+     */
+    @Parameter(defaultValue = "", readonly = true)
     private List excludedComponents = Collections.EMPTY_LIST;
 
     @Component
@@ -98,23 +107,32 @@ public class GenerateCamelKafkaConnectorsMojo extends AbstractCamelKafkaConnecto
     protected void executeAll() throws MojoExecutionException, IOException, ResourceNotFoundException, FileResourceCreationException {
         CamelCatalog cc = new DefaultCamelCatalog();
         List<String> components;
-        //TODO: implement an exclusion mechanism
-        if (excludedComponents == null || excludedComponents.isEmpty()) {
+        List<String> filteredComponents;
+        if (filter == null || filter.isEmpty()) {
             components = cc.findComponentNames();
         } else {
-            components = cc.findComponentNames().stream().filter(componentName -> !excludedComponents.contains(componentName)).collect(Collectors.toList());
+            Set<String> filterComponentNames = new HashSet<>(Arrays.asList(filter.split(",")));
+            components = cc.findComponentNames().stream().filter(componentName -> filterComponentNames.contains(componentName)).collect(Collectors.toList());
+        }
+        if (excludedComponents == null || excludedComponents.isEmpty()) {
+            filteredComponents = components;
+        } else {
+            filteredComponents = components.stream().filter(component -> !excludedComponents.contains(component)).collect(Collectors.toList());
+        }
+        if (filter != null && !filter.isEmpty()) {
+            getLog().info("Filtered Components that will be generated: " + filter);
         }
-        if (!excludedComponents.isEmpty()) {
+        if (excludedComponents != null && !excludedComponents.isEmpty()) {
             getLog().info("Excluded Components that won't be generated: " + excludedComponents);
         }
-        getLog().info("Components found to be generated/updated: " + components);
+        getLog().info("Components found to be generated/updated: " + filteredComponents);
 
         //TODO: evaluate dataformats to include in each camel kafka connector generated placing them as a comma separated GAV in:
         String additionalDependencies = "";
 
         final Properties properties = new Properties();
         properties.load(new FileInputStream(rm.getResourceAsFile("project.properties")));
-        for (String component : components) {
+        for (String component : filteredComponents) {
             String cJson = cc.componentJSonSchema(component);
             ComponentModel cm = JsonMapper.generateComponentModel(cJson);