[jsscripting] Use OSGi-ified GraalVM dependencies (#18053)

* [jsscripting] Use OSGI-ified org.graalvm.sdk:* dependencies

Signed-off-by: Florian Hotze <dev@florianhotze.com>
pull/18261/head
Florian Hotze 2025-02-13 09:23:05 +01:00 committed by GitHub
parent 01cb892fc3
commit 8c68fb706e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 28 additions and 6 deletions

View File

@ -1,6 +1,6 @@
# JavaScript Scripting
This add-on provides support for JavaScript (ECMAScript 2022+) that can be used as a scripting language within automation rules.
This add-on provides support for JavaScript (ECMAScript 2024+) that can be used as a scripting language within automation rules.
It is based on [GraalJS](https://www.graalvm.org/javascript/) from the [GraalVM project](https://www.graalvm.org/).
Also included is [openhab-js](https://github.com/openhab/openhab-js/), a fairly high-level ES6 library to support automation in openHAB. It provides convenient access

View File

@ -7,6 +7,13 @@ Require-Capability:
osgi.serviceloader:=
filter:="(osgi.serviceloader=org.graalvm.polyglot.impl.AbstractPolyglotImpl)";
cardinality:=multiple
Require-Bundle: org.graalvm.sdk.collections;bundle-version="24.1.2",\
org.graalvm.sdk.jniutils;bundle-version="24.1.2",\
org.graalvm.sdk.nativeimage;bundle-version="24.1.2",\
org.graalvm.sdk.word;bundle-version="24.1.2",\
org.graalvm.shadowed.icu4j;bundle-version="24.1.2",\
org.graalvm.truffle.truffle-compiler;bundle-version="24.1.2",\
org.graalvm.truffle.truffle-runtime;bundle-version="24.1.2"
SPI-Provider: *
SPI-Consumer: *

View File

@ -23,7 +23,7 @@
!jdk.vm.ci.services
</bnd.importpackage>
<!-- Remember to check if the fix https://github.com/openhab/openhab-core/pull/4437 still works when upgrading GraalJS -->
<graaljs.version>24.1.1</graaljs.version>
<graaljs.version>24.1.2</graaljs.version>
<oh.version>${project.version}</oh.version>
<ohjs.version>openhab@5.8.1</ohjs.version>
</properties>
@ -46,6 +46,14 @@
<excludes>
<exclude>org.lastnpe.eea:eea-all</exclude>
<exclude>org.apache.karaf.features:framework</exclude>
<!-- we use OSGI-ified version, so we don't need the following -->
<exclude>org.graalvm.sdk:collections</exclude>
<exclude>org.graalvm.sdk:jniutils</exclude>
<exclude>org.graalvm.sdk:nativeimage</exclude>
<exclude>org.graalvm.sdk:word</exclude>
<exclude>org.graalvm.shadowed:icu4j</exclude>
<exclude>org.graalvm.truffle:truffle-compiler</exclude>
<exclude>org.graalvm.truffle:truffle-runtime</exclude>
</excludes>
</artifactSet>
<createDependencyReducedPom>false</createDependencyReducedPom>
@ -109,6 +117,7 @@
</execution>
</executions>
</plugin>
<!-- embed the JS resources into the bundle -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
@ -141,6 +150,7 @@
</build>
<dependencies>
<!-- Graal Polyglot Framework -->
<dependency>
<groupId>org.graalvm.polyglot</groupId>
<artifactId>polyglot</artifactId>

View File

@ -5,6 +5,13 @@
<feature name="openhab-automation-jsscripting" description="JavaScript Scripting" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.sdk.collections/24.1.2</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.sdk.jniutils/24.1.2</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.sdk.nativeimage/24.1.2</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.sdk.word/24.1.2</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.shadowed.icu4j/24.1.2</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.truffle.truffle-compiler/24.1.2</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/org.graalvm.truffle.truffle-runtime/24.1.2</bundle>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.automation.jsscripting/${project.version}</bundle>
</feature>
</features>

View File

@ -23,8 +23,6 @@ import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;
import javax.script.ScriptException;
import org.eclipse.jdt.annotation.NonNull;
/**
* {@link ScriptEngine} implementation that delegates to a supplied ScriptEngine instance. Allows overriding specific
* methods.
@ -33,9 +31,9 @@ import org.eclipse.jdt.annotation.NonNull;
*/
public abstract class DelegatingScriptEngineWithInvocableAndCompilableAndAutocloseable<T extends ScriptEngine & Invocable & Compilable & AutoCloseable>
implements ScriptEngine, Invocable, Compilable, AutoCloseable {
protected @NonNull T delegate;
protected T delegate;
public DelegatingScriptEngineWithInvocableAndCompilableAndAutocloseable(@NonNull T delegate) {
public DelegatingScriptEngineWithInvocableAndCompilableAndAutocloseable(T delegate) {
this.delegate = delegate;
}