This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git
The following commit(s) were added to refs/heads/main by this push:
new cc138ab tools: allow to exclude
components/dataformat/languages/dsld/capabilities from the generated
camel-k-catalog
cc138ab is described below
commit cc138ab95f06203ab55826dabb1710e90c8bd298
Author: Luca Burgazzoli <[email protected]>
AuthorDate: Wed Sep 1 12:48:41 2021 +0200
tools: allow to exclude components/dataformat/languages/dsld/capabilities
from the generated camel-k-catalog
---
pom.xml | 2 +-
support/camel-k-maven-plugin/pom.xml | 1 +
.../it/generate-catalog-with-exclusions/pom.xml | 109 ++++++
.../verify.groovy} | 36 +-
.../src/it/generate-catalog/verify.groovy | 11 +-
.../camel/k/tooling/maven/GenerateCatalogMojo.java | 379 ++++++++++++++++++---
.../maven/processors/CatalogProcessor3x.java | 280 ---------------
....camel.k.tooling.maven.support.CatalogProcessor | 18 -
.../processors/AbstractCatalogProcessorTest.java | 31 --
.../maven/processors/CatalogProcessor3Test.java | 113 ------
10 files changed, 457 insertions(+), 523 deletions(-)
diff --git a/pom.xml b/pom.xml
index 1cb493b..a8326df 100644
--- a/pom.xml
+++ b/pom.xml
@@ -66,7 +66,7 @@
<exec-maven-plugin-version>3.0.0</exec-maven-plugin-version>
<mycila-license-version>4.1</mycila-license-version>
<maven-checkstyle-plugin-version>3.1.2</maven-checkstyle-plugin-version>
- <maven-checkstyle-version>8.26</maven-checkstyle-version>
+ <maven-checkstyle-version>8.43</maven-checkstyle-version>
<maven-gpg-plugin-version>3.0.1</maven-gpg-plugin-version>
<maven-deploy-plugin-version>3.0.0-M1</maven-deploy-plugin-version>
<maven-javadoc-plugin-version>3.3.0</maven-javadoc-plugin-version>
diff --git a/support/camel-k-maven-plugin/pom.xml
b/support/camel-k-maven-plugin/pom.xml
index 5e818fc..90c0b44 100644
--- a/support/camel-k-maven-plugin/pom.xml
+++ b/support/camel-k-maven-plugin/pom.xml
@@ -200,6 +200,7 @@
</scriptVariables>
<pomIncludes>
<pomInclude>generate-catalog/pom.xml</pomInclude>
+
<pomInclude>generate-catalog-with-exclusions/pom.xml</pomInclude>
<pomInclude>generate-rest-dsl-from-v3/pom.xml</pomInclude>
<pomInclude>generate-rest-dsl-from-v2/pom.xml</pomInclude>
<pomInclude>generate-dependencies/pom.xml</pomInclude>
diff --git
a/support/camel-k-maven-plugin/src/it/generate-catalog-with-exclusions/pom.xml
b/support/camel-k-maven-plugin/src/it/generate-catalog-with-exclusions/pom.xml
new file mode 100644
index 0000000..b0cfd14
--- /dev/null
+++
b/support/camel-k-maven-plugin/src/it/generate-catalog-with-exclusions/pom.xml
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-k-catalog-generator</artifactId>
+ <version>1.0.0</version>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <catalog.path>${project.basedir}</catalog.path>
+ <catalog.runtime>quarkus</catalog.runtime>
+ <catalog.file>catalog.yaml</catalog.file>
+ <!-- exclusion list -->
+ <dsls.exclusion.list>jsh,js,kts,groovy</dsls.exclusion.list>
+ <dataformats.exclusion.list>avro-jackson</dataformats.exclusion.list>
+ <languages.exclusion.list>csimple</languages.exclusion.list>
+
<components.exclusion.list>disruptor,disruptor-vm</components.exclusion.list>
+ <capabilities.exclusion.list>master</capabilities.exclusion.list>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-k-maven-plugin</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <id>generate-catalog</id>
+ <goals>
+ <goal>generate-catalog</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache.snapshots</id>
+ <name>Apache Development Snapshot Repository</name>
+
<url>https://repository.apache.org/content/repositories/snapshots/</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>oss.snapshots</id>
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>apache.snapshots</id>
+ <name>Apache Development Snapshot Repository</name>
+
<url>https://repository.apache.org/content/repositories/snapshots/</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ <pluginRepository>
+ <id>oss.snapshots</id>
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+
+</project>
diff --git
a/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/support/CatalogProcessor.java
b/support/camel-k-maven-plugin/src/it/generate-catalog-with-exclusions/verify.groovy
similarity index 51%
rename from
support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/support/CatalogProcessor.java
rename to
support/camel-k-maven-plugin/src/it/generate-catalog-with-exclusions/verify.groovy
index b7d908e..2191826 100644
---
a/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/support/CatalogProcessor.java
+++
b/support/camel-k-maven-plugin/src/it/generate-catalog-with-exclusions/verify.groovy
@@ -14,31 +14,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.k.tooling.maven.support;
-import java.util.List;
+new File(basedir, "catalog.yaml").withReader {
+ def catalog = new groovy.yaml.YamlSlurper().parse(it)
-import org.apache.camel.catalog.CamelCatalog;
-import org.apache.camel.k.catalog.model.k8s.crd.CamelCatalogSpec;
-import org.apache.maven.project.MavenProject;
+ assert catalog.spec.loaders['jsh'] == null
+ assert catalog.spec.loaders['kts'] == null
+ assert catalog.spec.loaders['js'] == null
+ assert catalog.spec.loaders['groovy'] == null
-public interface CatalogProcessor {
- /**
- * The highest precedence
- */
- int HIGHEST = Integer.MIN_VALUE;
+ assert catalog.spec.loaders['java'] != null
+ assert catalog.spec.loaders['xml'] != null
+ assert catalog.spec.loaders['yaml'] != null
- /**
- * The lowest precedence
- */
- int LOWEST = Integer.MAX_VALUE;
+ assert catalog.spec.artifacts['camel-quarkus-jackson-avro'] == null
+ assert catalog.spec.artifacts['camel-quarkus-csimple'] == null
+ assert catalog.spec.artifacts['camel-quarkus-disruptor'] == null
- boolean accepts(CamelCatalog catalog);
-
- void process(MavenProject project, CamelCatalog catalog,
CamelCatalogSpec.Builder specBuilder,
- List<String> exclusions);
-
- default int getOrder() {
- return LOWEST;
- }
+ assert catalog.spec.runtime.capabilities['master'] == null
+ assert catalog.spec.artifacts['camel-k-master'] == null
}
diff --git a/support/camel-k-maven-plugin/src/it/generate-catalog/verify.groovy
b/support/camel-k-maven-plugin/src/it/generate-catalog/verify.groovy
index aae3b13..032c246 100644
--- a/support/camel-k-maven-plugin/src/it/generate-catalog/verify.groovy
+++ b/support/camel-k-maven-plugin/src/it/generate-catalog/verify.groovy
@@ -24,7 +24,6 @@ new File(basedir, "catalog.yaml").withReader {
assert catalog.spec.runtime.metadata['quarkus.version'] == quarkusVersion
assert catalog.spec.runtime.metadata['camel-quarkus.version'] ==
camelQuarkusVersion
-
assert catalog.spec.runtime.dependencies.any {
it.groupId == 'org.apache.camel.k' && it.artifactId ==
'camel-k-runtime'
}
@@ -52,9 +51,6 @@ new File(basedir, "catalog.yaml").withReader {
catalog.spec.artifacts['camel-k-cron'].with {
schemes == null
}
- catalog.spec.artifacts['camel-k-webhook'].with {
- schemes == null
- }
def diff = org.apache.commons.collections4.CollectionUtils.disjunction(
catalog.spec.artifacts.values()
@@ -70,6 +66,13 @@ new File(basedir, "catalog.yaml").withReader {
assert diff.size() == 0 : "Duplicated schemes: ${diff}"
+ catalog.spec.artifacts.each { k,v ->
+ assert k != null
+ assert v.groupId != null
+ assert v.artifactId != null
+ assert v.version == null
+ }
+
catalog.spec.artifacts['camel-k-knative'].with {
assert dependencies == null
assert requiredCapabilities == null
diff --git
a/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
b/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
index c98c555..17061d0 100644
---
a/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
+++
b/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
@@ -23,12 +23,13 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import java.util.Locale;
-import java.util.ServiceLoader;
-import java.util.stream.StreamSupport;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -38,14 +39,23 @@ import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import org.apache.camel.catalog.DefaultCamelCatalog;
import org.apache.camel.catalog.quarkus.QuarkusRuntimeProvider;
import org.apache.camel.impl.engine.AbstractCamelContext;
+import org.apache.camel.k.catalog.model.CamelArtifact;
import org.apache.camel.k.catalog.model.CamelCapability;
+import org.apache.camel.k.catalog.model.CamelLoader;
+import org.apache.camel.k.catalog.model.CamelScheme;
+import org.apache.camel.k.catalog.model.CamelScopedArtifact;
+import org.apache.camel.k.catalog.model.CatalogComponentDefinition;
+import org.apache.camel.k.catalog.model.CatalogDataFormatDefinition;
+import org.apache.camel.k.catalog.model.CatalogDefinition;
+import org.apache.camel.k.catalog.model.CatalogLanguageDefinition;
+import org.apache.camel.k.catalog.model.CatalogSupport;
import org.apache.camel.k.catalog.model.k8s.ObjectMeta;
import org.apache.camel.k.catalog.model.k8s.crd.CamelCatalog;
import org.apache.camel.k.catalog.model.k8s.crd.CamelCatalogSpec;
import org.apache.camel.k.catalog.model.k8s.crd.RuntimeSpec;
-import org.apache.camel.k.tooling.maven.support.CatalogProcessor;
import org.apache.camel.k.tooling.maven.support.MavenSupport;
import org.apache.camel.quarkus.core.FastCamelContext;
+import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
@@ -53,7 +63,6 @@ import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.apache.maven.project.MavenProject;
@Mojo(
name = "generate-catalog",
@@ -62,9 +71,46 @@ import org.apache.maven.project.MavenProject;
requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME,
requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME)
public class GenerateCatalogMojo extends AbstractMojo {
+ private static final List<String> KNOWN_HTTP_URIS = Arrays.asList(
+ "ahc",
+ "ahc-ws",
+ "atmosphere-websocket",
+ "cxf",
+ "cxfrs",
+ "grpc",
+ "jetty",
+ "netty-http",
+ "platform-http",
+ "rest",
+ "restlet",
+ "servlet",
+ "spark-rest",
+ "spring-ws",
+ "undertow",
+ "webhook",
+ "websocket"
+ );
- @Parameter(readonly = true, defaultValue = "${project}")
- private MavenProject project;
+ private static final List<String> KNOWN_PASSIVE_URIS = Arrays.asList(
+ "bean",
+ "binding",
+ "browse",
+ "class",
+ "controlbus",
+ "dataformat",
+ "dataset",
+ "direct",
+ "direct-vm",
+ "language",
+ "log",
+ "mock",
+ "ref",
+ "seda",
+ "stub",
+ "test",
+ "validator",
+ "vm"
+ );
@Parameter(property = "catalog.path", defaultValue =
"${project.build.directory}")
private String outputPath;
@@ -72,8 +118,20 @@ public class GenerateCatalogMojo extends AbstractMojo {
@Parameter(property = "catalog.file", defaultValue =
"camel-catalog-${runtime.version}.yaml")
private String outputFile;
- @Parameter(property = "exclusion.list")
- private String exclusionList;
+ @Parameter(property = "components.exclusion.list")
+ private Set<String> componentsExclusionList;
+
+ @Parameter(property = "dataformats.exclusion.list")
+ private Set<String> dataformatsExclusionList;
+
+ @Parameter(property = "languages.exclusion.list")
+ private Set<String> languagesExclusionList;
+
+ @Parameter(property = "dsls.exclusion.list")
+ private Set<String> dslsExclusionList;
+
+ @Parameter(property = "capabilities.exclusion.list")
+ private Set<String> capabilitiesExclusionList;
// ********************
//
@@ -101,6 +159,8 @@ public class GenerateCatalogMojo extends AbstractMojo {
final String catalogName = String.format("camel-catalog-%s",
runtimeVersion.toLowerCase(Locale.US));
try {
+ CamelCatalogSpec.Builder catalogSpec = new
CamelCatalogSpec.Builder();
+
RuntimeSpec.Builder runtimeSpec = new RuntimeSpec.Builder()
.version(runtimeVersion)
.provider("quarkus");
@@ -121,46 +181,69 @@ public class GenerateCatalogMojo extends AbstractMojo {
runtimeSpec.applicationClass("io.quarkus.bootstrap.runner.QuarkusEntryPoint");
runtimeSpec.addDependency("org.apache.camel.k", "camel-k-runtime");
runtimeSpec.addDependency("io.quarkus", "quarkus-logging-json");
- runtimeSpec.putCapability(
- "cron",
- CamelCapability.forArtifact(
- "org.apache.camel.k", "camel-k-cron"));
- runtimeSpec.putCapability(
- "health",
- CamelCapability.forArtifact(
- "org.apache.camel.quarkus",
"camel-quarkus-microprofile-health"));
- runtimeSpec.putCapability(
- "platform-http",
- CamelCapability.forArtifact(
- "org.apache.camel.quarkus",
"camel-quarkus-platform-http"));
- runtimeSpec.putCapability(
- "rest",
- new CamelCapability.Builder()
- .addDependency("org.apache.camel.quarkus",
"camel-quarkus-rest")
- .addDependency("org.apache.camel.quarkus",
"camel-quarkus-platform-http")
- .build());
- runtimeSpec.putCapability(
- "circuit-breaker",
- CamelCapability.forArtifact(
- "org.apache.camel.quarkus",
"camel-quarkus-microprofile-fault-tolerance"));
- runtimeSpec.putCapability(
- "tracing",
- CamelCapability.forArtifact(
- "org.apache.camel.quarkus", "camel-quarkus-opentracing"));
- runtimeSpec.putCapability(
- "master",
- CamelCapability.forArtifact(
- "org.apache.camel.k", "camel-k-master"));
-
- CamelCatalogSpec.Builder catalogSpec = new
CamelCatalogSpec.Builder()
- .runtime(runtimeSpec.build());
-
- List<String> exclusions = createExclusionList();
-
-
StreamSupport.stream(ServiceLoader.load(CatalogProcessor.class).spliterator(),
false)
- .sorted(Comparator.comparingInt(CatalogProcessor::getOrder))
- .filter(p -> p.accepts(catalog))
- .forEach(p -> p.process(project, catalog, catalogSpec,
exclusions));
+
+ if (capabilitiesExclusionList != null &&
!capabilitiesExclusionList.contains("cron")) {
+ runtimeSpec.putCapability(
+ "cron",
+ CamelCapability.forArtifact(
+ "org.apache.camel.k", "camel-k-cron"));
+
+ catalogSpec.putArtifact(
+ new CamelArtifact.Builder()
+ .groupId("org.apache.camel.k")
+ .artifactId("camel-k-cron")
+ .build()
+ );
+ }
+ if (capabilitiesExclusionList != null &&
!capabilitiesExclusionList.contains("health")) {
+ runtimeSpec.putCapability(
+ "health",
+ CamelCapability.forArtifact(
+ "org.apache.camel.quarkus",
"camel-quarkus-microprofile-health"));
+ }
+ if (capabilitiesExclusionList != null &&
!capabilitiesExclusionList.contains("platform-http")) {
+ runtimeSpec.putCapability(
+ "platform-http",
+ CamelCapability.forArtifact(
+ "org.apache.camel.quarkus",
"camel-quarkus-platform-http"));
+ }
+ if (capabilitiesExclusionList != null &&
!capabilitiesExclusionList.contains("rest")) {
+ runtimeSpec.putCapability(
+ "rest",
+ new CamelCapability.Builder()
+ .addDependency("org.apache.camel.quarkus",
"camel-quarkus-rest")
+ .addDependency("org.apache.camel.quarkus",
"camel-quarkus-platform-http")
+ .build());
+ }
+ if (capabilitiesExclusionList != null &&
!capabilitiesExclusionList.contains("circuit-breaker")) {
+ runtimeSpec.putCapability(
+ "circuit-breaker",
+ CamelCapability.forArtifact(
+ "org.apache.camel.quarkus",
"camel-quarkus-microprofile-fault-tolerance"));
+ }
+ if (capabilitiesExclusionList != null &&
!capabilitiesExclusionList.contains("tracing")) {
+ runtimeSpec.putCapability(
+ "tracing",
+ CamelCapability.forArtifact(
+ "org.apache.camel.quarkus",
"camel-quarkus-opentracing"));
+ }
+ if (capabilitiesExclusionList != null &&
!capabilitiesExclusionList.contains("master")) {
+ runtimeSpec.putCapability(
+ "master",
+ CamelCapability.forArtifact(
+ "org.apache.camel.k", "camel-k-master"));
+
+ catalogSpec.putArtifact(
+ new CamelArtifact.Builder()
+ .groupId("org.apache.camel.k")
+ .artifactId("camel-k-master")
+ .build()
+ );
+ }
+
+ catalogSpec.runtime(runtimeSpec.build());
+
+ process(catalog, catalogSpec);
ObjectMeta.Builder metadata = new ObjectMeta.Builder()
.name(catalogName)
@@ -218,11 +301,199 @@ public class GenerateCatalogMojo extends AbstractMojo {
}
}
- private List<String> createExclusionList() {
- if (exclusionList != null) {
- return Arrays.asList(exclusionList.split(","));
+ // ********************
+ //
+ // ********************
+
+ public void process(
+ org.apache.camel.catalog.CamelCatalog catalog,
+ CamelCatalogSpec.Builder specBuilder) {
+
+ Map<String, CamelArtifact> artifacts = new TreeMap<>();
+
+ processComponents(catalog, artifacts);
+ processLanguages(catalog, artifacts);
+ processDataFormats(catalog, artifacts);
+ processLoaders(specBuilder);
+
+ specBuilder.putAllArtifacts(artifacts);
+
+
+ specBuilder.putArtifact(
+ new CamelArtifact.Builder()
+ .groupId("org.apache.camel.k")
+ .artifactId("camel-k-knative")
+ .addScheme(new CamelScheme.Builder()
+ .id("knative")
+ .http(true)
+ .consumer(new CamelScopedArtifact.Builder()
+ .addDependency("org.apache.camel.k",
"camel-k-knative-consumer")
+ .build())
+ .producer(new CamelScopedArtifact.Builder()
+ .addDependency("org.apache.camel.k",
"camel-k-knative-producer")
+ .build())
+ .build())
+ .build()
+ );
+ }
+
+ private void processLoaders(CamelCatalogSpec.Builder specBuilder) {
+ if (dslsExclusionList != null) {
+ getLog().info("dsls.exclusion.list: " + dslsExclusionList);
+ }
+
+ if (dslsExclusionList != null && !dslsExclusionList.contains("yaml")) {
+ specBuilder.putLoader(
+ "yaml",
+ CamelLoader.fromArtifact("org.apache.camel.quarkus",
"camel-quarkus-yaml-dsl")
+ .addLanguage("yaml")
+ .putMetadata("native", "true")
+ .build()
+ );
+ }
+ if (dslsExclusionList != null &&
!dslsExclusionList.contains("groovy")) {
+ specBuilder.putLoader(
+ "groovy",
+ CamelLoader.fromArtifact("org.apache.camel.quarkus",
"camel-quarkus-groovy-dsl")
+ .addLanguage("groovy")
+ .putMetadata("native", "false")
+ .build()
+ );
+ }
+ if (dslsExclusionList != null && !dslsExclusionList.contains("kts")) {
+ specBuilder.putLoader(
+ "kts",
+ CamelLoader.fromArtifact("org.apache.camel.quarkus",
"camel-quarkus-kotlin-dsl")
+ .addLanguage("kts")
+ .putMetadata("native", "false")
+ .build()
+ );
+ }
+ if (dslsExclusionList != null && !dslsExclusionList.contains("js")) {
+ specBuilder.putLoader(
+ "js",
+ CamelLoader.fromArtifact("org.apache.camel.quarkus",
"camel-quarkus-js-dsl")
+ .addLanguage("js")
+ .putMetadata("native", "true")
+ .build()
+ );
+ }
+ if (dslsExclusionList != null && !dslsExclusionList.contains("xml")) {
+ specBuilder.putLoader(
+ "xml",
+ CamelLoader.fromArtifact("org.apache.camel.quarkus",
"camel-quarkus-xml-io-dsl")
+ .addLanguage("xml")
+ .putMetadata("native", "true")
+ .build()
+ );
+ }
+ if (dslsExclusionList != null && !dslsExclusionList.contains("java")) {
+ specBuilder.putLoader(
+ "java",
+ CamelLoader.fromArtifact("org.apache.camel.quarkus",
"camel-quarkus-java-joor-dsl")
+ .addLanguages("java")
+ .putMetadata("native", "false")
+ .build()
+ );
+ }
+ if (dslsExclusionList != null && !dslsExclusionList.contains("jsh")) {
+ specBuilder.putLoader(
+ "jsh",
+ CamelLoader.fromArtifact("org.apache.camel.k",
"camel-k-loader-jsh")
+ .addLanguages("jsh")
+ .putMetadata("native", "false")
+ .build()
+ );
+ }
+ }
+
+ private void processComponents(org.apache.camel.catalog.CamelCatalog
catalog, Map<String, CamelArtifact> artifacts) {
+ final Set<String> elements = new
TreeSet<>(catalog.findComponentNames());
+
+ if (componentsExclusionList != null) {
+ getLog().info("components.exclusion.list: " +
componentsExclusionList);
+ elements.removeAll(componentsExclusionList);
+ }
+
+ for (String name : elements) {
+ String json = catalog.componentJSonSchema(name);
+ CatalogComponentDefinition definition =
CatalogSupport.unmarshallComponent(json);
+
+ artifacts.compute(definition.getArtifactId(), (key, artifact) -> {
+ CamelArtifact.Builder builder = artifactBuilder(artifact,
definition);
+ builder.addJavaType(definition.getJavaType());
+
+
definition.getSchemes().map(StringUtils::trimToNull).filter(Objects::nonNull).forEach(scheme
-> {
+ builder.addScheme(
+ new CamelScheme.Builder()
+ .id(scheme)
+ .http(KNOWN_HTTP_URIS.contains(scheme))
+ .passive(KNOWN_PASSIVE_URIS.contains(scheme))
+ .build());
+ });
+
+ return builder.build();
+ });
+ }
+ }
+
+ private void processLanguages(org.apache.camel.catalog.CamelCatalog
catalog, Map<String, CamelArtifact> artifacts) {
+ final Set<String> elements = new
TreeSet<>(catalog.findLanguageNames());
+
+ if (languagesExclusionList != null) {
+ getLog().info("languages.exclusion.list: " +
languagesExclusionList);
+ elements.removeAll(languagesExclusionList);
+ }
+
+ for (String name : elements) {
+ String json = catalog.languageJSonSchema(name);
+ CatalogLanguageDefinition definition =
CatalogSupport.unmarshallLanguage(json);
+
+ artifacts.compute(definition.getArtifactId(), (key, artifact) -> {
+ CamelArtifact.Builder builder = artifactBuilder(artifact,
definition);
+ builder.addLanguage(definition.getName());
+ builder.addJavaType(definition.getJavaType());
+
+ return builder.build();
+ });
+ }
+ }
+
+ private void processDataFormats(org.apache.camel.catalog.CamelCatalog
catalog, Map<String, CamelArtifact> artifacts) {
+ final Set<String> elements = new
TreeSet<>(catalog.findDataFormatNames());
+
+ if (dataformatsExclusionList != null) {
+ getLog().info("dataformats.exclusion.list: " +
dataformatsExclusionList);
+ elements.removeAll(dataformatsExclusionList);
+ }
+
+ for (String name : elements) {
+ String json = catalog.dataFormatJSonSchema(name);
+ CatalogDataFormatDefinition definition =
CatalogSupport.unmarshallDataFormat(json);
+
+ artifacts.compute(definition.getArtifactId(), (key, artifact) -> {
+ CamelArtifact.Builder builder = artifactBuilder(artifact,
definition);
+ builder.addDataformat(definition.getName());
+ builder.addJavaType(definition.getJavaType());
+
+ return builder.build();
+ });
+ }
+ }
+
+ private CamelArtifact.Builder artifactBuilder(CamelArtifact artifact,
CatalogDefinition definition) {
+ CamelArtifact.Builder builder = new CamelArtifact.Builder();
+
+ if (artifact != null) {
+ builder.from(artifact);
+ } else {
+ Objects.requireNonNull(definition.getGroupId());
+ Objects.requireNonNull(definition.getArtifactId());
+
+ builder.groupId(definition.getGroupId());
+ builder.artifactId(definition.getArtifactId());
}
- return Collections.emptyList();
+ return builder;
}
}
diff --git
a/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor3x.java
b/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor3x.java
deleted file mode 100644
index a8a2a6a..0000000
---
a/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor3x.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.k.tooling.maven.processors;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import com.vdurmont.semver4j.Semver;
-import org.apache.camel.catalog.CamelCatalog;
-import org.apache.camel.k.catalog.model.CamelArtifact;
-import org.apache.camel.k.catalog.model.CamelLoader;
-import org.apache.camel.k.catalog.model.CamelScheme;
-import org.apache.camel.k.catalog.model.CamelScopedArtifact;
-import org.apache.camel.k.catalog.model.CatalogComponentDefinition;
-import org.apache.camel.k.catalog.model.CatalogDataFormatDefinition;
-import org.apache.camel.k.catalog.model.CatalogDefinition;
-import org.apache.camel.k.catalog.model.CatalogLanguageDefinition;
-import org.apache.camel.k.catalog.model.CatalogSupport;
-import org.apache.camel.k.catalog.model.k8s.crd.CamelCatalogSpec;
-import org.apache.camel.k.tooling.maven.support.CatalogProcessor;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.maven.project.MavenProject;
-
-public class CatalogProcessor3x implements CatalogProcessor {
- private static final List<String> KNOWN_HTTP_URIS = Arrays.asList(
- "ahc",
- "ahc-ws",
- "atmosphere-websocket",
- "cxf",
- "cxfrs",
- "grpc",
- "jetty",
- "netty-http",
- "platform-http",
- "rest",
- "restlet",
- "servlet",
- "spark-rest",
- "spring-ws",
- "undertow",
- "webhook",
- "websocket"
- );
-
- private static final List<String> KNOWN_PASSIVE_URIS = Arrays.asList(
- "bean",
- "binding",
- "browse",
- "class",
- "controlbus",
- "dataformat",
- "dataset",
- "direct",
- "direct-vm",
- "language",
- "log",
- "mock",
- "ref",
- "seda",
- "stub",
- "test",
- "validator",
- "vm"
- );
-
- @Override
- public int getOrder() {
- return HIGHEST;
- }
-
- @Override
- public boolean accepts(CamelCatalog catalog) {
- Semver semver = new Semver(catalog.getCatalogVersion(),
Semver.SemverType.IVY);
- return semver.isGreaterThan("2.999.999") &&
semver.isLowerThan("4.0.0");
- }
-
- @Override
- public void process(MavenProject project, CamelCatalog catalog,
CamelCatalogSpec.Builder specBuilder,
- List<String> exclusions) {
- Map<String, CamelArtifact> artifacts = new TreeMap<>();
-
- processComponents(catalog, artifacts, exclusions);
- processLanguages(catalog, artifacts);
- processDataFormats(catalog, artifacts);
- processLoaders(specBuilder);
-
- artifacts.computeIfPresent("camel-http",
- (key, artifact) -> new CamelArtifact.Builder()
- .from(artifact)
- .addDependency("org.apache.camel", "camel-file")
- .build()
- );
-
- specBuilder.putAllArtifacts(artifacts);
-
- specBuilder.putArtifact(
- new CamelArtifact.Builder()
- .groupId("org.apache.camel.k")
- .artifactId("camel-k-cron")
- .build()
- );
- specBuilder.putArtifact(
- new CamelArtifact.Builder()
- .groupId("org.apache.camel.k")
- .artifactId("camel-k-webhook")
- .build()
- );
- specBuilder.putArtifact(
- new CamelArtifact.Builder()
- .groupId("org.apache.camel.k")
- .artifactId("camel-k-master")
- .build()
- );
-
- specBuilder.putArtifact(
- new CamelArtifact.Builder()
- .groupId("org.apache.camel.k")
- .artifactId("camel-k-knative")
- .addScheme(new CamelScheme.Builder()
- .id("knative")
- .http(true)
- .consumer(new CamelScopedArtifact.Builder()
- .addDependency("org.apache.camel.k",
"camel-k-knative-consumer")
- .build())
- .producer(new CamelScopedArtifact.Builder()
- .addDependency("org.apache.camel.k",
"camel-k-knative-producer")
- .build())
- .build())
- .build()
- );
- }
-
- private static void processLoaders(CamelCatalogSpec.Builder specBuilder) {
- specBuilder.putLoader(
- "yaml",
- CamelLoader.fromArtifact("org.apache.camel.quarkus",
"camel-quarkus-yaml-dsl")
- .addLanguage("yaml")
- .putMetadata("native", "true")
- .build()
- );
- specBuilder.putLoader(
- "groovy",
- CamelLoader.fromArtifact("org.apache.camel.quarkus",
"camel-quarkus-groovy-dsl")
- .addLanguage("groovy")
- .putMetadata("native", "false")
- .build()
- );
- specBuilder.putLoader(
- "kts",
- CamelLoader.fromArtifact("org.apache.camel.quarkus",
"camel-quarkus-kotlin-dsl")
- .addLanguage("kts")
- .putMetadata("native", "false")
- .build()
- );
- specBuilder.putLoader(
- "js",
- CamelLoader.fromArtifact("org.apache.camel.quarkus",
"camel-quarkus-js-dsl")
- .addLanguage("js")
- .putMetadata("native", "true")
- .build()
- );
- specBuilder.putLoader(
- "xml",
- CamelLoader.fromArtifact("org.apache.camel.quarkus",
"camel-quarkus-xml-io-dsl")
- .addLanguage("xml")
- .putMetadata("native", "true")
- .build()
- );
- specBuilder.putLoader(
- "java",
- CamelLoader.fromArtifact("org.apache.camel.quarkus",
"camel-quarkus-java-joor-dsl")
- .addLanguages("java")
- .putMetadata("native", "false")
- .build()
- );
- specBuilder.putLoader(
- "jsh",
- CamelLoader.fromArtifact("org.apache.camel.k",
"camel-k-loader-jsh")
- .addLanguages("jsh")
- .putMetadata("native", "false")
- .build()
- );
- }
-
- private static void processComponents(CamelCatalog catalog, Map<String,
CamelArtifact> artifacts, List<String> exclusions) {
- final Set<String> elements = new
TreeSet<>(catalog.findComponentNames());
-
- elements.removeAll(exclusions);
-
- for (String name : elements) {
- String json = catalog.componentJSonSchema(name);
- CatalogComponentDefinition definition =
CatalogSupport.unmarshallComponent(json);
-
- artifacts.compute(definition.getArtifactId(), (key, artifact) -> {
- CamelArtifact.Builder builder = artifactBuilder(artifact,
definition);
- builder.addJavaType(definition.getJavaType());
-
-
definition.getSchemes().map(StringUtils::trimToNull).filter(Objects::nonNull).forEach(scheme
-> {
- builder.addScheme(
- new CamelScheme.Builder()
- .id(scheme)
- .http(KNOWN_HTTP_URIS.contains(scheme))
- .passive(KNOWN_PASSIVE_URIS.contains(scheme))
- .build());
- });
-
- return builder.build();
- });
- }
- }
-
- private static void processLanguages(CamelCatalog catalog, Map<String,
CamelArtifact> artifacts) {
- final Set<String> elements = new
TreeSet<>(catalog.findLanguageNames());
-
- for (String name : elements) {
- String json = catalog.languageJSonSchema(name);
- CatalogLanguageDefinition definition =
CatalogSupport.unmarshallLanguage(json);
-
- artifacts.compute(definition.getArtifactId(), (key, artifact) -> {
- CamelArtifact.Builder builder = artifactBuilder(artifact,
definition);
- builder.addLanguage(definition.getName());
- builder.addJavaType(definition.getJavaType());
-
- return builder.build();
- });
- }
- }
-
- private static void processDataFormats(CamelCatalog catalog, Map<String,
CamelArtifact> artifacts) {
- final Set<String> elements = new
TreeSet<>(catalog.findDataFormatNames());
-
- for (String name : elements) {
- String json = catalog.dataFormatJSonSchema(name);
- CatalogDataFormatDefinition definition =
CatalogSupport.unmarshallDataFormat(json);
-
- artifacts.compute(definition.getArtifactId(), (key, artifact) -> {
- CamelArtifact.Builder builder = artifactBuilder(artifact,
definition);
- builder.addDataformat(definition.getName());
- builder.addJavaType(definition.getJavaType());
-
- return builder.build();
- });
- }
- }
-
- private static CamelArtifact.Builder artifactBuilder(CamelArtifact
artifact, CatalogDefinition definition) {
- CamelArtifact.Builder builder = new CamelArtifact.Builder();
-
- if (artifact != null) {
- builder.from(artifact);
- } else {
- Objects.requireNonNull(definition.getGroupId());
- Objects.requireNonNull(definition.getArtifactId());
-
- builder.groupId(definition.getGroupId());
- builder.artifactId(definition.getArtifactId());
- }
-
- return builder;
- }
-}
diff --git
a/support/camel-k-maven-plugin/src/main/resources/META-INF/services/org.apache.camel.k.tooling.maven.support.CatalogProcessor
b/support/camel-k-maven-plugin/src/main/resources/META-INF/services/org.apache.camel.k.tooling.maven.support.CatalogProcessor
deleted file mode 100644
index 28059d1..0000000
---
a/support/camel-k-maven-plugin/src/main/resources/META-INF/services/org.apache.camel.k.tooling.maven.support.CatalogProcessor
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.camel.k.tooling.maven.processors.CatalogProcessor3x
diff --git
a/support/camel-k-maven-plugin/src/test/java/org/apache/camel/k/tooling/maven/processors/AbstractCatalogProcessorTest.java
b/support/camel-k-maven-plugin/src/test/java/org/apache/camel/k/tooling/maven/processors/AbstractCatalogProcessorTest.java
deleted file mode 100644
index f47f0ce..0000000
---
a/support/camel-k-maven-plugin/src/test/java/org/apache/camel/k/tooling/maven/processors/AbstractCatalogProcessorTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.k.tooling.maven.processors;
-
-import org.apache.camel.catalog.CamelCatalog;
-import org.apache.camel.catalog.DefaultCamelCatalog;
-
-public abstract class AbstractCatalogProcessorTest {
- protected CamelCatalog versionCamelCatalog(String version) {
- return new DefaultCamelCatalog() {
- @Override
- public String getCatalogVersion() {
- return version;
- }
- };
- }
-}
diff --git
a/support/camel-k-maven-plugin/src/test/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor3Test.java
b/support/camel-k-maven-plugin/src/test/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor3Test.java
deleted file mode 100644
index 96ac3bb..0000000
---
a/support/camel-k-maven-plugin/src/test/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor3Test.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.k.tooling.maven.processors;
-
-import java.util.Collections;
-import java.util.Map;
-
-import org.apache.camel.catalog.CamelCatalog;
-import org.apache.camel.k.catalog.model.Artifact;
-import org.apache.camel.k.catalog.model.CamelArtifact;
-import org.apache.camel.k.catalog.model.k8s.crd.CamelCatalogSpec;
-import org.apache.camel.k.catalog.model.k8s.crd.RuntimeSpec;
-import org.apache.camel.k.tooling.maven.support.CatalogProcessor;
-import org.apache.maven.project.MavenProject;
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class CatalogProcessor3Test extends AbstractCatalogProcessorTest {
- @Test
- public void testAcceptHyphen() {
- CamelCatalog catalog = versionCamelCatalog("3.0.0.acme-123456");
-
- assertThat(new CatalogProcessor3x().accepts(catalog)).isTrue();
- }
-
- @Test
- public void testAcceptEqualToLower() {
- CamelCatalog catalog = versionCamelCatalog("3.0.0");
-
- assertThat(new CatalogProcessor3x().accepts(catalog)).isTrue();
- }
-
- @Test
- public void testAcceptLessThanLower() {
- CamelCatalog catalog = versionCamelCatalog("2.17.0");
-
- assertThat(new CatalogProcessor3x().accepts(catalog)).isFalse();
- }
-
- @Test
- public void testAcceptEqualToHigher() {
- CamelCatalog catalog = versionCamelCatalog("4.0.0");
-
- assertThat(new CatalogProcessor3x().accepts(catalog)).isFalse();
- }
-
- @Test
- public void testAcceptMoreThanHigher() {
- CamelCatalog catalog = versionCamelCatalog("5.0.0");
-
- assertThat(new CatalogProcessor3x().accepts(catalog)).isFalse();
- }
-
- @Test
- public void testArtifactsEnrichment() {
- CatalogProcessor processor = new CatalogProcessor3x();
- CamelCatalog catalog = versionCamelCatalog("3.0.0");
-
- RuntimeSpec runtime = new
RuntimeSpec.Builder().version("1.0.0").applicationClass("unknown").provider("quarkus").build();
- CamelCatalogSpec.Builder builder = new
CamelCatalogSpec.Builder().runtime(runtime);
-
- assertThat(processor.accepts(catalog)).isTrue();
- processor.process(new MavenProject(), catalog, builder,
Collections.emptyList());
-
- CamelCatalogSpec spec = builder.build();
- Map<String, CamelArtifact> artifactMap = spec.getArtifacts();
-
- assertThat(artifactMap).containsKey("camel-k-knative");
- assertThat(artifactMap.get("camel-http")).satisfies(a -> {
- assertThat(a.getDependencies()).anyMatch(
- d -> d.getGroupId().equals("org.apache.camel") &&
d.getArtifactId().equals("camel-file")
- );
- });
- }
-
- @Test
- public void testArtifactsDoNotContainVersion() {
- CatalogProcessor processor = new CatalogProcessor3x();
- CamelCatalog catalog = versionCamelCatalog("3.0.0");
-
- RuntimeSpec runtime = new
RuntimeSpec.Builder().version("1.0.0").applicationClass("unknown").provider("quarkus").build();
- CamelCatalogSpec.Builder builder = new
CamelCatalogSpec.Builder().runtime(runtime);
-
- assertThat(processor.accepts(catalog)).isTrue();
- processor.process(new MavenProject(), catalog, builder,
Collections.emptyList());
-
- CamelCatalogSpec spec = builder.build();
- Map<String, CamelArtifact> artifactMap = spec.getArtifacts();
-
- for (Map.Entry<String, CamelArtifact> artifact:
artifactMap.entrySet()) {
- assertThat(artifact.getValue().getVersion()).isNotPresent();
-
- for (Artifact dependency: artifact.getValue().getDependencies()) {
- assertThat(dependency.getVersion()).isNotPresent();
- }
- }
- }
-}