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 415c2c465af7..613c885de42a 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 @@ -120,7 +120,8 @@ public CqCatalog(Path baseDir, Flavor flavor) { public CqCatalog(Flavor flavor, Function resourceLocator) { this.flavor = flavor; - final DefaultCamelCatalog c = new DefaultCamelCatalog(true); + // workaround for catalog `beans/*.json`, see comment on BeansWorkaroundCustomCatalog for more information + final DefaultCamelCatalog c = new BeansWorkaroundCustomCatalog(true); c.setRuntimeProvider(flavor.createRuntimeProvider(c)); c.setVersionManager(new CqVersionManager(c, resourceLocator)); this.catalog = c; @@ -197,6 +198,8 @@ static void serialize(final Path catalogPath, ArtifactModel model) { switch (model.getKind()) { case bean: rawJson = JsonMapper.createParameterJsonSchema((PojoBeanModel) model); + //workaround + rawJson = rawJson.replace("model", "bean"); break; case component: rawJson = JsonMapper.createParameterJsonSchema((ComponentModel) model); @@ -346,6 +349,7 @@ static class CqRuntimeProvider implements RuntimeProvider { private static final String LANGUAGE_CATALOG = CQ_CATALOG_DIR + "/languages.properties"; private static final String TRANSFORMER_CATALOG = CQ_CATALOG_DIR + "/transformers.properties"; private static final String OTHER_CATALOG = CQ_CATALOG_DIR + "/others.properties"; + private static final String BEANS_CATALOG = CQ_CATALOG_DIR + "/beans.properties"; private static final String CAPABILITIES_CATALOG = "org/apache/camel/catalog/capabilities.properties"; private CamelCatalog camelCatalog; @@ -438,6 +442,10 @@ protected String getOtherCatalog() { return OTHER_CATALOG; } + protected String getBeansCatalog() { + return BEANS_CATALOG; + } + protected String getCapabilitiesCatalog() { return CAPABILITIES_CATALOG; } @@ -529,7 +537,7 @@ public List findOtherNames() { @Override public List findBeansNames() { List names = new ArrayList<>(); - InputStream is = getCamelCatalog().getVersionManager().getResourceAsStream(getPojoBeanJSonSchemaDirectory()); + InputStream is = getCamelCatalog().getVersionManager().getResourceAsStream(getBeansCatalog()); if (is != null) { try { CatalogHelper.loadLines(is, names); @@ -586,4 +594,20 @@ public void close() { } } + /** + * Prior https://github.com/apache/camel/pull/15708, the catalog files from `beans/*json` might have contained + * attribute `model` instead of `bean`. This custom catalog is fixing the json, to be parsable by Camel + * tooling. + */ + public static class BeansWorkaroundCustomCatalog extends DefaultCamelCatalog { + public BeansWorkaroundCustomCatalog(boolean caching) { + super(caching); + } + + @Override + public String pojoBeanJSonSchema(String name) { + return getJSonSchemaResolver().getPojoBeanJSonSchema(name).replace("model", "bean"); + } + } + } 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 74a853567d44..22726478d900 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 @@ -88,7 +88,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { final CqCatalog catalog = CqCatalog.findFirstFromClassPath(); if (extendClassPathCatalog) { catalog.store(catalogBaseDir.toPath()); - catalog.models().forEach(model -> schemesByKind.get(model.getKind()).add(model.getName())); + catalog.models().forEach(model -> schemesByKind.get(model.getKind().name()).add(model.getName())); } findExtensions()