Skip to content

Commit e21de19

Browse files
committed
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
1 parent c6e6217 commit e21de19

File tree

5 files changed

+15
-42
lines changed

5 files changed

+15
-42
lines changed

build.gradle

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.kotlinVersion = '1.8.10'
2+
ext.kotlinVersion = '1.8.20'
33
ext.isCI = System.getenv('GITHUB_ACTION')
44
repositories {
55
gradlePluginPortal()
@@ -852,18 +852,13 @@ project('spring-integration-scripting') {
852852
description = 'Spring Integration Scripting Support'
853853
dependencies {
854854
api project(':spring-integration-core')
855-
optionalApi ('org.jetbrains.kotlin:kotlin-script-util') {
856-
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-daemon-client'
857-
}
858-
optionalApi 'org.jetbrains.kotlin:kotlin-compiler-embeddable'
855+
optionalApi 'org.jetbrains.kotlin:kotlin-scripting-jsr223'
859856
providedImplementation "org.graalvm.sdk:graal-sdk:$graalvmVersion"
860857
providedImplementation "org.graalvm.js:js:$graalvmVersion"
861858

862859
testImplementation "org.jruby:jruby-complete:$jrubyVersion"
863860
testImplementation 'org.apache.groovy:groovy-jsr223'
864861
testImplementation "org.python:jython-standalone:$jythonVersion"
865-
866-
testRuntimeOnly 'org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable'
867862
}
868863

869864
tasks.withType(JavaForkOptions) {

spring-integration-scripting/src/main/java/org/springframework/integration/scripting/jsr223/KotlinScriptExecutor.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019 the original author or authors.
2+
* Copyright 2019-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,29 +18,24 @@
1818

1919
import javax.script.Bindings;
2020
import javax.script.ScriptEngine;
21-
22-
import org.jetbrains.kotlin.script.jsr223.KotlinJsr223JvmLocalScriptEngineFactory;
21+
import javax.script.ScriptEngineManager;
2322

2423

2524
/**
2625
* An {@link AbstractScriptExecutor} for the Kotlin scripts support.
27-
* Uses {@link KotlinJsr223JvmLocalScriptEngineFactory} directly since there is
28-
* no {@code META-INF/services/javax.script.ScriptEngineFactory} file in CLASSPATH.
29-
* Also sets an {@code idea.use.native.fs.for.win} system property to {@code false}
30-
* to disable a native engine discovery for Windows: bay be resolved in the future Kotlin versions.
3126
*
3227
* @author Artem Bilan
3328
*
3429
* @since 5.2
30+
*
31+
* @deprecated since 6.1.6 in favor of {@link DefaultScriptExecutor} with {@code kotlin}
32+
* as an argument.
3533
*/
34+
@Deprecated(since = "6.1.6", forRemoval = true)
3635
public class KotlinScriptExecutor extends AbstractScriptExecutor {
3736

38-
static {
39-
System.setProperty("idea.use.native.fs.for.win", "false");
40-
}
41-
4237
public KotlinScriptExecutor() {
43-
super(new KotlinJsr223JvmLocalScriptEngineFactory().getScriptEngine());
38+
super(new ScriptEngineManager().getEngineByName("kotlin"));
4439
}
4540

4641
@Override

spring-integration-scripting/src/main/java/org/springframework/integration/scripting/jsr223/ScriptExecutorFactory.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,9 +40,6 @@ public static ScriptExecutor getScriptExecutor(String language) {
4040
else if (language.equalsIgnoreCase("ruby") || language.equalsIgnoreCase("jruby")) {
4141
return new RubyScriptExecutor();
4242
}
43-
else if (language.equalsIgnoreCase("kotlin")) {
44-
return new KotlinScriptExecutor();
45-
}
4643
else if (language.equalsIgnoreCase("js") || language.equalsIgnoreCase("javascript")) {
4744
return new PolyglotScriptExecutor("js");
4845
}

spring-integration-scripting/src/test/java/org/springframework/integration/scripting/jsr223/DeriveLanguageFromExtensionTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -48,7 +48,7 @@ public void testParseLanguage() {
4848
RubyScriptExecutor.class,
4949
DefaultScriptExecutor.class,
5050
PythonScriptExecutor.class,
51-
KotlinScriptExecutor.class
51+
DefaultScriptExecutor.class
5252
};
5353

5454
Map<String, ScriptExecutingMessageProcessor> scriptProcessors =

src/reference/asciidoc/scripting.adoc

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,25 @@ compile "org.springframework.integration:spring-integration-scripting:{project-v
2727
In addition, you need to add a script engine implementation, e.g. JRuby, Jython.
2828

2929
Starting with version 5.2, Spring Integration provides a Kotlin Jsr223 support.
30-
You need to add these dependencies into your project to make it working:
30+
You need to add this dependency into your project to make it working:
3131

3232
====
3333
[source, xml, subs="normal", role="primary"]
3434
.Maven
3535
----
3636
<dependency>
3737
<groupId>org.jetbrains.kotlin</groupId>
38-
<artifactId>kotlin-script-util</artifactId>
39-
<scope>runtime</scope>
40-
</dependency>
41-
<dependency>
42-
<groupId>org.jetbrains.kotlin</groupId>
43-
<artifactId>kotlin-compiler-embeddable</artifactId>
44-
<scope>runtime</scope>
45-
</dependency>
46-
<dependency>
47-
<groupId>org.jetbrains.kotlin</groupId>
48-
<artifactId>kotlin-scripting-compiler-embeddable</artifactId>
38+
<artifactId>kotlin-scripting-jsr223</artifactId>
4939
<scope>runtime</scope>
5040
</dependency>
5141
----
5242
[source, groovy, subs="normal", role="secondary"]
5343
.Gradle
5444
----
55-
runtime 'org.jetbrains.kotlin:kotlin-script-util'
56-
runtime 'org.jetbrains.kotlin:kotlin-compiler-embeddable'
57-
runtime 'org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable'
45+
runtime 'org.jetbrains.kotlin:kotlin-scripting-jsr223'
5846
----
5947
====
6048

61-
The `KotlinScriptExecutor` is selected by the provided `kotlin` language indicator or script file comes with the `.kts` extension.
62-
6349
In order to use a JVM scripting language, a JSR223 implementation for that language must be included in your class path.
6450
The https://groovy-lang.org/[Groovy] and https://www.jruby.org[JRuby] projects provide JSR233 support in their standard distributions.
6551

0 commit comments

Comments
 (0)