davsclaus opened a new pull request, #3137:
URL: https://github.com/apache/camel-kamelets/pull/3137

   Part of #3133. Independent of #3135 (the catalog without the ClassGraph 
scan).
   
   A tool that lists the Kamelets, such as `camel catalog kamelet` in the Camel 
CLI, needs a few attributes of each Kamelet, but today has to parse all of 
them: 259 YAML files, 2.3 MB with their icons. `KameletsCatalog` takes 400-600 
ms for that (the CRD model), a plain YAML parse still 150-200 ms. This adds a 
small index for them.
   
   ### Change
   
   - **`generate-index`**, a new goal of `kamelets-maven-plugin`, writes 
`META-INF/kamelets-index.json` into the resources of `camel-kamelets`: for each 
Kamelet, sorted by name, its `name`, `type` (label 
`camel.apache.org/kamelet.type`), `supportLevel`, `title` and `description` (of 
`spec.definition`), `group`, `namespace` and `provider` (annotations). An 
attribute that a Kamelet does not have is left out; there is no icon. A Kamelet 
without `metadata.name` fails the goal.
   - The bom runs it next to `generate-nav`, in `compile`. The index is 
committed with the Kamelets, like their copy in 
`library/camel-kamelets/src/main/resources/kamelets` and `nav.adoc`, so the 
build of main (`main-push-regen.yaml`) regenerates it; the goal writes the file 
only when its content changes.
   - It is not under `kamelets/`, so the catalog and the tests that count the 
files there see only the Kamelets. RAT already excludes `*.json`.
   
   The format (also in the Javadoc of `GenerateIndexMojo`):
   
   ```json
   {
     "kamelets" : [ {
       "name" : "avro-deserialize-action",
       "type" : "action",
       "supportLevel" : "Stable",
       "title" : "Avro Deserialize Action",
       "description" : "Deserialize payload to Avro.",
       "group" : "Actions",
       "namespace" : "Transformation",
       "provider" : "Apache Software Foundation"
     }, ... ]
   }
   ```
   
   ### Measured
   
   The index is 87 KB. Reading it from the `camel-kamelets` JAR with 
`camel-util-json`, in a new JVM on the class path of the Camel CLI distribution 
(341 JARs): 22-26 ms for the 259 Kamelets, against 430-640 ms for `new 
KameletsCatalog()`.
   
   The Camel CLI ships `camel-kamelets` in its distribution, so `camel catalog 
kamelet` can list from the index without resolving and loading the catalog (a 
Camel change that follows, with a fallback to the catalog for Kamelets releases 
without the index).
   
   ### Tests
   
   - `GenerateIndexMojoTest` (new; the plugin had no tests, so `junit-jupiter` 
is added as for the catalog): the attributes of each Kamelet sorted by name, 
the ones a Kamelet does not have left out, a multi-line description, no icon, 
the JSON format; a Kamelet without a name fails; the Kamelets of this project: 
one entry per `*.kamelet.yaml`, each with type, support level, title and 
description.
   - The goal run twice: written, then "up to date". `camel-kamelets` packaged: 
the JAR has the 259 Kamelets and the index.
   
   _Claude Code on behalf of Claus Ibsen_
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to