You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2023/01/12 18:58:22 UTC
[camel-quarkus] branch 4392/kotlin-dsl-native created (now b5f015be79)
This is an automated email from the ASF dual-hosted git repository.
nfilotto pushed a change to branch 4392/kotlin-dsl-native
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
at b5f015be79 Ref #4392: Kotlin DSL native support
This branch includes the following new commits:
new b5f015be79 Ref #4392: Kotlin DSL native support
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[camel-quarkus] 01/01: Ref #4392: Kotlin DSL native support
Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
nfilotto pushed a commit to branch 4392/kotlin-dsl-native
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit b5f015be7951cc762d3e0299963cd2cdb9e69168
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Thu Jan 12 19:57:35 2023 +0100
Ref #4392: Kotlin DSL native support
---
docs/modules/ROOT/examples/others/kotlin-dsl.yml | 6 +-
.../pages/reference/extensions/kotlin-dsl.adoc | 14 +-
extensions-jvm/pom.xml | 1 -
.../kotlin-dsl/deployment/pom.xml | 0
.../dsl/kotlin/deployment/KotlinDslProcessor.java | 224 +++++++++++++++++++++
.../deployment/KotlinGeneratedClassBuildItem.java | 27 +--
{extensions-jvm => extensions}/kotlin-dsl/pom.xml | 2 +-
.../kotlin-dsl/runtime/pom.xml | 13 +-
.../quarkus/dsl/kotlin/runtime/Configurer.java | 17 +-
.../dsl/kotlin/runtime/KotlinDslRecorder.java | 50 +++++
.../graal/SubstituteKotlinRoutesBuilderLoader.java | 20 +-
.../main/resources/META-INF/quarkus-extension.yaml | 0
extensions/pom.xml | 1 +
.../camel/quarkus/dsl/kotlin/KotlinDslTest.java | 49 -----
integration-tests-jvm/pom.xml | 1 -
.../kotlin-dsl/pom.xml | 62 ++++++
.../quarkus/dsl/kotlin/KotlinDslResource.java | 58 ++++--
.../src/main/resources/application.properties | 3 +-
.../src/main/resources/routes/my-routes.kts | 4 +-
.../routes-with-components-configuration.kts | 30 ++-
.../routes-with-dataformats-configuration.kts | 22 +-
.../resources/routes/routes-with-endpoint-dsl.kts | 9 +-
.../resources/routes/routes-with-error-handler.kts | 13 +-
.../routes/routes-with-languages-configuration.kts | 20 +-
.../src/main/resources/routes/routes-with-rest.kts | 35 +++-
.../src/main/resources/routes/routes.kts | 9 +-
.../camel/quarkus/dsl/kotlin/KotlinDslIT.java | 11 +-
.../camel/quarkus/dsl/kotlin/KotlinDslTest.java | 59 ++++++
integration-tests/pom.xml | 1 +
tooling/scripts/test-categories.yaml | 1 +
30 files changed, 626 insertions(+), 136 deletions(-)
diff --git a/docs/modules/ROOT/examples/others/kotlin-dsl.yml b/docs/modules/ROOT/examples/others/kotlin-dsl.yml
index 0ceeb26750..032388d0ab 100644
--- a/docs/modules/ROOT/examples/others/kotlin-dsl.yml
+++ b/docs/modules/ROOT/examples/others/kotlin-dsl.yml
@@ -2,11 +2,11 @@
# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
cqArtifactId: camel-quarkus-kotlin-dsl
cqArtifactIdBase: kotlin-dsl
-cqNativeSupported: false
-cqStatus: Preview
+cqNativeSupported: true
+cqStatus: Stable
cqDeprecated: false
cqJvmSince: 1.8.0
-cqNativeSince: n/a
+cqNativeSince: 2.16.0
cqCamelPartName: kotlin-dsl
cqCamelPartTitle: Kotlin DSL
cqCamelPartDescription: Camel DSL with Kotlin
diff --git a/docs/modules/ROOT/pages/reference/extensions/kotlin-dsl.adoc b/docs/modules/ROOT/pages/reference/extensions/kotlin-dsl.adoc
index 37283c9d1d..4b940a1441 100644
--- a/docs/modules/ROOT/pages/reference/extensions/kotlin-dsl.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/kotlin-dsl.adoc
@@ -4,17 +4,17 @@
= Kotlin DSL
:linkattrs:
:cq-artifact-id: camel-quarkus-kotlin-dsl
-:cq-native-supported: false
-:cq-status: Preview
-:cq-status-deprecation: Preview
+:cq-native-supported: true
+:cq-status: Stable
+:cq-status-deprecation: Stable
:cq-description: Support for parsing Kotlin route definitions at runtime
:cq-deprecated: false
:cq-jvm-since: 1.8.0
-:cq-native-since: n/a
+:cq-native-since: 2.16.0
ifeval::[{doc-show-badges} == true]
[.badges]
-[.badge-key]##JVM since##[.badge-supported]##1.8.0## [.badge-key]##Native##[.badge-unsupported]##unsupported##
+[.badge-key]##JVM since##[.badge-supported]##1.8.0## [.badge-key]##Native since##[.badge-supported]##2.16.0##
endif::[]
Support for parsing Kotlin route definitions at runtime
@@ -29,6 +29,10 @@ Please refer to the above link for usage and configuration details.
[id="extensions-kotlin-dsl-maven-coordinates"]
== Maven coordinates
+https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-kotlin-dsl[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"]
+
+Or add the coordinates to your existing project:
+
[source,xml]
----
<dependency>
diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml
index 01ff26c757..edf23af344 100644
--- a/extensions-jvm/pom.xml
+++ b/extensions-jvm/pom.xml
@@ -87,7 +87,6 @@
<module>json-patch</module>
<module>jsonapi</module>
<module>jt400</module>
- <module>kotlin-dsl</module>
<module>ldap</module>
<module>ldif</module>
<module>lucene</module>
diff --git a/extensions-jvm/kotlin-dsl/deployment/pom.xml b/extensions/kotlin-dsl/deployment/pom.xml
similarity index 100%
rename from extensions-jvm/kotlin-dsl/deployment/pom.xml
rename to extensions/kotlin-dsl/deployment/pom.xml
diff --git a/extensions/kotlin-dsl/deployment/src/main/java/org/apache/camel/quarkus/dsl/kotlin/deployment/KotlinDslProcessor.java b/extensions/kotlin-dsl/deployment/src/main/java/org/apache/camel/quarkus/dsl/kotlin/deployment/KotlinDslProcessor.java
new file mode 100644
index 0000000000..1a89d690ba
--- /dev/null
+++ b/extensions/kotlin-dsl/deployment/src/main/java/org/apache/camel/quarkus/dsl/kotlin/deployment/KotlinDslProcessor.java
@@ -0,0 +1,224 @@
+/*
+ * 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.quarkus.dsl.kotlin.deployment;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.annotations.ExecutionTime;
+import io.quarkus.deployment.annotations.Record;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.GeneratedClassBuildItem;
+import io.quarkus.deployment.builditem.GeneratedResourceBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import io.quarkus.deployment.dev.CompilationProvider;
+import io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem;
+import io.quarkus.deployment.pkg.steps.NativeBuild;
+import io.quarkus.kotlin.deployment.KotlinCompilationProvider;
+import io.quarkus.maven.dependency.ResolvedDependency;
+import io.quarkus.paths.PathCollection;
+import io.quarkus.runtime.RuntimeValue;
+import org.apache.camel.CamelContext;
+import org.apache.camel.dsl.kotlin.KotlinConstantsKt;
+import org.apache.camel.quarkus.core.deployment.main.CamelMainHelper;
+import org.apache.camel.quarkus.core.deployment.spi.CamelContextBuildItem;
+import org.apache.camel.quarkus.dsl.kotlin.runtime.Configurer;
+import org.apache.camel.quarkus.dsl.kotlin.runtime.KotlinDslRecorder;
+import org.apache.camel.spi.Resource;
+import org.apache.camel.util.FileUtil;
+import org.apache.camel.util.IOHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+class KotlinDslProcessor {
+
+ private static final Logger LOG = LoggerFactory.getLogger(KotlinDslProcessor.class);
+ private static final String PACKAGE_NAME = "org.apache.camel.quarkus.dsl.kotlin.generated";
+ private static final Pattern IMPORT_PATTERN = Pattern.compile("import .*");
+ private static final String FILE_FORMAT = "package %s\n" +
+ "%s\n" +
+ "class %s(builder: org.apache.camel.builder.endpoint.EndpointRouteBuilder) :\n" +
+ " %s(builder) { \n" +
+ " override fun configure() { \n" +
+ " %s\n" +
+ " }\n" +
+ "}";
+ private static final String FEATURE = "camel-kotlin-dsl";
+ public static final String CLASS_EXT = ".class";
+
+ @BuildStep
+ FeatureBuildItem feature() {
+ return new FeatureBuildItem(FEATURE);
+ }
+
+ @BuildStep(onlyIf = NativeBuild.class)
+ void compileScriptsAOT(BuildProducer<GeneratedClassBuildItem> generatedClass,
+ BuildProducer<GeneratedResourceBuildItem> generatedResource,
+ BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
+ BuildProducer<KotlinGeneratedClassBuildItem> generatedKotlinClass,
+ CurateOutcomeBuildItem curateOutcomeBuildItem) throws Exception {
+ LOG.debug("Loading .kts resources");
+ final Path projectDir = Paths.get(".").toAbsolutePath().normalize();
+ final Path generatedSourceDir = projectDir.resolve("target/kotlin-dsl/generated-sources");
+ Files.createDirectories(generatedSourceDir);
+ final Path generatedSourceHomeDir = generatedSourceDir.resolve(PACKAGE_NAME.replace('.', File.separatorChar));
+ Files.createDirectories(generatedSourceHomeDir);
+ Map<String, Resource> nameToResource = new HashMap<>();
+ Set<File> filesToCompile = new HashSet<>();
+ CamelMainHelper.forEachMatchingResource(
+ resource -> {
+ if (!resource.getLocation().endsWith(".kts")) {
+ return;
+ }
+ String name = determineName(resource);
+ try (InputStream is = resource.getInputStream()) {
+ String content = toKotlinClass(name, IOHelper.loadText(is));
+ LOG.debug("Generated Kotlin source content:\n {}", content);
+ final Path sourceFile = generatedSourceHomeDir.resolve(String.format("%s.kt", name));
+ Files.write(sourceFile, content.getBytes(StandardCharsets.UTF_8));
+ filesToCompile.add(sourceFile.toFile());
+ nameToResource.put(String.format("%s.%s", PACKAGE_NAME, name), resource);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ });
+
+ if (filesToCompile.isEmpty()) {
+ return;
+ }
+ final Path classesDir = projectDir.resolve("target/kotlin-dsl/generated-classes");
+ Files.createDirectories(classesDir);
+ CompilationProvider.Context context = new CompilationProvider.Context(
+ FEATURE,
+ curateOutcomeBuildItem.getApplicationModel().getDependencies().stream()
+ .map(ResolvedDependency::getResolvedPaths)
+ .flatMap(PathCollection::stream)
+ .map(Path::toFile)
+ .filter(f -> f.getName().endsWith(".jar"))
+ .collect(Collectors.toSet()),
+ Set.of(),
+ projectDir.toFile(),
+ generatedSourceDir.toFile(),
+ classesDir.toFile(),
+ StandardCharsets.UTF_8.name(),
+ Map.of(),
+ KotlinConstantsKt.JVM_TARGET,
+ KotlinConstantsKt.JVM_TARGET,
+ KotlinConstantsKt.JVM_TARGET,
+ List.of(),
+ List.of());
+ try (KotlinCompilationProvider compiler = new KotlinCompilationProvider()) {
+ compiler.compile(filesToCompile, context);
+ }
+
+ try (Stream<Path> classFiles = Files.walk(classesDir)) {
+ classFiles
+ .filter(Files::isRegularFile)
+ .forEach(p -> {
+ String fileName = p.getFileName().toString();
+ String relativePath = classesDir.relativize(p).toString();
+ try {
+ if (fileName.endsWith(CLASS_EXT)) {
+ String className = relativePath.replace(File.separatorChar, '.').substring(0,
+ relativePath.length() - CLASS_EXT.length());
+ generatedClass.produce(new GeneratedClassBuildItem(true, className, Files.readAllBytes(p)));
+ if (nameToResource.containsKey(className)) {
+ reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, className));
+ generatedKotlinClass
+ .produce(new KotlinGeneratedClassBuildItem(className,
+ nameToResource.get(className).getLocation()));
+ }
+ } else {
+ generatedResource.produce(new GeneratedResourceBuildItem(
+ relativePath.replace(File.separatorChar, '/'),
+ Files.readAllBytes(p)));
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("Could not read " + p);
+ }
+ });
+ }
+ }
+
+ @BuildStep(onlyIf = NativeBuild.class)
+ @Record(value = ExecutionTime.STATIC_INIT)
+ void registerRoutesBuilder(List<KotlinGeneratedClassBuildItem> classes,
+ CamelContextBuildItem context,
+ KotlinDslRecorder recorder) throws Exception {
+ RuntimeValue<CamelContext> camelContext = context.getCamelContext();
+ for (KotlinGeneratedClassBuildItem clazz : classes) {
+ recorder.registerRoutesBuilder(camelContext, clazz.getName(), clazz.getLocation());
+ }
+ }
+
+ private static String determineName(Resource resource) {
+ String str = FileUtil.onlyName(resource.getLocation(), true);
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0, length = str.length(); i < length; i++) {
+ char c = str.charAt(i);
+ if ((i == 0 && Character.isJavaIdentifierStart(c)) || (i > 0 && Character.isJavaIdentifierPart(c))) {
+ sb.append(c);
+ } else {
+ sb.append((int) c);
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Convert a Kotlin script into a Kotlin class to be able to compile it.
+ *
+ * @param name the name of the Kotlin class
+ * @param contentResource the content of the Kotlin script
+ * @return the content of the corresponding Kotlin class.
+ */
+ private static String toKotlinClass(String name, String contentResource) {
+ List<String> imports = new ArrayList<>();
+ imports.add("import org.apache.camel.*");
+ imports.add("import org.apache.camel.spi.*");
+ Matcher m = IMPORT_PATTERN.matcher(contentResource);
+ int beginIndex = 0;
+ while (m.find()) {
+ imports.add(m.group());
+ beginIndex = m.end();
+ }
+ if (beginIndex > 0) {
+ contentResource = contentResource.substring(beginIndex);
+ }
+ return String.format(
+ FILE_FORMAT, PACKAGE_NAME, String.join("\n", imports), name,
+ Configurer.class.getName(), contentResource);
+ }
+}
diff --git a/extensions-jvm/kotlin-dsl/deployment/src/main/java/org/apache/camel/quarkus/dsl/kotlin/deployment/KotlinDslProcessor.java b/extensions/kotlin-dsl/deployment/src/main/java/org/apache/camel/quarkus/dsl/kotlin/deployment/KotlinGeneratedClassBuildItem.java
similarity index 59%
rename from extensions-jvm/kotlin-dsl/deployment/src/main/java/org/apache/camel/quarkus/dsl/kotlin/deployment/KotlinDslProcessor.java
rename to extensions/kotlin-dsl/deployment/src/main/java/org/apache/camel/quarkus/dsl/kotlin/deployment/KotlinGeneratedClassBuildItem.java
index 767e2645e1..a9240ba6ef 100644
--- a/extensions-jvm/kotlin-dsl/deployment/src/main/java/org/apache/camel/quarkus/dsl/kotlin/deployment/KotlinDslProcessor.java
+++ b/extensions/kotlin-dsl/deployment/src/main/java/org/apache/camel/quarkus/dsl/kotlin/deployment/KotlinGeneratedClassBuildItem.java
@@ -14,24 +14,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.camel.quarkus.dsl.kotlin.deployment;
-import io.quarkus.deployment.annotations.BuildStep;
-import io.quarkus.deployment.builditem.FeatureBuildItem;
-import io.quarkus.deployment.pkg.steps.NativeBuild;
+import io.quarkus.builder.item.MultiBuildItem;
+
+public final class KotlinGeneratedClassBuildItem extends MultiBuildItem {
-public class KotlinDslProcessor {
- private static final String FEATURE = "camel-kotlin-dsl";
+ final String name;
+ final String location;
+
+ public KotlinGeneratedClassBuildItem(String name, String location) {
+ this.name = name;
+ this.location = location;
+ }
- @BuildStep
- FeatureBuildItem feature() {
- return new FeatureBuildItem(FEATURE);
+ public String getName() {
+ return this.name;
}
- @BuildStep(onlyIf = NativeBuild.class)
- void nativeUnsupported() {
- throw new RuntimeException("The " + FEATURE + " extension is not supported in native mode "
- + "as loading Kotlin code at runtime is not supported on GraalVM");
+ public String getLocation() {
+ return location;
}
}
diff --git a/extensions-jvm/kotlin-dsl/pom.xml b/extensions/kotlin-dsl/pom.xml
similarity index 96%
rename from extensions-jvm/kotlin-dsl/pom.xml
rename to extensions/kotlin-dsl/pom.xml
index 6c82278189..a2cf2d4eba 100644
--- a/extensions-jvm/kotlin-dsl/pom.xml
+++ b/extensions/kotlin-dsl/pom.xml
@@ -21,7 +21,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-extensions-jvm</artifactId>
+ <artifactId>camel-quarkus-extensions</artifactId>
<version>2.16.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/extensions-jvm/kotlin-dsl/runtime/pom.xml b/extensions/kotlin-dsl/runtime/pom.xml
similarity index 89%
rename from extensions-jvm/kotlin-dsl/runtime/pom.xml
rename to extensions/kotlin-dsl/runtime/pom.xml
index ce43424feb..fa381be603 100644
--- a/extensions-jvm/kotlin-dsl/runtime/pom.xml
+++ b/extensions/kotlin-dsl/runtime/pom.xml
@@ -32,6 +32,7 @@
<properties>
<camel.quarkus.jvmSince>1.8.0</camel.quarkus.jvmSince>
+ <camel.quarkus.nativeSince>2.16.0</camel.quarkus.nativeSince>
</properties>
<dependencies>
@@ -47,18 +48,6 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-kotlin-dsl</artifactId>
</dependency>
- <dependency>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-script-util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-scripting-jvm</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-scripting-jvm-host</artifactId>
- </dependency>
</dependencies>
<build>
diff --git a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts b/extensions/kotlin-dsl/runtime/src/main/java/org/apache/camel/quarkus/dsl/kotlin/runtime/Configurer.java
similarity index 66%
copy from integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
copy to extensions/kotlin-dsl/runtime/src/main/java/org/apache/camel/quarkus/dsl/kotlin/runtime/Configurer.java
index 1175ccbd11..3e69e9f086 100644
--- a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
+++ b/extensions/kotlin-dsl/runtime/src/main/java/org/apache/camel/quarkus/dsl/kotlin/runtime/Configurer.java
@@ -14,6 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-from("direct:start")
- .id("my-kotlin-route")
- .log("Hello Kotlin !!!")
\ No newline at end of file
+package org.apache.camel.quarkus.dsl.kotlin.runtime;
+
+import org.apache.camel.builder.endpoint.EndpointRouteBuilder;
+import org.apache.camel.dsl.kotlin.KotlinDSL;
+import org.jetbrains.annotations.NotNull;
+
+public abstract class Configurer extends KotlinDSL {
+
+ protected Configurer(@NotNull EndpointRouteBuilder builder) {
+ super(builder);
+ }
+
+ public abstract void configure();
+}
diff --git a/extensions/kotlin-dsl/runtime/src/main/java/org/apache/camel/quarkus/dsl/kotlin/runtime/KotlinDslRecorder.java b/extensions/kotlin-dsl/runtime/src/main/java/org/apache/camel/quarkus/dsl/kotlin/runtime/KotlinDslRecorder.java
new file mode 100644
index 0000000000..7a1f3068ff
--- /dev/null
+++ b/extensions/kotlin-dsl/runtime/src/main/java/org/apache/camel/quarkus/dsl/kotlin/runtime/KotlinDslRecorder.java
@@ -0,0 +1,50 @@
+/*
+ * 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.quarkus.dsl.kotlin.runtime;
+
+import java.lang.reflect.Constructor;
+
+import io.quarkus.runtime.RuntimeValue;
+import io.quarkus.runtime.annotations.Recorder;
+import org.apache.camel.CamelContext;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.builder.endpoint.EndpointRouteBuilder;
+import org.apache.camel.support.ResourceHelper;
+
+@Recorder
+public class KotlinDslRecorder {
+
+ public void registerRoutesBuilder(RuntimeValue<CamelContext> camelContext, String className, String location)
+ throws Exception {
+ Constructor<? extends Configurer> constructor = (Constructor<? extends Configurer>) Class.forName(className)
+ .getDeclaredConstructor(EndpointRouteBuilder.class);
+ camelContext.getValue().addRoutes(
+ new EndpointRouteBuilder() {
+
+ @Override
+ public void configure() throws Exception {
+ setCamelContext(camelContext.getValue());
+ setResource(ResourceHelper.fromString(location, ""));
+ try {
+ constructor.newInstance(this).configure();
+ } catch (Exception e) {
+ throw new RuntimeCamelException("Cannot create instance of class: " + className, e);
+ }
+ }
+ });
+ }
+}
diff --git a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts b/extensions/kotlin-dsl/runtime/src/main/java/org/apache/camel/quarkus/dsl/kotlin/runtime/graal/SubstituteKotlinRoutesBuilderLoader.java
similarity index 59%
copy from integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
copy to extensions/kotlin-dsl/runtime/src/main/java/org/apache/camel/quarkus/dsl/kotlin/runtime/graal/SubstituteKotlinRoutesBuilderLoader.java
index 1175ccbd11..9b23e996a4 100644
--- a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
+++ b/extensions/kotlin-dsl/runtime/src/main/java/org/apache/camel/quarkus/dsl/kotlin/runtime/graal/SubstituteKotlinRoutesBuilderLoader.java
@@ -14,6 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-from("direct:start")
- .id("my-kotlin-route")
- .log("Hello Kotlin !!!")
\ No newline at end of file
+package org.apache.camel.quarkus.dsl.kotlin.runtime.graal;
+
+import java.io.Reader;
+
+import com.oracle.svm.core.annotate.Substitute;
+import com.oracle.svm.core.annotate.TargetClass;
+import org.apache.camel.builder.endpoint.EndpointRouteBuilder;
+import org.apache.camel.dsl.kotlin.KotlinRoutesBuilderLoader;
+
+@TargetClass(KotlinRoutesBuilderLoader.class)
+final class SubstituteKotlinRoutesBuilderLoader {
+
+ @Substitute
+ protected void doLoadEndpointRouteBuilder(Reader reader, EndpointRouteBuilder builder) {
+ // Do nothing
+ }
+}
diff --git a/extensions-jvm/kotlin-dsl/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/kotlin-dsl/runtime/src/main/resources/META-INF/quarkus-extension.yaml
similarity index 100%
rename from extensions-jvm/kotlin-dsl/runtime/src/main/resources/META-INF/quarkus-extension.yaml
rename to extensions/kotlin-dsl/runtime/src/main/resources/META-INF/quarkus-extension.yaml
diff --git a/extensions/pom.xml b/extensions/pom.xml
index f548467277..bf56945982 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -156,6 +156,7 @@
<module>knative-consumer</module>
<module>knative-producer</module>
<module>kotlin</module>
+ <module>kotlin-dsl</module>
<module>kubernetes</module>
<module>kudu</module>
<module>language</module>
diff --git a/integration-tests-jvm/kotlin-dsl/src/test/java/org/apache/camel/quarkus/dsl/kotlin/KotlinDslTest.java b/integration-tests-jvm/kotlin-dsl/src/test/java/org/apache/camel/quarkus/dsl/kotlin/KotlinDslTest.java
deleted file mode 100644
index cd0ee54595..0000000000
--- a/integration-tests-jvm/kotlin-dsl/src/test/java/org/apache/camel/quarkus/dsl/kotlin/KotlinDslTest.java
+++ /dev/null
@@ -1,49 +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.quarkus.dsl.kotlin;
-
-import javax.ws.rs.core.MediaType;
-
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import io.restassured.path.json.JsonPath;
-import org.apache.camel.dsl.kotlin.KotlinRoutesBuilderLoader;
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-@QuarkusTest
-public class KotlinDslTest {
- @Test
- public void testMainInstanceWithJavaRoutes() {
- JsonPath p = RestAssured.given()
- .accept(MediaType.APPLICATION_JSON)
- .get("/test/main/describe")
- .then()
- .statusCode(200)
- .extract()
- .body()
- .jsonPath();
-
- assertThat(p.getString("routes-builder-loader"))
- .isEqualTo(KotlinRoutesBuilderLoader.class.getName());
- assertThat(p.getList("routeBuilders", String.class))
- .isEmpty();
- assertThat(p.getList("routes", String.class))
- .contains("my-kotlin-route");
- }
-}
diff --git a/integration-tests-jvm/pom.xml b/integration-tests-jvm/pom.xml
index b6fdee38d3..dd3059be92 100644
--- a/integration-tests-jvm/pom.xml
+++ b/integration-tests-jvm/pom.xml
@@ -86,7 +86,6 @@
<module>json-patch</module>
<module>jsonapi</module>
<module>jt400</module>
- <module>kotlin-dsl</module>
<module>ldap</module>
<module>ldif</module>
<module>lucene</module>
diff --git a/integration-tests-jvm/kotlin-dsl/pom.xml b/integration-tests/kotlin-dsl/pom.xml
similarity index 63%
rename from integration-tests-jvm/kotlin-dsl/pom.xml
rename to integration-tests/kotlin-dsl/pom.xml
index 6b7aade39f..44a9e6918d 100644
--- a/integration-tests-jvm/kotlin-dsl/pom.xml
+++ b/integration-tests/kotlin-dsl/pom.xml
@@ -39,6 +39,30 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-direct</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-seda</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-jackson</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bean</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-timer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-log</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-rest</artifactId>
+ </dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
@@ -100,6 +124,44 @@
</dependency>
</dependencies>
</profile>
+ <profile>
+ <id>native</id>
+ <activation>
+ <property>
+ <name>native</name>
+ </property>
+ </activation>
+ <properties>
+ <quarkus.package.type>native</quarkus.package.type>
+ </properties>
+ <build>
+ <plugins>
+ <!-- remove me -->
+ <plugin>
+ <groupId>org.codehaus.gmaven</groupId>
+ <artifactId>groovy-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>sanity-checks</id>
+ <phase /><!-- Speedup the check-format profile by skipping the sanity-checks -->
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
</project>
diff --git a/integration-tests-jvm/kotlin-dsl/src/main/java/org/apache/camel/quarkus/dsl/kotlin/KotlinDslResource.java b/integration-tests/kotlin-dsl/src/main/java/org/apache/camel/quarkus/dsl/kotlin/KotlinDslResource.java
similarity index 51%
rename from integration-tests-jvm/kotlin-dsl/src/main/java/org/apache/camel/quarkus/dsl/kotlin/KotlinDslResource.java
rename to integration-tests/kotlin-dsl/src/main/java/org/apache/camel/quarkus/dsl/kotlin/KotlinDslResource.java
index 7170ca12ee..99d8a102f7 100644
--- a/integration-tests-jvm/kotlin-dsl/src/main/java/org/apache/camel/quarkus/dsl/kotlin/KotlinDslResource.java
+++ b/integration-tests/kotlin-dsl/src/main/java/org/apache/camel/quarkus/dsl/kotlin/KotlinDslResource.java
@@ -16,45 +16,67 @@
*/
package org.apache.camel.quarkus.dsl.kotlin;
+import java.util.stream.Collectors;
+
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
-import javax.json.Json;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonObject;
+import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
+import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.apache.camel.ExtendedCamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.Route;
import org.apache.camel.dsl.kotlin.KotlinConstantsKt;
import org.apache.camel.quarkus.main.CamelMain;
import org.apache.camel.spi.RoutesBuilderLoader;
-@Path("/test")
+@Path("/kotlin-dsl")
@ApplicationScoped
public class KotlinDslResource {
@Inject
CamelMain main;
- @Path("/main/describe")
+ @Inject
+ ProducerTemplate producerTemplate;
+
+ @Path("/main/kotlinRoutesBuilderLoader")
@GET
- @Produces(MediaType.APPLICATION_JSON)
- public JsonObject describeMain() {
+ @Produces(MediaType.TEXT_PLAIN)
+ public String kotlinRoutesBuilder() {
final ExtendedCamelContext camelContext = main.getCamelContext().adapt(ExtendedCamelContext.class);
+ return camelContext.getBootstrapFactoryFinder(RoutesBuilderLoader.FACTORY_PATH)
+ .findClass(KotlinConstantsKt.EXTENSION).get().getName();
+ }
- JsonArrayBuilder routeBuilders = Json.createArrayBuilder();
- main.configure().getRoutesBuilders().forEach(builder -> routeBuilders.add(builder.getClass().getName()));
+ @Path("/main/routeBuilders")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String routeBuilders() {
+ return main.configure().getRoutesBuilders().stream()
+ .map(rb -> rb.getClass().getSimpleName())
+ .sorted()
+ .collect(Collectors.joining(","));
+ }
- JsonArrayBuilder routes = Json.createArrayBuilder();
- main.getCamelContext().getRoutes().forEach(route -> routes.add(route.getId()));
+ @Path("/main/routes")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String routes() {
+ return main.getCamelContext().getRoutes().stream()
+ .map(Route::getId)
+ .sorted()
+ .collect(Collectors.joining(","));
+ }
- return Json.createObjectBuilder()
- .add("routes-builder-loader",
- camelContext.getBootstrapFactoryFinder(RoutesBuilderLoader.FACTORY_PATH)
- .findClass(KotlinConstantsKt.EXTENSION).get().getName())
- .add("routeBuilders", routeBuilders)
- .add("routes", routes)
- .build();
+ @POST
+ @Path("/hello")
+ @Consumes(MediaType.TEXT_PLAIN)
+ @Produces(MediaType.TEXT_PLAIN)
+ public String hello(String message) {
+ return producerTemplate.requestBody("direct:kotlinHello", message, String.class);
}
}
diff --git a/integration-tests-jvm/kotlin-dsl/src/main/resources/application.properties b/integration-tests/kotlin-dsl/src/main/resources/application.properties
similarity index 93%
rename from integration-tests-jvm/kotlin-dsl/src/main/resources/application.properties
rename to integration-tests/kotlin-dsl/src/main/resources/application.properties
index 3107c5ab50..3f43a52589 100644
--- a/integration-tests-jvm/kotlin-dsl/src/main/resources/application.properties
+++ b/integration-tests/kotlin-dsl/src/main/resources/application.properties
@@ -18,4 +18,5 @@
#
# Main
#
-camel.main.routes-include-pattern = classpath:routes/my-routes.kts
+camel.main.routes-include-pattern = classpath:routes/*.kts
+
diff --git a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts b/integration-tests/kotlin-dsl/src/main/resources/routes/my-routes.kts
similarity index 91%
copy from integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
copy to integration-tests/kotlin-dsl/src/main/resources/routes/my-routes.kts
index 1175ccbd11..4387318c49 100644
--- a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
+++ b/integration-tests/kotlin-dsl/src/main/resources/routes/my-routes.kts
@@ -14,6 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-from("direct:start")
+from("direct:kotlinHello")
.id("my-kotlin-route")
- .log("Hello Kotlin !!!")
\ No newline at end of file
+ .setBody().simple("Hello \${body} from Kotlin!")
diff --git a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts b/integration-tests/kotlin-dsl/src/main/resources/routes/routes-with-components-configuration.kts
similarity index 55%
copy from integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
copy to integration-tests/kotlin-dsl/src/main/resources/routes/routes-with-components-configuration.kts
index 1175ccbd11..3ea933ce55 100644
--- a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
+++ b/integration-tests/kotlin-dsl/src/main/resources/routes/routes-with-components-configuration.kts
@@ -14,6 +14,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-from("direct:start")
- .id("my-kotlin-route")
- .log("Hello Kotlin !!!")
\ No newline at end of file
+import org.apache.camel.Exchange
+import org.apache.camel.component.log.LogComponent
+import org.apache.camel.component.seda.SedaComponent
+
+camel {
+ components {
+ component<LogComponent>("log") {
+ setExchangeFormatter {
+ e: Exchange -> "" + e.getIn().body
+ }
+ }
+
+ component<SedaComponent>("seda") {
+ queueSize = 1234
+ concurrentConsumers = 12
+ }
+
+ component<SedaComponent>("mySeda") {
+ queueSize = 4321
+ concurrentConsumers = 21
+ }
+ }
+}
+
+from("timer:tick")
+ .id("routes-with-components-configuration")
+ .to("log:info")
\ No newline at end of file
diff --git a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts b/integration-tests/kotlin-dsl/src/main/resources/routes/routes-with-dataformats-configuration.kts
similarity index 63%
copy from integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
copy to integration-tests/kotlin-dsl/src/main/resources/routes/routes-with-dataformats-configuration.kts
index 1175ccbd11..daf0daaf9c 100644
--- a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
+++ b/integration-tests/kotlin-dsl/src/main/resources/routes/routes-with-dataformats-configuration.kts
@@ -14,6 +14,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-from("direct:start")
- .id("my-kotlin-route")
- .log("Hello Kotlin !!!")
\ No newline at end of file
+import org.apache.camel.component.jackson.JacksonDataFormat
+
+camel {
+ dataFormats {
+ dataFormat<JacksonDataFormat>("jackson") {
+ unmarshalType = Map::class.java
+ isPrettyPrint = true
+ }
+
+ dataFormat<JacksonDataFormat>("my-jackson") {
+ unmarshalType = String::class.java
+ isPrettyPrint = false
+ }
+ }
+}
+
+from("timer:tick")
+ .id("routes-with-dataformats-configuration")
+ .to("log:info")
\ No newline at end of file
diff --git a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts b/integration-tests/kotlin-dsl/src/main/resources/routes/routes-with-endpoint-dsl.kts
similarity index 87%
copy from integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
copy to integration-tests/kotlin-dsl/src/main/resources/routes/routes-with-endpoint-dsl.kts
index 1175ccbd11..cb6028cff0 100644
--- a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
+++ b/integration-tests/kotlin-dsl/src/main/resources/routes/routes-with-endpoint-dsl.kts
@@ -14,6 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-from("direct:start")
- .id("my-kotlin-route")
- .log("Hello Kotlin !!!")
\ No newline at end of file
+var f = timer("tick").period("1s")
+var t = log("info")
+
+from(f)
+ .id("routes-with-endpoint-dsl")
+ .to(t)
\ No newline at end of file
diff --git a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts b/integration-tests/kotlin-dsl/src/main/resources/routes/routes-with-error-handler.kts
similarity index 75%
copy from integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
copy to integration-tests/kotlin-dsl/src/main/resources/routes/routes-with-error-handler.kts
index 1175ccbd11..0a995a24b9 100644
--- a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
+++ b/integration-tests/kotlin-dsl/src/main/resources/routes/routes-with-error-handler.kts
@@ -14,6 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-from("direct:start")
- .id("my-kotlin-route")
- .log("Hello Kotlin !!!")
\ No newline at end of file
+onException(IllegalArgumentException::class.java)
+ .id("my-on-exception")
+ .to("log:exception")
+
+from("timer:tick")
+ .id("routes-with-error-handler")
+ .process().message {
+ m -> m.headers["MyHeader"] = "MyHeaderValue"
+ }
+ .to("log:info")
\ No newline at end of file
diff --git a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts b/integration-tests/kotlin-dsl/src/main/resources/routes/routes-with-languages-configuration.kts
similarity index 65%
copy from integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
copy to integration-tests/kotlin-dsl/src/main/resources/routes/routes-with-languages-configuration.kts
index 1175ccbd11..3290373f92 100644
--- a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
+++ b/integration-tests/kotlin-dsl/src/main/resources/routes/routes-with-languages-configuration.kts
@@ -14,6 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-from("direct:start")
- .id("my-kotlin-route")
- .log("Hello Kotlin !!!")
\ No newline at end of file
+import org.apache.camel.language.bean.BeanLanguage
+
+camel {
+ languages {
+ language<BeanLanguage>("bean") {
+ beanType = String::class.java
+ method = "toUpperCase"
+ }
+ language<BeanLanguage>("my-bean") {
+ beanType = String::class.java
+ method = "toLowerCase"
+ }
+ }
+}
+from("timer:tick")
+ .id("routes-with-languages-configuration")
+ .to("log:info")
\ No newline at end of file
diff --git a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts b/integration-tests/kotlin-dsl/src/main/resources/routes/routes-with-rest.kts
similarity index 56%
copy from integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
copy to integration-tests/kotlin-dsl/src/main/resources/routes/routes-with-rest.kts
index 1175ccbd11..f041ac1bd5 100644
--- a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
+++ b/integration-tests/kotlin-dsl/src/main/resources/routes/routes-with-rest.kts
@@ -14,6 +14,35 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-from("direct:start")
- .id("my-kotlin-route")
- .log("Hello Kotlin !!!")
\ No newline at end of file
+rest {
+ configuration {
+ host = "my-host"
+ port = "9192"
+ }
+
+ path("/my/path") {
+ get("/get") {
+ id("routes-with-rest-get")
+ consumes("application/json")
+ produces("application/json")
+ to("direct:get")
+ }
+ }
+
+ post {
+ id("routes-with-rest-post")
+ path("/post")
+ consumes("application/json")
+ produces("application/json")
+ to("direct:post")
+ }
+}
+
+
+
+from("timer:tick")
+ .id("routes-with-rest")
+ .process().message {
+ m -> m.headers["MyHeader"] = "MyHeaderValue"
+ }
+ .to("log:info")
diff --git a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts b/integration-tests/kotlin-dsl/src/main/resources/routes/routes.kts
similarity index 85%
copy from integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
copy to integration-tests/kotlin-dsl/src/main/resources/routes/routes.kts
index 1175ccbd11..a57b5d21cf 100644
--- a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
+++ b/integration-tests/kotlin-dsl/src/main/resources/routes/routes.kts
@@ -14,6 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-from("direct:start")
- .id("my-kotlin-route")
- .log("Hello Kotlin !!!")
\ No newline at end of file
+from("timer:tick")
+ .id("routes")
+ .process().message {
+ m -> m.headers["MyHeader"] = "MyHeaderValue"
+ }
+ .to("log:info")
\ No newline at end of file
diff --git a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts b/integration-tests/kotlin-dsl/src/test/java/org/apache/camel/quarkus/dsl/kotlin/KotlinDslIT.java
similarity index 82%
rename from integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
rename to integration-tests/kotlin-dsl/src/test/java/org/apache/camel/quarkus/dsl/kotlin/KotlinDslIT.java
index 1175ccbd11..7d41693a7c 100644
--- a/integration-tests-jvm/kotlin-dsl/src/main/resources/routes/my-routes.kts
+++ b/integration-tests/kotlin-dsl/src/test/java/org/apache/camel/quarkus/dsl/kotlin/KotlinDslIT.java
@@ -14,6 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-from("direct:start")
- .id("my-kotlin-route")
- .log("Hello Kotlin !!!")
\ No newline at end of file
+package org.apache.camel.quarkus.dsl.kotlin;
+
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+
+@QuarkusIntegrationTest
+class KotlinDslIT extends KotlinDslTest {
+
+}
diff --git a/integration-tests/kotlin-dsl/src/test/java/org/apache/camel/quarkus/dsl/kotlin/KotlinDslTest.java b/integration-tests/kotlin-dsl/src/test/java/org/apache/camel/quarkus/dsl/kotlin/KotlinDslTest.java
new file mode 100644
index 0000000000..79e585fc1c
--- /dev/null
+++ b/integration-tests/kotlin-dsl/src/test/java/org/apache/camel/quarkus/dsl/kotlin/KotlinDslTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.quarkus.dsl.kotlin;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import org.apache.camel.dsl.kotlin.KotlinRoutesBuilderLoader;
+import org.hamcrest.CoreMatchers;
+import org.junit.jupiter.api.Test;
+
+@QuarkusTest
+class KotlinDslTest {
+
+ @Test
+ void kotlinHello() {
+ RestAssured.given()
+ .body("Will Smith")
+ .post("/kotlin-dsl/hello")
+ .then()
+ .statusCode(200)
+ .body(CoreMatchers.is("Hello Will Smith from Kotlin!"));
+ }
+
+ @Test
+ void testMainInstanceWithJavaRoutes() {
+ RestAssured.given()
+ .get("/kotlin-dsl/main/kotlinRoutesBuilderLoader")
+ .then()
+ .statusCode(200)
+ .body(CoreMatchers.is(KotlinRoutesBuilderLoader.class.getName()));
+
+ RestAssured.given()
+ .get("/kotlin-dsl/main/routeBuilders")
+ .then()
+ .statusCode(200)
+ .body(CoreMatchers.is(""));
+
+ RestAssured.given()
+ .get("/kotlin-dsl/main/routes")
+ .then()
+ .statusCode(200)
+ .body(CoreMatchers.is(
+ "my-kotlin-route,routes,routes-with-components-configuration,routes-with-dataformats-configuration,routes-with-endpoint-dsl,routes-with-error-handler,routes-with-languages-configuration,routes-with-rest,routes-with-rest-get,routes-with-rest-post"));
+ }
+}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index 061f0adea1..043063a5b4 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -144,6 +144,7 @@
<module>knative-event-consumer</module>
<module>knative-producer</module>
<module>kotlin</module>
+ <module>kotlin-dsl</module>
<module>kubernetes</module>
<module>kudu</module>
<module>leveldb</module>
diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml
index c0c776976d..023abb356b 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -208,6 +208,7 @@ group-13:
- jira
- java-joor-dsl
- js-dsl
+ - kotlin-dsl
- kubernetes
- salesforce
- sap-netweaver