Upgrade to Kotlin 1.8.20
* Fix Scripting module to rely on the `kotlin-scripting-jsr223` instead * Deprecate `KotlinScriptExecutor` in favor of `DefaultScriptExecutor` with `kotlin` as lang
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
buildscript {
|
||||
ext.kotlinVersion = '1.8.10'
|
||||
ext.kotlinVersion = '1.8.20'
|
||||
ext.isCI = System.getenv('GITHUB_ACTION')
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
@@ -852,18 +852,13 @@ project('spring-integration-scripting') {
|
||||
description = 'Spring Integration Scripting Support'
|
||||
dependencies {
|
||||
api project(':spring-integration-core')
|
||||
optionalApi ('org.jetbrains.kotlin:kotlin-script-util') {
|
||||
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-daemon-client'
|
||||
}
|
||||
optionalApi 'org.jetbrains.kotlin:kotlin-compiler-embeddable'
|
||||
optionalApi 'org.jetbrains.kotlin:kotlin-scripting-jsr223'
|
||||
providedImplementation "org.graalvm.sdk:graal-sdk:$graalvmVersion"
|
||||
providedImplementation "org.graalvm.js:js:$graalvmVersion"
|
||||
|
||||
testImplementation "org.jruby:jruby-complete:$jrubyVersion"
|
||||
testImplementation 'org.apache.groovy:groovy-jsr223'
|
||||
testImplementation "org.python:jython-standalone:$jythonVersion"
|
||||
|
||||
testRuntimeOnly 'org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable'
|
||||
}
|
||||
|
||||
tasks.withType(JavaForkOptions) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
* Copyright 2019-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,29 +18,24 @@ package org.springframework.integration.scripting.jsr223;
|
||||
|
||||
import javax.script.Bindings;
|
||||
import javax.script.ScriptEngine;
|
||||
|
||||
import org.jetbrains.kotlin.script.jsr223.KotlinJsr223JvmLocalScriptEngineFactory;
|
||||
import javax.script.ScriptEngineManager;
|
||||
|
||||
|
||||
/**
|
||||
* An {@link AbstractScriptExecutor} for the Kotlin scripts support.
|
||||
* Uses {@link KotlinJsr223JvmLocalScriptEngineFactory} directly since there is
|
||||
* no {@code META-INF/services/javax.script.ScriptEngineFactory} file in CLASSPATH.
|
||||
* Also sets an {@code idea.use.native.fs.for.win} system property to {@code false}
|
||||
* to disable a native engine discovery for Windows: bay be resolved in the future Kotlin versions.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 5.2
|
||||
*
|
||||
* @deprecated since 6.1.6 in favor of {@link DefaultScriptExecutor} with {@code kotlin}
|
||||
* as an argument.
|
||||
*/
|
||||
@Deprecated(since = "6.1.6", forRemoval = true)
|
||||
public class KotlinScriptExecutor extends AbstractScriptExecutor {
|
||||
|
||||
static {
|
||||
System.setProperty("idea.use.native.fs.for.win", "false");
|
||||
}
|
||||
|
||||
public KotlinScriptExecutor() {
|
||||
super(new KotlinJsr223JvmLocalScriptEngineFactory().getScriptEngine());
|
||||
super(new ScriptEngineManager().getEngineByName("kotlin"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,9 +40,6 @@ public final class ScriptExecutorFactory {
|
||||
else if (language.equalsIgnoreCase("ruby") || language.equalsIgnoreCase("jruby")) {
|
||||
return new RubyScriptExecutor();
|
||||
}
|
||||
else if (language.equalsIgnoreCase("kotlin")) {
|
||||
return new KotlinScriptExecutor();
|
||||
}
|
||||
else if (language.equalsIgnoreCase("js") || language.equalsIgnoreCase("javascript")) {
|
||||
return new PolyglotScriptExecutor("js");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -48,7 +48,7 @@ public class DeriveLanguageFromExtensionTests {
|
||||
RubyScriptExecutor.class,
|
||||
DefaultScriptExecutor.class,
|
||||
PythonScriptExecutor.class,
|
||||
KotlinScriptExecutor.class
|
||||
DefaultScriptExecutor.class
|
||||
};
|
||||
|
||||
Map<String, ScriptExecutingMessageProcessor> scriptProcessors =
|
||||
|
||||
@@ -27,7 +27,7 @@ compile "org.springframework.integration:spring-integration-scripting:{project-v
|
||||
In addition, you need to add a script engine implementation, e.g. JRuby, Jython.
|
||||
|
||||
Starting with version 5.2, Spring Integration provides a Kotlin Jsr223 support.
|
||||
You need to add these dependencies into your project to make it working:
|
||||
You need to add this dependency into your project to make it working:
|
||||
|
||||
====
|
||||
[source, xml, subs="normal", role="primary"]
|
||||
@@ -35,31 +35,17 @@ You need to add these dependencies into your project to make it working:
|
||||
----
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-script-util</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-compiler-embeddable</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-scripting-compiler-embeddable</artifactId>
|
||||
<artifactId>kotlin-scripting-jsr223</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
----
|
||||
[source, groovy, subs="normal", role="secondary"]
|
||||
.Gradle
|
||||
----
|
||||
runtime 'org.jetbrains.kotlin:kotlin-script-util'
|
||||
runtime 'org.jetbrains.kotlin:kotlin-compiler-embeddable'
|
||||
runtime 'org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable'
|
||||
runtime 'org.jetbrains.kotlin:kotlin-scripting-jsr223'
|
||||
----
|
||||
====
|
||||
|
||||
The `KotlinScriptExecutor` is selected by the provided `kotlin` language indicator or script file comes with the `.kts` extension.
|
||||
|
||||
In order to use a JVM scripting language, a JSR223 implementation for that language must be included in your class path.
|
||||
The https://groovy-lang.org/[Groovy] and https://www.jruby.org[JRuby] projects provide JSR233 support in their standard distributions.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user