diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-kotlin/pom.xml b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-kotlin/pom.xml new file mode 100644 index 000000000..c3736b1d7 --- /dev/null +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-kotlin/pom.xml @@ -0,0 +1,113 @@ + + + + + org.apache.camel.k + camel-k-quarkus-itests + 1.5.1-SNAPSHOT + + 4.0.0 + + camel-k-quarkus-itests-loader-kotlin + + + + org.apache.camel.k + camel-k-quarkus-loader-kotlin + + + org.apache.camel.quarkus + camel-quarkus-direct + + + org.apache.camel.quarkus + camel-quarkus-log + + + org.apache.camel.k + camel-k-quarkus-itests-loader-support + + + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + org.assertj + assertj-core + test + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + ${build-helper-maven-plugin.version} + + + reserve-network-port + + reserve-network-port + + process-resources + + + test.http.port.jvm + test.http.port.native + + + + + + + io.quarkus + quarkus-maven-plugin + ${quarkus.version} + + + + build + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${test.http.port.jvm} + org.jboss.logmanager.LogManager + + + + + + + diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-kotlin/src/main/java/org/apache/camel/k/loader/kotlin/quarkus/Application.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-kotlin/src/main/java/org/apache/camel/k/loader/kotlin/quarkus/Application.java new file mode 100644 index 000000000..a8aa15f9d --- /dev/null +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-kotlin/src/main/java/org/apache/camel/k/loader/kotlin/quarkus/Application.java @@ -0,0 +1,45 @@ +/* + * 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.quarkus; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.json.JsonObject; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.apache.camel.CamelContext; +import org.apache.camel.Consume; +import org.apache.camel.k.loader.support.LoaderSupport; + +@Path("/test") +@ApplicationScoped +public class Application { + @Inject + CamelContext context; + + @POST + @Path("/load-routes/{name}") + @Consume(MediaType.TEXT_PLAIN) + @Produces(MediaType.APPLICATION_JSON) + public JsonObject loadRoutes(@PathParam("name") String name, String code) throws Exception { + return LoaderSupport.inspectSource(context, name, "kts", code); + } +} diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-kotlin/src/main/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-kotlin/src/main/resources/application.properties new file mode 100644 index 000000000..67b30b144 --- /dev/null +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-kotlin/src/main/resources/application.properties @@ -0,0 +1,27 @@ +## --------------------------------------------------------------------------- +## 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.log.console.enable = true +quarkus.banner.enabled = false + +# +# Quarkus :: Camel +# +quarkus.camel.routes-discovery.enabled = false diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-kotlin/src/test/java/org/apache/camel/k/loader/kotlin/quarkus/KotlinLoaderTest.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-kotlin/src/test/java/org/apache/camel/k/loader/kotlin/quarkus/KotlinLoaderTest.java new file mode 100644 index 000000000..8ce44c4a2 --- /dev/null +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-kotlin/src/test/java/org/apache/camel/k/loader/kotlin/quarkus/KotlinLoaderTest.java @@ -0,0 +1,61 @@ +/* + * 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.quarkus; + +import java.io.IOException; +import java.io.InputStream; + +import javax.ws.rs.core.MediaType; + +import io.quarkus.test.junit.DisabledOnNativeImage; +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.path.json.JsonPath; +import org.apache.camel.util.IOHelper; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +@Disabled("https://github.com/quarkusio/quarkus/issues/11549") +@DisabledOnNativeImage +@QuarkusTest +public class KotlinLoaderTest { + @Test + public void testLoadRoutes() throws IOException { + String code; + + try (InputStream is = KotlinLoaderTest.class.getResourceAsStream("/routes.kts")) { + code = IOHelper.loadText(is); + } + + JsonPath p = RestAssured.given() + .contentType(MediaType.TEXT_PLAIN) + .accept(MediaType.APPLICATION_JSON) + .body(code) + .post("/test/load-routes/MyRoute") + .then() + .statusCode(200) + .extract() + .body() + .jsonPath(); + + assertThat(p.getList("components", String.class)).contains("direct", "log"); + assertThat(p.getList("routes", String.class)).contains("kotlin"); + assertThat(p.getList("endpoints", String.class)).contains("direct://kotlin", "log://kotlin"); + } +} diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-kotlin/src/test/resources/routes.kts b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-kotlin/src/test/resources/routes.kts new file mode 100644 index 000000000..fba70eee0 --- /dev/null +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-kotlin/src/test/resources/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("direct:kotlin") + .routeId("kotlin") + .to("log:kotlin") \ No newline at end of file diff --git a/camel-k-quarkus/camel-k-quarkus-itests/pom.xml b/camel-k-quarkus/camel-k-quarkus-itests/pom.xml index c886cd097..2ca69ea72 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/pom.xml +++ b/camel-k-quarkus/camel-k-quarkus-itests/pom.xml @@ -34,6 +34,7 @@ camel-k-quarkus-itests-knative camel-k-quarkus-itests-loader-support camel-k-quarkus-itests-loader-groovy + camel-k-quarkus-itests-loader-kotlin camel-k-quarkus-itests-loader-java camel-k-quarkus-itests-loader-js camel-k-quarkus-itests-loader-xml 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 72bde54ad..6a0940fdf 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 @@ -36,11 +36,6 @@ org.apache.camel.k camel-k-quarkus-loader-kotlin - - - org.apache.camel.quarkus - camel-quarkus-kotlin-deployment - diff --git a/camel-k-quarkus/camel-k-quarkus-loader-kotlin/pom.xml b/camel-k-quarkus/camel-k-quarkus-loader-kotlin/pom.xml index fe98331ad..567a829d0 100644 --- a/camel-k-quarkus/camel-k-quarkus-loader-kotlin/pom.xml +++ b/camel-k-quarkus/camel-k-quarkus-loader-kotlin/pom.xml @@ -28,6 +28,18 @@ camel-k-quarkus-loader-kotlin-parent + + + + org.jetbrains.kotlin + kotlin-bom + ${kotlin.version} + pom + import + + + + runtime 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 c80083aa8..c604cffdf 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 @@ -27,32 +27,15 @@ camel-k-quarkus-loader-kotlin - - - - org.jetbrains.kotlin - kotlin-bom - ${kotlin.version} - pom - import - - - - org.apache.camel.k camel-k-loader-kotlin - org.apache.camel.k camel-k-quarkus-core - - org.apache.camel.quarkus - camel-quarkus-kotlin - diff --git a/camel-k-quarkus/pom.xml b/camel-k-quarkus/pom.xml index 6c998ebad..33dfe27a1 100644 --- a/camel-k-quarkus/pom.xml +++ b/camel-k-quarkus/pom.xml @@ -30,6 +30,13 @@ + + org.jetbrains.kotlin + kotlin-bom + ${kotlin.version} + pom + import + org.apache.camel.quarkus camel-quarkus-bom diff --git a/examples/camel-k-runtime-example-quarkus-kotlin/pom.xml b/examples/camel-k-runtime-example-quarkus-kotlin/pom.xml index 6b7d9fd2e..cae868a29 100644 --- a/examples/camel-k-runtime-example-quarkus-kotlin/pom.xml +++ b/examples/camel-k-runtime-example-quarkus-kotlin/pom.xml @@ -35,6 +35,13 @@ + + org.jetbrains.kotlin + kotlin-bom + ${kotlin.version} + pom + import + org.apache.camel.quarkus camel-quarkus-bom