This is an automated email from the ASF dual-hosted git repository. lburgazzoli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git
The following commit(s) were added to refs/heads/master by this push: new c666377 loader(kotlin): add default imports c666377 is described below commit c666377049dc326baacba0f6453d5f772dc1c5ee Author: lburgazzoli <lburgazz...@gmail.com> AuthorDate: Sat Jul 20 10:22:58 2019 +0200 loader(kotlin): add default imports --- .../kotlin/KotlinCompilationConfiguration.kt | 40 ++++++++++++++++++++++ .../camel/k/loader/kotlin/KotlinRoutesLoader.kt | 14 -------- .../kotlin/KotlinScriptCompilationConfiguration.kt | 0 .../loader/kotlin/dsl/IntegrationConfiguration.kt | 4 +-- 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinCompilationConfiguration.kt b/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinCompilationConfiguration.kt new file mode 100644 index 0000000..c1b53a8 --- /dev/null +++ b/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinCompilationConfiguration.kt @@ -0,0 +1,40 @@ +/** + * 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 kotlin.script.experimental.api.* +import kotlin.script.experimental.jvm.dependenciesFromClassloader +import kotlin.script.experimental.jvm.jvm + +class KotlinCompilationConfiguration : ScriptCompilationConfiguration( +{ + defaultImports( + "org.apache.camel", + "org.apache.camel.spi" + ) + + jvm { + // + // The Kotlin script compiler does not inherit + // the classpath by default + // + dependenciesFromClassloader(wholeClasspath = true) + } + ide { + acceptedLocations(ScriptAcceptedLocation.Everywhere) + } +}) \ No newline at end of file diff --git a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinRoutesLoader.kt b/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinRoutesLoader.kt index a6105f9..ea1950b 100644 --- a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinRoutesLoader.kt +++ b/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinRoutesLoader.kt @@ -34,20 +34,6 @@ import kotlin.script.experimental.jvmhost.BasicJvmScriptingHost import kotlin.script.experimental.jvmhost.JvmScriptCompiler import kotlin.script.experimental.jvmhost.createJvmCompilationConfigurationFromTemplate -class KamelKtsConfigurator : ScriptCompilationConfiguration( -{ - jvm { - // - // The Kotlin script compiler does not inherit - // the classpath by default - // - dependenciesFromClassloader(wholeClasspath = true) - } - ide { - acceptedLocations(ScriptAcceptedLocation.Everywhere) - } -}) - class KotlinRoutesLoader : RoutesLoader { companion object { val LOGGER : Logger = LoggerFactory.getLogger(KotlinRoutesLoader::class.java) diff --git a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinScriptCompilationConfiguration.kt b/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinScriptCompilationConfiguration.kt deleted file mode 100644 index e69de29..0000000 diff --git a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationConfiguration.kt b/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationConfiguration.kt index e5029df..6c9bfd5 100644 --- a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationConfiguration.kt +++ b/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationConfiguration.kt @@ -20,12 +20,12 @@ import org.apache.camel.Exchange import org.apache.camel.Predicate import org.apache.camel.Processor import org.apache.camel.builder.RouteBuilder -import org.apache.camel.k.loader.kotlin.KamelKtsConfigurator +import org.apache.camel.k.loader.kotlin.KotlinCompilationConfiguration import org.apache.camel.model.* import org.apache.camel.spi.Registry import kotlin.script.experimental.annotations.KotlinScript -@KotlinScript(fileExtension = "kts", compilationConfiguration = KamelKtsConfigurator::class) +@KotlinScript(fileExtension = "kts", compilationConfiguration = KotlinCompilationConfiguration::class) abstract class IntegrationConfiguration( private val registry : Registry, private val builder : RouteBuilder) : org.apache.camel.builder.BuilderSupport(builder.context) {