This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 5a5de86ec15e32dc1a1445878e675d5b98a7ad38 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Sun Mar 5 21:44:41 2023 +0100 CAMEL-19117: camel-catalog - Remove archetypeAsXml from CamelCatalog --- .../camel/catalog/archetypes/archetype-catalog.xml | 41 ---------------------- .../org/apache/camel/catalog/CamelCatalog.java | 7 ---- .../apache/camel/catalog/DefaultCamelCatalog.java | 36 ++----------------- .../org/apache/camel/catalog/CamelCatalogTest.java | 6 ---- .../ROOT/pages/camel-4-migration-guide.adoc | 1 + .../camel/maven/packaging/PrepareCatalogMojo.java | 23 ------------ 6 files changed, 3 insertions(+), 111 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/archetypes/archetype-catalog.xml b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/archetypes/archetype-catalog.xml deleted file mode 100644 index b68f1eb6904..00000000000 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/archetypes/archetype-catalog.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<archetype-catalog> - <archetypes> - <archetype> - <groupId>org.apache.camel.archetypes</groupId> - <artifactId>camel-archetype-api-component</artifactId> - <version>4.0.0-SNAPSHOT</version> - <description>Creates a new Camel component that wraps one or more API proxies.</description> - </archetype> - <archetype> - <groupId>org.apache.camel.archetypes</groupId> - <artifactId>camel-archetype-component</artifactId> - <version>4.0.0-SNAPSHOT</version> - <description>Creates a new Camel component.</description> - </archetype> - <archetype> - <groupId>org.apache.camel.archetypes</groupId> - <artifactId>camel-archetype-dataformat</artifactId> - <version>4.0.0-SNAPSHOT</version> - <description>Creates a new Camel data format.</description> - </archetype> - <archetype> - <groupId>org.apache.camel.archetypes</groupId> - <artifactId>camel-archetype-java</artifactId> - <version>4.0.0-SNAPSHOT</version> - <description>Creates a new Camel project using Java DSL.</description> - </archetype> - <archetype> - <groupId>org.apache.camel.archetypes</groupId> - <artifactId>camel-archetype-main</artifactId> - <version>4.0.0-SNAPSHOT</version> - <description>Creates a new Camel project using standalone Camel Main.</description> - </archetype> - <archetype> - <groupId>org.apache.camel.archetypes</groupId> - <artifactId>camel-archetype-spring</artifactId> - <version>4.0.0-SNAPSHOT</version> - <description>Creates a new Camel project with added Spring DSL support.</description> - </archetype> - </archetypes> -</archetype-catalog> diff --git a/catalog/camel-catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java b/catalog/camel-catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java index ff9bcf1d13c..bd09766368c 100644 --- a/catalog/camel-catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java +++ b/catalog/camel-catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java @@ -321,13 +321,6 @@ public interface CamelCatalog { */ Set<String> findOtherLabels(); - /** - * Returns the Apache Camel Maven Archetype catalog in XML format. - * - * @return the catalog in XML - */ - String archetypeCatalogAsXml(); - /** * Returns the Camel Spring XML schema * diff --git a/catalog/camel-catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java b/catalog/camel-catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java index 5f6c2078446..f093d8c75e4 100644 --- a/catalog/camel-catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java +++ b/catalog/camel-catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java @@ -16,7 +16,6 @@ */ package org.apache.camel.catalog; -import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; @@ -34,13 +33,6 @@ import java.util.regex.PatternSyntaxException; import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.xml.XMLConstants; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathFactory; - -import org.w3c.dom.Document; - import org.apache.camel.catalog.impl.AbstractCamelCatalog; import org.apache.camel.catalog.impl.CatalogHelper; import org.apache.camel.tooling.model.ArtifactModel; @@ -60,7 +52,6 @@ import org.apache.camel.util.json.JsonObject; public class DefaultCamelCatalog extends AbstractCamelCatalog implements CamelCatalog { private static final String MODELS_CATALOG = "org/apache/camel/catalog/models.properties"; - private static final String ARCHETYPES_CATALOG = "org/apache/camel/catalog/archetypes/archetype-catalog.xml"; private static final String SCHEMAS_XML = "org/apache/camel/catalog/schemas"; private static final String MAIN_DIR = "org/apache/camel/catalog/main"; @@ -392,11 +383,6 @@ public class DefaultCamelCatalog extends AbstractCamelCatalog implements CamelCa return answer; } - @Override - public String archetypeCatalogAsXml() { - return cache(ARCHETYPES_CATALOG, this::loadResource); - } - @Override public String springSchemaAsXml() { return cache(SCHEMAS_XML + "/camel-spring.xsd", this::loadResource); @@ -457,11 +443,11 @@ public class DefaultCamelCatalog extends AbstractCamelCatalog implements CamelCa return cache("summaryAsJson", () -> { Map<String, Object> obj = new JsonObject(); obj.put("version", getCatalogVersion()); - obj.put("eips", findModelNames().size()); + obj.put("models", findModelNames().size()); obj.put("components", findComponentNames().size()); obj.put("dataformats", findDataFormatNames().size()); obj.put("languages", findLanguageNames().size()); - obj.put("archetypes", getArchetypesCount()); + obj.put("others", findOtherNames().size()); return JsonMapper.serialize(obj); }); } @@ -503,24 +489,6 @@ public class DefaultCamelCatalog extends AbstractCamelCatalog implements CamelCa && (version == null || version.isBlank() || version.equals(am.getVersion())); } - private int getArchetypesCount() { - int archetypes = 0; - try { - String xml = archetypeCatalogAsXml(); - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE); - dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", Boolean.TRUE); - Document dom = dbf.newDocumentBuilder().parse(new ByteArrayInputStream(xml.getBytes())); - Object val = XPathFactory.newInstance().newXPath().evaluate("count(/archetype-catalog/archetypes/archetype)", dom, - XPathConstants.NUMBER); - double num = (double) val; - archetypes = (int) num; - } catch (Exception e) { - // ignore - } - return archetypes; - } - @SuppressWarnings("unchecked") private <T> T cache(String name, Supplier<T> loader) { if (caching) { diff --git a/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java b/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java index efed7c1c2d1..f7656d10b7b 100644 --- a/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java +++ b/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java @@ -164,12 +164,6 @@ public class CamelCatalogTest { assertNotNull(schema); } - @Test - public void testArchetypeCatalog() { - String schema = catalog.archetypeCatalogAsXml(); - assertNotNull(schema); - } - @Test public void testMain() { String schema = catalog.mainJsonSchema(); diff --git a/docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc b/docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc index 98ac18aa79b..595012659e9 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc @@ -80,6 +80,7 @@ We have removed deprecated APIs such as the following: - Removed `Discard` and `DiscardOldest` from `org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy`. - Removed `org.apache.camel.builder.SimpleBuilder`. Was mostly used internally in Camel with the Java DSL in some situations. - Moved `org.apache.camel.support.IntrospectionSupport` to `camel-core-engine` for internal use only. End users should use `org.apache.camel.spi.BeanInspection` instead. +- Removed `archetypeCatalogAsXml` method from `org.apache.camel.catalog.CamelCatalog`. == EIP Changes diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogMojo.java index 62f4e283a2d..15ed57e98ae 100644 --- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogMojo.java +++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogMojo.java @@ -111,12 +111,6 @@ public class PrepareCatalogMojo extends AbstractMojo { @Parameter(defaultValue = "${project.basedir}/src/generated/resources/org/apache/camel/catalog/models") protected File modelsOutDir; - /** - * The output directory for archetypes catalog - */ - @Parameter(defaultValue = "${project.basedir}/src/generated/resources/org/apache/camel/catalog/archetypes") - protected File archetypesOutDir; - /** * The output directory for XML schemas catalog */ @@ -165,12 +159,6 @@ public class PrepareCatalogMojo extends AbstractMojo { @Parameter(defaultValue = "${project.build.directory}/../../../components/camel-spring-xml") protected File springDir; - /** - * The archetypes directory where all the Apache Camel Maven archetypes are - */ - @Parameter(defaultValue = "${project.build.directory}/../../../archetypes") - protected File archetypesDir; - /** * The directory where the camel-spring XML schema are */ @@ -290,7 +278,6 @@ public class PrepareCatalogMojo extends AbstractMojo { Set<String> languages = executeLanguages(); Set<String> others = executeOthers(); executeDocuments(components, dataformats, languages, others); - executeArchetypes(); executeXmlSchemas(); executeMain(); } catch (Exception e) { @@ -705,16 +692,6 @@ public class PrepareCatalogMojo extends AbstractMojo { return otherNames; } - protected void executeArchetypes() throws Exception { - Path archetypesDir = this.archetypesDir.toPath(); - Path archetypesOutDir = this.archetypesOutDir.toPath(); - - getLog().info("Copying Archetype Catalog"); - - // find the generate catalog - copyFile(archetypesDir.resolve("target/classes/archetype-catalog.xml"), archetypesOutDir); - } - protected void executeXmlSchemas() throws Exception { Path schemasOutDir = this.schemasOutDir.toPath(); Path springSchemaDir = this.springSchemaDir.toPath();