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

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git

commit 5a6669ed35a82c710be2c11a774d72c22c041df9
Author: Antonin Stefanutti <anto...@stefanutti.fr>
AuthorDate: Thu Oct 17 17:50:52 2019 +0200

    Add support for Quarkus runtime provider in catalog generator
---
 pom.xml                                            |  1 +
 tooling/camel-k-maven-plugin/pom.xml               |  6 +++++
 .../camel/k/tooling/maven/GenerateCatalogMojo.java | 30 +++++++++++++++++-----
 3 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/pom.xml b/pom.xml
index 235df17..0f300ba 100644
--- a/pom.xml
+++ b/pom.xml
@@ -38,6 +38,7 @@
         <camel.version>3.0.0-RC1</camel.version>
         <camel-quarkus.version>0.2.0</camel-quarkus.version>
         <catalog.version>${camel.version}</catalog.version>
+        <quarkus.catalog.version>0.2.1-SNAPSHOT</quarkus.catalog.version>
         <junit.version>5.5.2</junit.version>
         <joor.version>0.9.12</joor.version>
         <commons-io.version>2.6</commons-io.version>
diff --git a/tooling/camel-k-maven-plugin/pom.xml 
b/tooling/camel-k-maven-plugin/pom.xml
index 3ef5514..37aa2f0 100644
--- a/tooling/camel-k-maven-plugin/pom.xml
+++ b/tooling/camel-k-maven-plugin/pom.xml
@@ -97,6 +97,12 @@
       <scope>provided</scope>
     </dependency>
     <dependency>
+      <groupId>org.apache.camel.quarkus</groupId>
+      <artifactId>camel-catalog-quarkus</artifactId>
+      <version>${quarkus.catalog.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
       <groupId>org.yaml</groupId>
       <artifactId>snakeyaml</artifactId>
       <version>${snakeyaml.version}</version>
diff --git 
a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
 
b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
index 95354ea..ddf68bd 100644
--- 
a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
+++ 
b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
@@ -74,6 +74,9 @@ public class GenerateCatalogMojo extends AbstractMojo {
     @Parameter(property = "catalog.file", defaultValue = 
"camel-catalog-${camel.version}-${runtime.version}.yaml")
     private String outputFile;
 
+    @Parameter(property = "catalog.runtime", defaultValue = "default")
+    private String runtime;
+
     // ********************
     //
     // ********************
@@ -96,6 +99,19 @@ public class GenerateCatalogMojo extends AbstractMojo {
 
         final SortedMap<String, CamelArtifact> artifacts = new TreeMap<>();
         final org.apache.camel.catalog.CamelCatalog catalog = new 
DefaultCamelCatalog();
+        String version = "";
+        switch (runtime) {
+            case "quarkus":
+                catalog.setRuntimeProvider(new 
org.apache.camel.catalog.quarkus.QuarkusRuntimeProvider());
+                version = 
getVersionFor("/META-INF/maven/org.apache.camel.quarkus/camel-catalog-quarkus/pom.properties");
+                break;
+            case "default":
+                version = catalog.getCatalogVersion();
+            case "":
+                break;
+            default:
+                throw new IllegalArgumentException("catalog.runtime parameter 
value [" + runtime + "] is not supported!");
+        }
 
         try {
             processComponents(catalog, artifacts);
@@ -140,8 +156,9 @@ public class GenerateCatalogMojo extends AbstractMojo {
                     .metadata(new ObjectMeta.Builder()
                         .name(catalogName)
                         .putLabels("app", "camel-k")
-                        .putLabels("camel.apache.org/catalog.version", 
catalog.getCatalogVersion())
+                        .putLabels("camel.apache.org/catalog.version", version)
                         .putLabels("camel.apache.org/catalog.loader.version", 
catalog.getLoadedVersion())
+                        .putLabels("camel.apache.org/runtime.provider", 
runtime.length() == 0 ? "default" : runtime)
                         .putLabels("camel.apache.org/runtime.version", 
getRuntimeVersion())
                         .build())
                     .spec(new CamelCatalogSpec.Builder()
@@ -251,15 +268,16 @@ public class GenerateCatalogMojo extends AbstractMojo {
         }
     }
 
-    public synchronized String getRuntimeVersion() {
+    private String getRuntimeVersion() {
+        return 
getVersionFor("/META-INF/maven/org.apache.camel.k/camel-k-maven-plugin/pom.properties");
+    }
+
+    private synchronized String getVersionFor(String path) {
         String version = null;
 
         // try to load from maven properties first
         try {
-
-            InputStream is = getClass().getResourceAsStream(
-                
"/META-INF/maven/org.apache.camel.k/camel-k-maven-plugin/pom.properties"
-            );
+            InputStream is = getClass().getResourceAsStream(path);
 
             if (is != null) {
                 Properties p = new Properties();

Reply via email to