This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push: new eef25fe Add initial support for kotlin new f3dca92 Merge pull request #549 from lburgazzoli/kotlin-extension eef25fe is described below commit eef25fe785e07a57b80d08a51d7e45f0896954e9 Author: lburgazzoli <lburgazz...@gmail.com> AuthorDate: Thu Dec 12 23:25:02 2019 +0100 Add initial support for kotlin --- .../pages/list-of-camel-quarkus-extensions.adoc | 4 +- examples/timer-log-kotlin/pom.xml | 21 +++- .../org/acme/timer/{TimerRoute.kt => routes.kt} | 13 +- extensions/kotlin/deployment/pom.xml | 136 +++++++++++++++++++++ .../quarkus/kotlin/deployment/KotlinFeature.kt | 18 +-- extensions/kotlin/pom.xml | 39 ++++++ .../kotlin/runtime}/pom.xml | 89 +++++--------- .../org/apache/camel/quarkus/kotlin/RoutesDSL.kt | 29 +++-- .../main/resources/META-INF/quarkus-extension.yaml | 29 +++++ extensions/pom.xml | 1 + extensions/readme.adoc | 4 +- pom.xml | 1 + poms/bom-deployment/pom.xml | 5 + poms/bom/pom.xml | 5 + 14 files changed, 316 insertions(+), 78 deletions(-) diff --git a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc index 17e3b51..e8c7090 100644 --- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc +++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc @@ -229,7 +229,7 @@ Number of Camel languages: 8 in 2 JAR artifacts (0 deprecated) == Miscellaneous Extensions // others: START -Number of miscellaneous extensions: 7 in 7 JAR artifacts (0 deprecated) +Number of miscellaneous extensions: 8 in 8 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -243,6 +243,8 @@ Number of miscellaneous extensions: 7 in 7 JAR artifacts (0 deprecated) | (camel-quarkus-hystrix) | 1.0.0-M1 | Circuit Breaker EIP using Netflix Hystrix +| (camel-quarkus-kotlin) | 1.0.0 | camel-quarkus-kotlin + | xref:extensions/microprofile-health.adoc[camel-quarkus-microprofile-health] | 0.3.0 | Bridging Eclipse MicroProfile Health with Camel health checks | xref:extensions/opentracing.adoc[camel-quarkus-opentracing] | 0.3.0 | Distributed tracing using OpenTracing diff --git a/examples/timer-log-kotlin/pom.xml b/examples/timer-log-kotlin/pom.xml index 8a92642..ea19296 100644 --- a/examples/timer-log-kotlin/pom.xml +++ b/examples/timer-log-kotlin/pom.xml @@ -45,8 +45,8 @@ <artifactId>camel-quarkus-log</artifactId> </dependency> <dependency> - <groupId>org.jetbrains.kotlin</groupId> - <artifactId>kotlin-stdlib-jdk8</artifactId> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-kotlin</artifactId> </dependency> </dependencies> @@ -85,6 +85,23 @@ </goals> </execution> </executions> + <configuration> + <compilerPlugins> + <plugin>all-open</plugin> + </compilerPlugins> + <pluginOptions> + <option>all-open:annotation=javax.enterprise.inject.Produces</option> + <option>all-open:annotation=javax.inject.Singleton</option> + <option>all-open:annotation=javax.enterprise.context.ApplicationScoped</option> + </pluginOptions> + </configuration> + <dependencies> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-maven-allopen</artifactId> + <version>${kotlin.version}</version> + </dependency> + </dependencies> </plugin> </plugins> </build> diff --git a/examples/timer-log-kotlin/src/main/kotlin/org/acme/timer/TimerRoute.kt b/examples/timer-log-kotlin/src/main/kotlin/org/acme/timer/routes.kt similarity index 73% copy from examples/timer-log-kotlin/src/main/kotlin/org/acme/timer/TimerRoute.kt copy to examples/timer-log-kotlin/src/main/kotlin/org/acme/timer/routes.kt index 92fb6d4..129a6ef 100644 --- a/examples/timer-log-kotlin/src/main/kotlin/org/acme/timer/TimerRoute.kt +++ b/examples/timer-log-kotlin/src/main/kotlin/org/acme/timer/routes.kt @@ -16,12 +16,17 @@ */ package org.acme.timer -import org.apache.camel.builder.RouteBuilder +import org.apache.camel.Exchange +import org.apache.camel.quarkus.kotlin.routes +import javax.enterprise.context.ApplicationScoped +import javax.enterprise.inject.Produces -class TimerRoute: RouteBuilder() { - override fun configure() { +@ApplicationScoped +class Routes { + @Produces + fun myRoutes() = routes { from("timer:foo?period=1s") - .process { e -> e.message.body = "Hello from Kotlin!" } + .process { e: Exchange -> e.message.body = "Hello from Kotlin!" } .log("\${body}") } } \ No newline at end of file diff --git a/extensions/kotlin/deployment/pom.xml b/extensions/kotlin/deployment/pom.xml new file mode 100644 index 0000000..ca6a206 --- /dev/null +++ b/extensions/kotlin/deployment/pom.xml @@ -0,0 +1,136 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-kotlin-parent</artifactId> + <version>1.0.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>camel-quarkus-kotlin-deployment</artifactId> + <name>Camel Quarkus :: Kotlin :: Deployment</name> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-core-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-kotlin</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-maven-plugin</artifactId> + <version>${kotlin.version}</version> + <configuration> + <jvmTarget>${maven.compiler.target}</jvmTarget> + </configuration> + <executions> + <execution> + <id>kapt</id> + <goals> + <goal>kapt</goal> + </goals> + <configuration> + <sourceDirs> + <sourceDir>src/main/kotlin</sourceDir> + </sourceDirs> + <annotationProcessorPaths> + <annotationProcessorPath> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-extension-processor</artifactId> + <version>${quarkus.version}</version> + </annotationProcessorPath> + </annotationProcessorPaths> + </configuration> + </execution> + <execution> + <id>compile</id> + <goals> + <goal>compile</goal> + </goals> + <configuration> + <sourceDirs> + <sourceDir>src/main/kotlin</sourceDir> + </sourceDirs> + </configuration> + </execution> + <execution> + <id>test-compile</id> + <goals> + <goal>test-compile</goal> + </goals> + <configuration> + <sourceDirs> + <sourceDir>src/test/kotlin</sourceDir> + </sourceDirs> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <executions> + <execution> + <id>default-compile</id> + <phase>none</phase> + </execution> + <execution> + <id>default-testCompile</id> + <phase>none</phase> + </execution> + <execution> + <id>java-compile</id> + <phase>compile</phase> + <goals> + <goal>compile</goal> + </goals> + </execution> + <execution> + <id>java-test-compile</id> + <phase>test-compile</phase> + <goals> + <goal>testCompile</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/examples/timer-log-kotlin/src/main/kotlin/org/acme/timer/TimerRoute.kt b/extensions/kotlin/deployment/src/main/kotlin/org/apache/camel/quarkus/kotlin/deployment/KotlinFeature.kt similarity index 69% copy from examples/timer-log-kotlin/src/main/kotlin/org/acme/timer/TimerRoute.kt copy to extensions/kotlin/deployment/src/main/kotlin/org/apache/camel/quarkus/kotlin/deployment/KotlinFeature.kt index 92fb6d4..d010a27 100644 --- a/examples/timer-log-kotlin/src/main/kotlin/org/acme/timer/TimerRoute.kt +++ b/extensions/kotlin/deployment/src/main/kotlin/org/apache/camel/quarkus/kotlin/deployment/KotlinFeature.kt @@ -14,14 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.acme.timer +package org.apache.camel.quarkus.kotlin.deployment -import org.apache.camel.builder.RouteBuilder +import io.quarkus.deployment.annotations.BuildStep +import io.quarkus.deployment.builditem.FeatureBuildItem -class TimerRoute: RouteBuilder() { - override fun configure() { - from("timer:foo?period=1s") - .process { e -> e.message.body = "Hello from Kotlin!" } - .log("\${body}") +class KotlinFeature { + companion object { + private const val FEATURE = "camel-kotlin" + } + + @BuildStep + fun feature(): FeatureBuildItem { + return FeatureBuildItem(FEATURE) } } \ No newline at end of file diff --git a/extensions/kotlin/pom.xml b/extensions/kotlin/pom.xml new file mode 100644 index 0000000..360b48b --- /dev/null +++ b/extensions/kotlin/pom.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-build-parent</artifactId> + <version>1.0.0-SNAPSHOT</version> + <relativePath>../../poms/build-parent/pom.xml</relativePath> + </parent> + + <modelVersion>4.0.0</modelVersion> + + <artifactId>camel-quarkus-kotlin-parent</artifactId> + <name>Camel Quarkus :: Kotlin</name> + <packaging>pom</packaging> + <modules> + <module>deployment</module> + <module>runtime</module> + </modules> + +</project> diff --git a/examples/timer-log-kotlin/pom.xml b/extensions/kotlin/runtime/pom.xml similarity index 52% copy from examples/timer-log-kotlin/pom.xml copy to extensions/kotlin/runtime/pom.xml index 8a92642..4563cfa 100644 --- a/examples/timer-log-kotlin/pom.xml +++ b/extensions/kotlin/runtime/pom.xml @@ -20,29 +20,35 @@ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-build-parent</artifactId> + <artifactId>camel-quarkus-kotlin-parent</artifactId> <version>1.0.0-SNAPSHOT</version> - <relativePath>../../poms/build-parent/pom.xml</relativePath> </parent> - <modelVersion>4.0.0</modelVersion> - <artifactId>camel-quarkus-examples-timer-log-kotlin</artifactId> - <name>Camel Quarkus :: Examples :: Timer Log Kotlin</name> - <description>Camel Quarkus Example :: Timer to Log Kotlin</description> + <artifactId>camel-quarkus-kotlin</artifactId> + <name>Camel Quarkus :: Kotlin :: Runtime</name> + <description>camel-quarkus-kotlin</description> <properties> - <kotlin.version>1.3.21</kotlin.version> + <firstVersion>1.0.0</firstVersion> </properties> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + <dependencies> <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> + <groupId>org.apache.camel</groupId> + <artifactId>camel-core-engine</artifactId> </dependency> <dependency> <groupId>org.jetbrains.kotlin</groupId> @@ -51,19 +57,10 @@ </dependencies> <build> - <sourceDirectory>src/main/kotlin</sourceDirectory> <plugins> <plugin> <groupId>io.quarkus</groupId> - <artifactId>quarkus-maven-plugin</artifactId> - <executions> - <execution> - <id>build</id> - <goals> - <goal>build</goal> - </goals> - </execution> - </executions> + <artifactId>quarkus-bootstrap-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.jetbrains.kotlin</groupId> @@ -76,6 +73,11 @@ <goals> <goal>compile</goal> </goals> + <configuration> + <sourceDirs> + <sourceDir>src/main/kotlin</sourceDir> + </sourceDirs> + </configuration> </execution> <execution> <id>test-compile</id> @@ -83,42 +85,17 @@ <goals> <goal>test-compile</goal> </goals> + <configuration> + <sourceDirs> + <sourceDir>src/test/kotlin</sourceDir> + </sourceDirs> + </configuration> </execution> </executions> + <configuration> + <jvmTarget>${maven.compiler.target}</jvmTarget> + </configuration> </plugin> </plugins> </build> - - <profiles> - <profile> - <id>native</id> - <activation> - <property> - <name>native</name> - </property> - </activation> - <build> - <plugins> - <plugin> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-maven-plugin</artifactId> - <executions> - <execution> - <id>native-image</id> - <goals> - <goal>native-image</goal> - </goals> - <configuration> - <enableServer>false</enableServer> - <cleanupServer>true</cleanupServer> - <disableReports>true</disableReports> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> - </project> diff --git a/examples/timer-log-kotlin/src/main/kotlin/org/acme/timer/TimerRoute.kt b/extensions/kotlin/runtime/src/main/kotlin/org/apache/camel/quarkus/kotlin/RoutesDSL.kt similarity index 61% rename from examples/timer-log-kotlin/src/main/kotlin/org/acme/timer/TimerRoute.kt rename to extensions/kotlin/runtime/src/main/kotlin/org/apache/camel/quarkus/kotlin/RoutesDSL.kt index 92fb6d4..1412771 100644 --- a/examples/timer-log-kotlin/src/main/kotlin/org/acme/timer/TimerRoute.kt +++ b/extensions/kotlin/runtime/src/main/kotlin/org/apache/camel/quarkus/kotlin/RoutesDSL.kt @@ -14,14 +14,29 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.acme.timer +package org.apache.camel.quarkus.kotlin +import org.apache.camel.RoutesBuilder import org.apache.camel.builder.RouteBuilder -class TimerRoute: RouteBuilder() { - override fun configure() { - from("timer:foo?period=1s") - .process { e -> e.message.body = "Hello from Kotlin!" } - .log("\${body}") +/** + * Functional routes definition Kotlin DSL. + * + * Example: + * + * ``` + * fun myRoutes() = routes { + * from("timer:foo?period=1s") + * .log("\${body}") + * } + * ``` + * + * In a nutshell, it makes it possible to configure routes with a lambda that acts as RouteBuilder. + */ +fun routes(block: RouteBuilder.() -> Unit) : RoutesBuilder { + return object: RouteBuilder() { + override fun configure() { + this.block() + } } -} \ No newline at end of file +} diff --git a/extensions/kotlin/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/kotlin/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000..97390fc --- /dev/null +++ b/extensions/kotlin/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,29 @@ +# +# 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. +# + +--- +name: "Camel Quarkus Kotlin" +description: "Camel Quarkus Kotlin" +metadata: + keywords: + - "camel" + - "kotlin" + guide: "https://quarkus.io/guides/camel" + categories: + - "integration" + - "alt-languages" + status: "preview" diff --git a/extensions/pom.xml b/extensions/pom.xml index 06ffb38..4569fd0 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -68,6 +68,7 @@ <module>jackson</module> <module>jdbc</module> <module>kafka</module> + <module>kotlin</module> <module>log</module> <module>mail</module> <module>microprofile-health</module> diff --git a/extensions/readme.adoc b/extensions/readme.adoc index aa43ae0..e15bb4b 100644 --- a/extensions/readme.adoc +++ b/extensions/readme.adoc @@ -231,7 +231,7 @@ Number of Camel languages: 8 in 2 JAR artifacts (0 deprecated) == Miscellaneous Extensions // others: START -Number of miscellaneous extensions: 7 in 7 JAR artifacts (0 deprecated) +Number of miscellaneous extensions: 8 in 8 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -245,6 +245,8 @@ Number of miscellaneous extensions: 7 in 7 JAR artifacts (0 deprecated) | (camel-quarkus-hystrix) | 1.0.0-M1 | Circuit Breaker EIP using Netflix Hystrix +| (camel-quarkus-kotlin) | 1.0.0 | camel-quarkus-kotlin + | xref:extensions/microprofile-health.adoc[camel-quarkus-microprofile-health] | 0.3.0 | Bridging Eclipse MicroProfile Health with Camel health checks | xref:extensions/opentracing.adoc[camel-quarkus-opentracing] | 0.3.0 | Distributed tracing using OpenTracing diff --git a/pom.xml b/pom.xml index c3f2aeb..0241c1c 100644 --- a/pom.xml +++ b/pom.xml @@ -47,6 +47,7 @@ <xstream.version>1.4.11</xstream.version> <snakeyaml.version>1.25</snakeyaml.version> <xalan.version>2.7.2</xalan.version> + <kotlin.version>1.3.21</kotlin.version> <maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version> <maven.compiler.target>1.8</maven.compiler.target> diff --git a/poms/bom-deployment/pom.xml b/poms/bom-deployment/pom.xml index 1af509d..731332a 100644 --- a/poms/bom-deployment/pom.xml +++ b/poms/bom-deployment/pom.xml @@ -210,6 +210,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-kotlin-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-log-deployment</artifactId> <version>${camel-quarkus.version}</version> </dependency> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 3206d08..b9d2544 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -574,6 +574,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-kotlin</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-log</artifactId> <version>${camel-quarkus.version}</version> </dependency>