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

ppalaga pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/main by this push:
     new 46776bf  Fix Qute component metadata in Camel Quarkus catalog fix #2701
46776bf is described below

commit 46776bfe5ac4faf394c9a2df7afabdbb5d3ba438
Author: Peter Palaga <ppal...@redhat.com>
AuthorDate: Thu Jun 10 00:04:26 2021 +0200

    Fix Qute component metadata in Camel Quarkus catalog fix #2701
---
 .../org/apache/camel/quarkus/maven/CqCatalog.java  |  6 ++++
 .../quarkus/maven/PrepareCatalogQuarkusMojo.java   | 32 ++++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git 
a/tooling/maven-plugin/src/main/java/org/apache/camel/quarkus/maven/CqCatalog.java
 
b/tooling/maven-plugin/src/main/java/org/apache/camel/quarkus/maven/CqCatalog.java
index 1a20ac6..ac0663e 100644
--- 
a/tooling/maven-plugin/src/main/java/org/apache/camel/quarkus/maven/CqCatalog.java
+++ 
b/tooling/maven-plugin/src/main/java/org/apache/camel/quarkus/maven/CqCatalog.java
@@ -114,6 +114,8 @@ public class CqCatalog {
             filter = model -> 
"camel-core-languages".equals(model.getArtifactId()) && 
"csimple".equals(model.getName());
         } else if ("reactive-executor".equals(cqArtifactIdBase)) {
             filter = model -> 
"camel-reactive-executor-vertx".equals(model.getArtifactId());
+        } else if ("qute".equals(cqArtifactIdBase)) {
+            filter = model -> 
"camel-quarkus-qute-component".equals(model.getArtifactId());
         } else {
             filter = model -> ("camel-" + 
cqArtifactIdBase).equals(model.getArtifactId());
         }
@@ -129,6 +131,10 @@ public class CqCatalog {
         return catalog.findNames(kind).stream().map(name -> (ArtifactModel<?>) 
catalog.model(kind, name));
     }
 
+    public void addComponent(String name, String className, String jsonSchema) 
{
+        catalog.addComponent(name, className, jsonSchema);
+    }
+
     public static Stream<Kind> kinds() {
         return Stream.of(Kind.values())
                 .filter(kind -> kind != org.apache.camel.catalog.Kind.eip);
diff --git 
a/tooling/maven-plugin/src/main/java/org/apache/camel/quarkus/maven/PrepareCatalogQuarkusMojo.java
 
b/tooling/maven-plugin/src/main/java/org/apache/camel/quarkus/maven/PrepareCatalogQuarkusMojo.java
index a9c5e13..dc19c29 100644
--- 
a/tooling/maven-plugin/src/main/java/org/apache/camel/quarkus/maven/PrepareCatalogQuarkusMojo.java
+++ 
b/tooling/maven-plugin/src/main/java/org/apache/camel/quarkus/maven/PrepareCatalogQuarkusMojo.java
@@ -85,6 +85,38 @@ public class PrepareCatalogQuarkusMojo extends AbstractMojo {
         extensionDirectories.stream()
                 .map(File::toPath)
                 .forEach(extDir -> {
+
+                    /* Discover local components, such as Qute and add them to 
the catalog */
+                    CqUtils.findExtensionArtifactIdBases(extDir)
+                            .filter(artifactIdBase -> 
!skipArtifactIdBases.contains(artifactIdBase))
+                            .forEach(artifactIdBase -> {
+                                final Path schemaFile = extDir
+                                        .resolve(artifactIdBase)
+                                        
.resolve("component/src/generated/resources/org/apache/camel/component/"
+                                                + artifactIdBase + "/" + 
artifactIdBase + ".json")
+                                        .toAbsolutePath().normalize();
+                                if (Files.isRegularFile(schemaFile)) {
+                                    try {
+                                        final String schema = new 
String(Files.readAllBytes(schemaFile),
+                                                StandardCharsets.UTF_8);
+                                        final String capBase = 
artifactIdBase.substring(0, 1).toUpperCase()
+                                                + artifactIdBase.substring(1);
+                                        getLog().debug("Adding an extra 
component " + artifactIdBase + " " +
+                                                "org.apache.camel.component." 
+ artifactIdBase + "." + capBase + "Component " +
+                                                schema);
+                                        catalog.addComponent(artifactIdBase,
+                                                "org.apache.camel.component." 
+ artifactIdBase + "." + capBase + "Component",
+                                                schema);
+                                    } catch (IOException e) {
+                                        throw new RuntimeException("Could not 
read " + schemaFile, e);
+                                    }
+                                }
+                            });
+                });
+
+        extensionDirectories.stream()
+                .map(File::toPath)
+                .forEach(extDir -> {
                     CqUtils.findExtensionArtifactIdBases(extDir)
                             .filter(artifactIdBase -> 
!skipArtifactIdBases.contains(artifactIdBase))
                             .forEach(artifactIdBase -> {

Reply via email to