Skip to content

Commit

Permalink
Upgrade to Kotlin 1.8.20
Browse files Browse the repository at this point in the history
* Fix Scripting module to rely on the `kotlin-scripting-jsr223` instead
* Deprecate `KotlinScriptExecutor` in favor of `DefaultScriptExecutor` with `kotlin` as lang
  • Loading branch information
artembilan committed Feb 17, 2024
1 parent c6e6217 commit e21de19
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 42 deletions.
9 changes: 2 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlinVersion = '1.8.10'
ext.kotlinVersion = '1.8.20'
ext.isCI = System.getenv('GITHUB_ACTION')
repositories {
gradlePluginPortal()
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -18,29 +18,24 @@

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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -40,9 +40,6 @@ public static ScriptExecutor getScriptExecutor(String language) {
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");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -48,7 +48,7 @@ public void testParseLanguage() {
RubyScriptExecutor.class,
DefaultScriptExecutor.class,
PythonScriptExecutor.class,
KotlinScriptExecutor.class
DefaultScriptExecutor.class
};

Map<String, ScriptExecutingMessageProcessor> scriptProcessors =
Expand Down
20 changes: 3 additions & 17 deletions src/reference/asciidoc/scripting.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,25 @@ 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"]
.Maven
----
<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.

Expand Down

0 comments on commit e21de19

Please sign in to comment.