From 90a38e0e3fda798c25ab1f78a7580d418ab259ad Mon Sep 17 00:00:00 2001 From: lburgazzoli Date: Tue, 14 Jul 2020 19:19:13 +0200 Subject: [PATCH] Unable to run kotlin routes with quarkus #394 --- camel-k-loader-groovy/pom.xml | 4 - camel-k-loader-java/pom.xml | 4 - camel-k-loader-js/pom.xml | 4 - .../camel-k-loader-kotlin-itests/pom.xml | 78 +++++++ .../k/loader/kotlin/itests/LoaderTest.java | 48 ++++ .../src/test/resources/log4j2-test.xml | 0 .../src/test/resources/routes.kts | 0 .../camel-k-loader-kotlin/pom.xml | 215 ++++++++++++++++++ .../kotlin/KotlinCompilationConfiguration.kt | 0 .../k/loader/kotlin/KotlinSourceLoader.kt | 87 +++++++ .../k/loader/kotlin/dsl/BeansConfiguration.kt | 0 .../k/loader/kotlin/dsl/CamelConfiguration.kt | 0 .../kotlin/dsl/ComponentsConfiguration.kt | 0 .../kotlin/dsl/DataFormatsConfiguration.kt | 0 .../kotlin/dsl/IntegrationConfiguration.kt | 0 .../kotlin/dsl/LanguagesConfiguration.kt | 0 .../kotlin/dsl/RegistryConfiguration.kt | 0 .../k/loader/kotlin/dsl/RestConfiguration.kt | 0 .../kotlin/dsl/RestVerbConfiguration.kt | 0 .../camel/k/loader/kotlin/dsl/Support.kt | 0 .../extension/LogComponentExtensions.kt | 0 ...lin.dsl.IntegrationConfiguration.classname | 0 .../services/org/apache/camel/k/loader/kts | 0 .../camel/k/loader/kotlin/LoaderTest.kt | 0 .../k/loader/kotlin/dsl/IntegrationTest.kt | 0 .../kotlin/extension/LogExtensionTest.kt | 0 .../src/test/resources/log4j2-test.xml | 35 +++ .../src/test/resources/routes-new.kts | 0 .../src/test/resources/routes-with-beans.kts | 0 ...es-with-components-configuration-error.kts | 0 .../routes-with-components-configuration.kts | 0 .../routes-with-dataformats-configuration.kts | 0 .../resources/routes-with-endpoint-dsl.kts | 0 .../resources/routes-with-error-handler.kts | 0 .../routes-with-languages-configuration.kts | 0 .../src/test/resources/routes-with-rest.kts | 0 .../src/test/resources/routes.kts | 21 ++ camel-k-loader-kotlin/pom.xml | 191 +--------------- .../k/loader/kotlin/KotlinSourceLoader.kt | 104 --------- camel-k-main/camel-k-runtime-main/pom.xml | 5 - .../camel-k-quarkus-core/deployment/pom.xml | 4 + .../camel-k-quarkus-core/runtime/pom.xml | 5 + .../runtime/pom.xml | 4 - .../runtime/pom.xml | 4 - .../camel-k-quarkus-loader-js/runtime/pom.xml | 4 - .../deployment/pom.xml | 9 +- .../runtime/pom.xml | 9 +- camel-k-runtime-core/pom.xml | 4 + .../apache/camel/k/support/RouteBuilders.java | 39 ++++ .../data/application.properties | 34 +++ .../data/routes.kts | 20 ++ .../pom.xml | 118 ++++++++++ .../src/main/resources/application.properties | 20 ++ examples/pom.xml | 1 + 54 files changed, 747 insertions(+), 324 deletions(-) create mode 100644 camel-k-loader-kotlin/camel-k-loader-kotlin-itests/pom.xml create mode 100644 camel-k-loader-kotlin/camel-k-loader-kotlin-itests/src/test/java/org/apache/camel/k/loader/kotlin/itests/LoaderTest.java rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin-itests}/src/test/resources/log4j2-test.xml (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin-itests}/src/test/resources/routes.kts (100%) create mode 100644 camel-k-loader-kotlin/camel-k-loader-kotlin/pom.xml rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinCompilationConfiguration.kt (100%) create mode 100644 camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinSourceLoader.kt rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/BeansConfiguration.kt (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/CamelConfiguration.kt (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/ComponentsConfiguration.kt (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/DataFormatsConfiguration.kt (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationConfiguration.kt (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/LanguagesConfiguration.kt (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/RegistryConfiguration.kt (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/RestConfiguration.kt (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/RestVerbConfiguration.kt (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/Support.kt (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/main/kotlin/org/apache/camel/k/loader/kotlin/extension/LogComponentExtensions.kt (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/main/resources/META-INF/kotlin/script/templates/org.apache.camel.k.loader.kotlin.dsl.IntegrationConfiguration.classname (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/main/resources/META-INF/services/org/apache/camel/k/loader/kts (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/test/kotlin/org/apache/camel/k/loader/kotlin/LoaderTest.kt (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/test/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationTest.kt (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/test/kotlin/org/apache/camel/k/loader/kotlin/extension/LogExtensionTest.kt (100%) create mode 100644 camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/log4j2-test.xml rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/test/resources/routes-new.kts (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/test/resources/routes-with-beans.kts (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/test/resources/routes-with-components-configuration-error.kts (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/test/resources/routes-with-components-configuration.kts (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/test/resources/routes-with-dataformats-configuration.kts (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/test/resources/routes-with-endpoint-dsl.kts (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/test/resources/routes-with-error-handler.kts (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/test/resources/routes-with-languages-configuration.kts (100%) rename camel-k-loader-kotlin/{ => camel-k-loader-kotlin}/src/test/resources/routes-with-rest.kts (100%) create mode 100644 camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes.kts delete mode 100644 camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinSourceLoader.kt create mode 100644 camel-k-runtime-core/src/main/java/org/apache/camel/k/support/RouteBuilders.java create mode 100644 examples/camel-k-runtime-example-quarkus-kotlin/data/application.properties create mode 100644 examples/camel-k-runtime-example-quarkus-kotlin/data/routes.kts create mode 100644 examples/camel-k-runtime-example-quarkus-kotlin/pom.xml create mode 100644 examples/camel-k-runtime-example-quarkus-kotlin/src/main/resources/application.properties diff --git a/camel-k-loader-groovy/pom.xml b/camel-k-loader-groovy/pom.xml index e1a962818..6693fafac 100644 --- a/camel-k-loader-groovy/pom.xml +++ b/camel-k-loader-groovy/pom.xml @@ -40,10 +40,6 @@ org.apache.camel camel-log - - org.apache.camel - camel-endpointdsl - org.apache.camel camel-groovy diff --git a/camel-k-loader-java/pom.xml b/camel-k-loader-java/pom.xml index 884e59d5d..1e4dd6743 100644 --- a/camel-k-loader-java/pom.xml +++ b/camel-k-loader-java/pom.xml @@ -36,10 +36,6 @@ org.apache.camel camel-core-engine - - org.apache.camel - camel-endpointdsl - org.jooq joor diff --git a/camel-k-loader-js/pom.xml b/camel-k-loader-js/pom.xml index a0237465f..b55289643 100644 --- a/camel-k-loader-js/pom.xml +++ b/camel-k-loader-js/pom.xml @@ -36,10 +36,6 @@ org.apache.camel camel-core-engine - - org.apache.camel - camel-endpointdsl - org.graalvm.js diff --git a/camel-k-loader-kotlin/camel-k-loader-kotlin-itests/pom.xml b/camel-k-loader-kotlin/camel-k-loader-kotlin-itests/pom.xml new file mode 100644 index 000000000..43075f2a4 --- /dev/null +++ b/camel-k-loader-kotlin/camel-k-loader-kotlin-itests/pom.xml @@ -0,0 +1,78 @@ + + + + + org.apache.camel.k + camel-k-loader-kotlin-parent + 1.5.0-SNAPSHOT + + 4.0.0 + + camel-k-loader-kotlin-itests + + + + org.apache.camel.k + camel-k-loader-kotlin + + + + + + + + + + org.apache.camel.k + camel-k-test + test + + + + org.apache.camel + camel-timer + test + + + org.apache.camel + camel-log + test + + + org.apache.camel + camel-direct + test + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + 1 + false + + + + + + diff --git a/camel-k-loader-kotlin/camel-k-loader-kotlin-itests/src/test/java/org/apache/camel/k/loader/kotlin/itests/LoaderTest.java b/camel-k-loader-kotlin/camel-k-loader-kotlin-itests/src/test/java/org/apache/camel/k/loader/kotlin/itests/LoaderTest.java new file mode 100644 index 000000000..bc25de785 --- /dev/null +++ b/camel-k-loader-kotlin/camel-k-loader-kotlin-itests/src/test/java/org/apache/camel/k/loader/kotlin/itests/LoaderTest.java @@ -0,0 +1,48 @@ +/* + * 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.loader.kotlin.itests; + +import org.apache.camel.CamelContext; +import org.apache.camel.impl.DefaultCamelContext; +import org.apache.camel.k.Runtime; +import org.apache.camel.k.Source; +import org.apache.camel.k.Sources; +import org.apache.camel.k.listener.RoutesConfigurer; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class LoaderTest { + @Test + public void testLoad() throws Exception { + final CamelContext context = new DefaultCamelContext(); + final Runtime runtime = Runtime.on(context); + final Source source = Sources.fromURI("classpath:routes.kts"); + + RoutesConfigurer.load(runtime, source); + + try { + context.start(); + + assertThat(context.getComponentNames()).isNotEmpty(); + assertThat(context.getRoutes()).isNotEmpty(); + assertThat(context.getEndpoints()).isNotEmpty(); + } finally { + context.stop(); + } + } +} diff --git a/camel-k-loader-kotlin/src/test/resources/log4j2-test.xml b/camel-k-loader-kotlin/camel-k-loader-kotlin-itests/src/test/resources/log4j2-test.xml similarity index 100% rename from camel-k-loader-kotlin/src/test/resources/log4j2-test.xml rename to camel-k-loader-kotlin/camel-k-loader-kotlin-itests/src/test/resources/log4j2-test.xml diff --git a/camel-k-loader-kotlin/src/test/resources/routes.kts b/camel-k-loader-kotlin/camel-k-loader-kotlin-itests/src/test/resources/routes.kts similarity index 100% rename from camel-k-loader-kotlin/src/test/resources/routes.kts rename to camel-k-loader-kotlin/camel-k-loader-kotlin-itests/src/test/resources/routes.kts diff --git a/camel-k-loader-kotlin/camel-k-loader-kotlin/pom.xml b/camel-k-loader-kotlin/camel-k-loader-kotlin/pom.xml new file mode 100644 index 000000000..ade15abb1 --- /dev/null +++ b/camel-k-loader-kotlin/camel-k-loader-kotlin/pom.xml @@ -0,0 +1,215 @@ + + + + + org.apache.camel.k + camel-k-loader-kotlin-parent + 1.5.0-SNAPSHOT + + 4.0.0 + + camel-k-loader-kotlin + + + + org.apache.camel.k + camel-k-runtime-core + + + org.apache.camel + camel-core-engine + + + org.apache.camel + camel-log + true + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-script-util + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-scripting-jvm + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-scripting-jvm-host + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-scripting-compiler + ${kotlin.version} + + + + + + + + + + org.apache.camel.k + camel-k-test + test + + + + org.apache.camel + camel-timer + test + + + org.apache.camel + camel-seda + test + + + org.apache.camel + camel-rest + test + + + org.apache.camel + camel-direct + test + + + org.apache.camel + camel-main + test + + + org.apache.camel + camel-bean + test + + + org.apache.camel + camel-jackson + test + + + + org.apache.commons + commons-dbcp2 + ${commons-dbcp2.version} + test + + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + ${maven.compiler.target} + + + + compile + + compile + + + ${kotlin.compiler.target} + + src/main/kotlin + + + + + test-compile + + test-compile + + + ${kotlin.compiler.target} + + src/test/kotlin + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + default-compile + none + + + + default-testCompile + none + + + java-compile + compile + + compile + + + + java-test-compile + test-compile + + testCompile + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + 1 + false + + + + org.jboss.jandex + jandex-maven-plugin + + + make-index + + jandex + + + + + + + + diff --git a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinCompilationConfiguration.kt b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinCompilationConfiguration.kt similarity index 100% rename from camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinCompilationConfiguration.kt rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinCompilationConfiguration.kt diff --git a/camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinSourceLoader.kt b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinSourceLoader.kt new file mode 100644 index 000000000..98f334c13 --- /dev/null +++ b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinSourceLoader.kt @@ -0,0 +1,87 @@ +/** + * 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.loader.kotlin + +import org.apache.camel.Experimental +import org.apache.camel.RuntimeCamelException +import org.apache.camel.builder.endpoint.EndpointRouteBuilder +import org.apache.camel.k.Runtime +import org.apache.camel.k.Source +import org.apache.camel.k.SourceLoader +import org.apache.camel.k.loader.kotlin.dsl.IntegrationConfiguration +import org.apache.camel.k.support.RouteBuilders +import org.slf4j.LoggerFactory +import java.io.InputStream +import java.io.InputStreamReader +import kotlin.script.experimental.api.ResultValue +import kotlin.script.experimental.api.ScriptDiagnostic +import kotlin.script.experimental.api.ScriptEvaluationConfiguration +import kotlin.script.experimental.api.constructorArgs +import kotlin.script.experimental.api.valueOrNull +import kotlin.script.experimental.host.toScriptSource +import kotlin.script.experimental.jvmhost.BasicJvmScriptingHost +import kotlin.script.experimental.jvmhost.createJvmCompilationConfigurationFromTemplate + +@Experimental +class KotlinSourceLoader : SourceLoader { + override fun getSupportedLanguages(): List { + return listOf("kts") + } + + @Throws(Exception::class) + override fun load(runtime: Runtime, source: Source): SourceLoader.Result { + val builder = RouteBuilders.endpoint(source) { + inputStream, builder -> doLoad(inputStream, builder) + } + + return SourceLoader.Result.on(builder) + } + + private fun doLoad(inputStream: InputStream, builder: EndpointRouteBuilder) { + val host = BasicJvmScriptingHost() + val config = createJvmCompilationConfigurationFromTemplate() + + val result = host.eval( + InputStreamReader(inputStream).readText().toScriptSource(), + config, + ScriptEvaluationConfiguration { + // + // Arguments used to initialize the script base class (IntegrationConfiguration) + // + constructorArgs(builder) + } + ) + + // ensure evaluation errors propagation + when(val rv = result.valueOrNull()?.returnValue) { + is ResultValue.Error -> throw RuntimeCamelException(rv.error) + } + + if (result.reports.isNotEmpty()) { + val logger = LoggerFactory.getLogger(KotlinSourceLoader::class.java) + for (report in result.reports) { + when (report.severity) { + ScriptDiagnostic.Severity.FATAL -> logger.error(report.message, report.exception) + ScriptDiagnostic.Severity.ERROR -> logger.error(report.message, report.exception) + ScriptDiagnostic.Severity.WARNING -> logger.warn(report.message, report.exception) + ScriptDiagnostic.Severity.INFO -> logger.info(report.message) + ScriptDiagnostic.Severity.DEBUG -> logger.debug(report.message) + } + } + } + } +} diff --git a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/BeansConfiguration.kt b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/BeansConfiguration.kt similarity index 100% rename from camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/BeansConfiguration.kt rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/BeansConfiguration.kt diff --git a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/CamelConfiguration.kt b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/CamelConfiguration.kt similarity index 100% rename from camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/CamelConfiguration.kt rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/CamelConfiguration.kt diff --git a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/ComponentsConfiguration.kt b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/ComponentsConfiguration.kt similarity index 100% rename from camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/ComponentsConfiguration.kt rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/ComponentsConfiguration.kt diff --git a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/DataFormatsConfiguration.kt b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/DataFormatsConfiguration.kt similarity index 100% rename from camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/DataFormatsConfiguration.kt rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/DataFormatsConfiguration.kt diff --git a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationConfiguration.kt b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationConfiguration.kt similarity index 100% rename from camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationConfiguration.kt rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationConfiguration.kt diff --git a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/LanguagesConfiguration.kt b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/LanguagesConfiguration.kt similarity index 100% rename from camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/LanguagesConfiguration.kt rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/LanguagesConfiguration.kt diff --git a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/RegistryConfiguration.kt b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/RegistryConfiguration.kt similarity index 100% rename from camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/RegistryConfiguration.kt rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/RegistryConfiguration.kt diff --git a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/RestConfiguration.kt b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/RestConfiguration.kt similarity index 100% rename from camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/RestConfiguration.kt rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/RestConfiguration.kt diff --git a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/RestVerbConfiguration.kt b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/RestVerbConfiguration.kt similarity index 100% rename from camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/RestVerbConfiguration.kt rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/RestVerbConfiguration.kt diff --git a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/Support.kt b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/Support.kt similarity index 100% rename from camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/Support.kt rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/Support.kt diff --git a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/extension/LogComponentExtensions.kt b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/extension/LogComponentExtensions.kt similarity index 100% rename from camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/extension/LogComponentExtensions.kt rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/extension/LogComponentExtensions.kt diff --git a/camel-k-loader-kotlin/src/main/resources/META-INF/kotlin/script/templates/org.apache.camel.k.loader.kotlin.dsl.IntegrationConfiguration.classname b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/resources/META-INF/kotlin/script/templates/org.apache.camel.k.loader.kotlin.dsl.IntegrationConfiguration.classname similarity index 100% rename from camel-k-loader-kotlin/src/main/resources/META-INF/kotlin/script/templates/org.apache.camel.k.loader.kotlin.dsl.IntegrationConfiguration.classname rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/resources/META-INF/kotlin/script/templates/org.apache.camel.k.loader.kotlin.dsl.IntegrationConfiguration.classname diff --git a/camel-k-loader-kotlin/src/main/resources/META-INF/services/org/apache/camel/k/loader/kts b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/resources/META-INF/services/org/apache/camel/k/loader/kts similarity index 100% rename from camel-k-loader-kotlin/src/main/resources/META-INF/services/org/apache/camel/k/loader/kts rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/main/resources/META-INF/services/org/apache/camel/k/loader/kts diff --git a/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/LoaderTest.kt b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/LoaderTest.kt similarity index 100% rename from camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/LoaderTest.kt rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/LoaderTest.kt diff --git a/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationTest.kt b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationTest.kt similarity index 100% rename from camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationTest.kt rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationTest.kt diff --git a/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/extension/LogExtensionTest.kt b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/extension/LogExtensionTest.kt similarity index 100% rename from camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/extension/LogExtensionTest.kt rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/extension/LogExtensionTest.kt diff --git a/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/log4j2-test.xml b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/log4j2-test.xml new file mode 100644 index 000000000..aa3f7885b --- /dev/null +++ b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/log4j2-test.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/camel-k-loader-kotlin/src/test/resources/routes-new.kts b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-new.kts similarity index 100% rename from camel-k-loader-kotlin/src/test/resources/routes-new.kts rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-new.kts diff --git a/camel-k-loader-kotlin/src/test/resources/routes-with-beans.kts b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-with-beans.kts similarity index 100% rename from camel-k-loader-kotlin/src/test/resources/routes-with-beans.kts rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-with-beans.kts diff --git a/camel-k-loader-kotlin/src/test/resources/routes-with-components-configuration-error.kts b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-with-components-configuration-error.kts similarity index 100% rename from camel-k-loader-kotlin/src/test/resources/routes-with-components-configuration-error.kts rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-with-components-configuration-error.kts diff --git a/camel-k-loader-kotlin/src/test/resources/routes-with-components-configuration.kts b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-with-components-configuration.kts similarity index 100% rename from camel-k-loader-kotlin/src/test/resources/routes-with-components-configuration.kts rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-with-components-configuration.kts diff --git a/camel-k-loader-kotlin/src/test/resources/routes-with-dataformats-configuration.kts b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-with-dataformats-configuration.kts similarity index 100% rename from camel-k-loader-kotlin/src/test/resources/routes-with-dataformats-configuration.kts rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-with-dataformats-configuration.kts diff --git a/camel-k-loader-kotlin/src/test/resources/routes-with-endpoint-dsl.kts b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-with-endpoint-dsl.kts similarity index 100% rename from camel-k-loader-kotlin/src/test/resources/routes-with-endpoint-dsl.kts rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-with-endpoint-dsl.kts diff --git a/camel-k-loader-kotlin/src/test/resources/routes-with-error-handler.kts b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-with-error-handler.kts similarity index 100% rename from camel-k-loader-kotlin/src/test/resources/routes-with-error-handler.kts rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-with-error-handler.kts diff --git a/camel-k-loader-kotlin/src/test/resources/routes-with-languages-configuration.kts b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-with-languages-configuration.kts similarity index 100% rename from camel-k-loader-kotlin/src/test/resources/routes-with-languages-configuration.kts rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-with-languages-configuration.kts diff --git a/camel-k-loader-kotlin/src/test/resources/routes-with-rest.kts b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-with-rest.kts similarity index 100% rename from camel-k-loader-kotlin/src/test/resources/routes-with-rest.kts rename to camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes-with-rest.kts diff --git a/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes.kts b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes.kts new file mode 100644 index 000000000..7d28bb5b9 --- /dev/null +++ b/camel-k-loader-kotlin/camel-k-loader-kotlin/src/test/resources/routes.kts @@ -0,0 +1,21 @@ +/* + * 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. + */ +from("timer:tick") + .process().message { + m -> m.headers["MyHeader"] = "MyHeaderValue" + } + .to("log:info") \ No newline at end of file diff --git a/camel-k-loader-kotlin/pom.xml b/camel-k-loader-kotlin/pom.xml index ac889a3ab..5a6165e30 100644 --- a/camel-k-loader-kotlin/pom.xml +++ b/camel-k-loader-kotlin/pom.xml @@ -25,191 +25,12 @@ 4.0.0 - camel-k-loader-kotlin + pom + camel-k-loader-kotlin-parent - - - org.apache.camel.k - camel-k-runtime-core - - - org.apache.camel - camel-core-engine - - - org.apache.camel - camel-endpointdsl - - - org.apache.camel - camel-log - true - - - org.jetbrains.kotlin - kotlin-stdlib-jdk8 - ${kotlin.version} - - - org.jetbrains.kotlin - kotlin-script-util - ${kotlin.version} - - - org.jetbrains.kotlin - kotlin-scripting-jvm - ${kotlin.version} - - - org.jetbrains.kotlin - kotlin-scripting-jvm-host - ${kotlin.version} - - - org.jetbrains.kotlin - kotlin-scripting-compiler - ${kotlin.version} - - - - - - - - - - org.apache.camel.k - camel-k-test - test - - - - org.apache.camel - camel-timer - test - - - org.apache.camel - camel-seda - test - - - org.apache.camel - camel-rest - test - - - org.apache.camel - camel-direct - test - - - org.apache.camel - camel-main - test - - - org.apache.camel - camel-bean - test - - - org.apache.camel - camel-jackson - test - - - - org.apache.commons - commons-dbcp2 - ${commons-dbcp2.version} - test - - - - - - - org.jetbrains.kotlin - kotlin-maven-plugin - ${kotlin.version} - - ${maven.compiler.target} - - - - compile - - compile - - - ${kotlin.compiler.target} - - src/main/kotlin - - - - - test-compile - - test-compile - - - ${kotlin.compiler.target} - - src/test/kotlin - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - default-compile - none - - - - default-testCompile - none - - - java-compile - compile - compile - - - java-test-compile - test-compile - testCompile - - - - - org.apache.maven.plugins - maven-surefire-plugin - - 1 - false - - - - org.jboss.jandex - jandex-maven-plugin - - - make-index - - jandex - - - - - - + + camel-k-loader-kotlin + camel-k-loader-kotlin-itests + diff --git a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinSourceLoader.kt b/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinSourceLoader.kt deleted file mode 100644 index afe6d4250..000000000 --- a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinSourceLoader.kt +++ /dev/null @@ -1,104 +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.loader.kotlin - -import org.apache.camel.RuntimeCamelException -import org.apache.camel.builder.endpoint.EndpointRouteBuilder -import org.apache.camel.k.Runtime -import org.apache.camel.k.Source -import org.apache.camel.k.SourceLoader -import org.apache.camel.k.loader.kotlin.dsl.IntegrationConfiguration -import org.slf4j.Logger -import org.slf4j.LoggerFactory -import java.io.InputStream -import java.io.InputStreamReader -import kotlin.script.experimental.api.ResultValue -import kotlin.script.experimental.api.ScriptDiagnostic -import kotlin.script.experimental.api.ScriptEvaluationConfiguration -import kotlin.script.experimental.api.constructorArgs -import kotlin.script.experimental.api.valueOrNull -import kotlin.script.experimental.host.toScriptSource -import kotlin.script.experimental.jvm.BasicJvmScriptEvaluator -import kotlin.script.experimental.jvmhost.BasicJvmScriptingHost -import kotlin.script.experimental.jvmhost.JvmScriptCompiler -import kotlin.script.experimental.jvmhost.createJvmCompilationConfigurationFromTemplate - -class KotlinSourceLoader : SourceLoader { - companion object { - private val LOGGER : Logger = LoggerFactory.getLogger(KotlinSourceLoader::class.java) - - @JvmStatic - fun load(inputStream: InputStream): EndpointRouteBuilder { - return object : EndpointRouteBuilder() { - @Throws(Exception::class) - override fun configure() { - load(inputStream, this) - } - } - } - - @JvmStatic - fun load(inputStream: InputStream, builder: EndpointRouteBuilder) { - val compiler = JvmScriptCompiler() - val evaluator = BasicJvmScriptEvaluator() - val host = BasicJvmScriptingHost(compiler = compiler, evaluator = evaluator) - val config = createJvmCompilationConfigurationFromTemplate() - - val result = host.eval( - InputStreamReader(inputStream).readText().toScriptSource(), - config, - ScriptEvaluationConfiguration { - // - // Arguments used to initialize the script base class - // - constructorArgs(builder) - } - ) - - // ensure that evaluation errors propagation - when(val rv = result.valueOrNull()?.returnValue) { - is ResultValue.Error -> throw RuntimeCamelException(rv.error) - } - - for (report in result.reports) { - when (report.severity) { - ScriptDiagnostic.Severity.FATAL -> LOGGER.error("{}", report.message, report.exception) - ScriptDiagnostic.Severity.ERROR -> LOGGER.error("{}", report.message, report.exception) - ScriptDiagnostic.Severity.WARNING -> LOGGER.warn("{}", report.message, report.exception) - ScriptDiagnostic.Severity.INFO -> LOGGER.info("{}", report.message) - ScriptDiagnostic.Severity.DEBUG -> LOGGER.debug("{}", report.message) - } - } - } - } - - override fun getSupportedLanguages(): List { - return listOf("kts") - } - - @Throws(Exception::class) - override fun load(runtime: Runtime, source: Source): SourceLoader.Result { - return SourceLoader.Result.on(object : EndpointRouteBuilder() { - @Throws(Exception::class) - override fun configure() { - source.resolveAsInputStream(runtime.camelContext).use { - load(it, this) - } - } - }) - } -} diff --git a/camel-k-main/camel-k-runtime-main/pom.xml b/camel-k-main/camel-k-runtime-main/pom.xml index 7673ce52b..0c69aebb8 100644 --- a/camel-k-main/camel-k-runtime-main/pom.xml +++ b/camel-k-main/camel-k-runtime-main/pom.xml @@ -117,11 +117,6 @@ camel-direct test - - org.apache.camel - camel-endpointdsl - test - org.apache.camel.k diff --git a/camel-k-quarkus/camel-k-quarkus-core/deployment/pom.xml b/camel-k-quarkus/camel-k-quarkus-core/deployment/pom.xml index 2a824a7e8..e7f221bd7 100644 --- a/camel-k-quarkus/camel-k-quarkus-core/deployment/pom.xml +++ b/camel-k-quarkus/camel-k-quarkus-core/deployment/pom.xml @@ -36,6 +36,10 @@ org.apache.camel.quarkus camel-quarkus-core-deployment + + org.apache.camel.quarkus + camel-quarkus-endpointdsl-deployment + diff --git a/camel-k-quarkus/camel-k-quarkus-core/runtime/pom.xml b/camel-k-quarkus/camel-k-quarkus-core/runtime/pom.xml index fcfef660e..d6454740c 100644 --- a/camel-k-quarkus/camel-k-quarkus-core/runtime/pom.xml +++ b/camel-k-quarkus/camel-k-quarkus-core/runtime/pom.xml @@ -44,6 +44,11 @@ org.apache.camel.quarkus camel-quarkus-core + + org.apache.camel.quarkus + camel-quarkus-endpointdsl + + io.quarkus quarkus-development-mode-spi diff --git a/camel-k-quarkus/camel-k-quarkus-loader-groovy/runtime/pom.xml b/camel-k-quarkus/camel-k-quarkus-loader-groovy/runtime/pom.xml index 8629f017e..7a421e0e3 100644 --- a/camel-k-quarkus/camel-k-quarkus-loader-groovy/runtime/pom.xml +++ b/camel-k-quarkus/camel-k-quarkus-loader-groovy/runtime/pom.xml @@ -36,10 +36,6 @@ org.apache.camel.k camel-k-loader-groovy - - org.apache.camel - camel-endpointdsl - org.apache.camel camel-groovy diff --git a/camel-k-quarkus/camel-k-quarkus-loader-java/runtime/pom.xml b/camel-k-quarkus/camel-k-quarkus-loader-java/runtime/pom.xml index 45392494f..20abf987e 100644 --- a/camel-k-quarkus/camel-k-quarkus-loader-java/runtime/pom.xml +++ b/camel-k-quarkus/camel-k-quarkus-loader-java/runtime/pom.xml @@ -36,10 +36,6 @@ org.apache.camel.k camel-k-loader-java - - org.apache.camel - camel-endpointdsl - diff --git a/camel-k-quarkus/camel-k-quarkus-loader-js/runtime/pom.xml b/camel-k-quarkus/camel-k-quarkus-loader-js/runtime/pom.xml index fd231c2e5..6357ed19c 100644 --- a/camel-k-quarkus/camel-k-quarkus-loader-js/runtime/pom.xml +++ b/camel-k-quarkus/camel-k-quarkus-loader-js/runtime/pom.xml @@ -31,10 +31,6 @@ org.apache.camel.k camel-k-quarkus-core - - - org.apache.camel - camel-endpointdsl org.apache.camel.k diff --git a/camel-k-quarkus/camel-k-quarkus-loader-kotlin/deployment/pom.xml b/camel-k-quarkus/camel-k-quarkus-loader-kotlin/deployment/pom.xml index ca11a402a..a8d9233ed 100644 --- a/camel-k-quarkus/camel-k-quarkus-loader-kotlin/deployment/pom.xml +++ b/camel-k-quarkus/camel-k-quarkus-loader-kotlin/deployment/pom.xml @@ -30,11 +30,16 @@ org.apache.camel.k - camel-k-quarkus-loader-kotlin + camel-k-quarkus-core-deployment org.apache.camel.k - camel-k-quarkus-core-deployment + camel-k-quarkus-loader-kotlin + + + + org.apache.camel.quarkus + camel-quarkus-kotlin-deployment diff --git a/camel-k-quarkus/camel-k-quarkus-loader-kotlin/runtime/pom.xml b/camel-k-quarkus/camel-k-quarkus-loader-kotlin/runtime/pom.xml index 3b276fde3..3d1441442 100644 --- a/camel-k-quarkus/camel-k-quarkus-loader-kotlin/runtime/pom.xml +++ b/camel-k-quarkus/camel-k-quarkus-loader-kotlin/runtime/pom.xml @@ -30,15 +30,16 @@ org.apache.camel.k - camel-k-quarkus-core + camel-k-loader-kotlin + org.apache.camel.k - camel-k-loader-kotlin + camel-k-quarkus-core - org.apache.camel - camel-endpointdsl + org.apache.camel.quarkus + camel-quarkus-kotlin diff --git a/camel-k-runtime-core/pom.xml b/camel-k-runtime-core/pom.xml index 544846cc9..2fc614d10 100644 --- a/camel-k-runtime-core/pom.xml +++ b/camel-k-runtime-core/pom.xml @@ -43,6 +43,10 @@ org.apache.camel camel-core-languages + + org.apache.camel + camel-endpointdsl + diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/RouteBuilders.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/RouteBuilders.java new file mode 100644 index 000000000..261eb99db --- /dev/null +++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/RouteBuilders.java @@ -0,0 +1,39 @@ +/* + * 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.support; + +import java.io.InputStream; +import java.util.function.BiConsumer; + +import org.apache.camel.builder.endpoint.EndpointRouteBuilder; +import org.apache.camel.k.Source; + +public final class RouteBuilders { + private RouteBuilders() { + } + + public static EndpointRouteBuilder endpoint(Source source, BiConsumer consumer) { + return new EndpointRouteBuilder() { + @Override + public void configure() throws Exception { + try (InputStream is = source.resolveAsInputStream(getContext())) { + consumer.accept(is, this); + } + } + }; + }; +} diff --git a/examples/camel-k-runtime-example-quarkus-kotlin/data/application.properties b/examples/camel-k-runtime-example-quarkus-kotlin/data/application.properties new file mode 100644 index 000000000..b3c70070b --- /dev/null +++ b/examples/camel-k-runtime-example-quarkus-kotlin/data/application.properties @@ -0,0 +1,34 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# Quarkus +# +quarkus.banner.enabled = false + +# +# camel - main +# +camel.main.name = camel-q +camel.main.stream-caching-enabled = true +camel.main.stream-caching-spool-directory = ${java.io.tmpdir}/camel-q + +# +# Integration +# +message = test-xs + diff --git a/examples/camel-k-runtime-example-quarkus-kotlin/data/routes.kts b/examples/camel-k-runtime-example-quarkus-kotlin/data/routes.kts new file mode 100644 index 000000000..489ddfce5 --- /dev/null +++ b/examples/camel-k-runtime-example-quarkus-kotlin/data/routes.kts @@ -0,0 +1,20 @@ +/* + * 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. + */ + +from("timer:tick") + .routeId("kotlin") + .to("log:kotlin") diff --git a/examples/camel-k-runtime-example-quarkus-kotlin/pom.xml b/examples/camel-k-runtime-example-quarkus-kotlin/pom.xml new file mode 100644 index 000000000..c10b8a897 --- /dev/null +++ b/examples/camel-k-runtime-example-quarkus-kotlin/pom.xml @@ -0,0 +1,118 @@ + + + + + + org.apache.camel.k + camel-k-runtime-examples + 1.5.0-SNAPSHOT + + + 4.0.0 + camel-k-runtime-example-quarkus-kotlin + + + true + false + + + + + + org.apache.camel.quarkus + camel-quarkus-bom + ${camel-quarkus.version} + pom + import + + + + + + + org.apache.camel.k + camel-k-runtime-quarkus + + + org.apache.camel.k + camel-k-quarkus-loader-kotlin + + + + org.apache.camel.quarkus + camel-quarkus-log + + + org.apache.camel.quarkus + camel-quarkus-timer + + + + + + + io.quarkus + quarkus-bootstrap-maven-plugin + ${quarkus.version} + + + io.quarkus + quarkus-maven-plugin + ${quarkus.version} + + + build + + build + + + ${project.artifactId} + + + + + + org.codehaus.mojo + exec-maven-plugin + ${exec-maven-plugin.version} + + + + exec + + + + + java + ${project.basedir} + + -jar + ${project.build.directory}/${project.artifactId}-runner.jar + + + ${project.basedir}/data/application.properties + file:${project.basedir}/data/routes.kts + + + + + + + diff --git a/examples/camel-k-runtime-example-quarkus-kotlin/src/main/resources/application.properties b/examples/camel-k-runtime-example-quarkus-kotlin/src/main/resources/application.properties new file mode 100644 index 000000000..1ba4656ff --- /dev/null +++ b/examples/camel-k-runtime-example-quarkus-kotlin/src/main/resources/application.properties @@ -0,0 +1,20 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# empty file to avoid build warning +# \ No newline at end of file diff --git a/examples/pom.xml b/examples/pom.xml index c6f1848ac..6151d8797 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -41,6 +41,7 @@ camel-k-runtime-example-quarkus-js camel-k-runtime-example-quarkus-yaml camel-k-runtime-example-quarkus-knative + camel-k-runtime-example-quarkus-kotlin camel-k-runtime-example-quarkus-groovy camel-k-runtime-example-quarkus-java camel-k-runtime-example-quarkus-xml