openhab-addons/bundles/org.openhab.automation.jsscripting/pom.xml

171 lines
6.0 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>5.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.openhab.automation.jsscripting</artifactId>
<name>openHAB Add-ons :: Bundles :: Automation :: JavaScript Scripting</name>
<properties>
<bnd.importpackage>
!sun.misc.*,
!sun.reflect.*,
!com.sun.management.*,
!jdk.internal.reflect.*,
!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>
<oh.version>${project.version}</oh.version>
<ohjs.version>openhab@5.8.1</ohjs.version>
</properties>
<build>
<plugins>
<!-- bundle the modular dependencies into an uber-JAR -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<exclude>org.lastnpe.eea:eea-all</exclude>
<exclude>org.apache.karaf.features:framework</exclude>
</excludes>
</artifactSet>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<!-- Transformer to merge module-info.class files, if needed -->
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<!-- bundle the openhab-js library -->
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.15.1</version>
<configuration>
<nodeVersion>v16.17.1</nodeVersion> <!-- DO NOT DOWNGRADE: NodeJS < 16 doesn't support Apple Silicon -->
<workingDirectory>target/js</workingDirectory>
</configuration>
<executions>
<execution>
<id>Install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<phase>generate-sources</phase>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<!--suppress UnresolvedMavenProperty -->
<arguments>install ${ohjs.version} webpack@^5.94.0 webpack-cli@^5.1.4</arguments> <!-- webpack & webpack-cli versions should match to the ones from openhab-js -->
</configuration>
</execution>
<execution>
<id>npx webpack (openhab-js globals injection)</id>
<goals>
<goal>npx</goal>
</goals>
<configuration>
<!--suppress UnresolvedMavenProperty -->
<arguments>webpack -c ./node_modules/openhab/build/@globals-webpack.config.js --entry-reset --entry
./node_modules/openhab/build/@openhab-globals.js -o ./dist</arguments>
</configuration>
</execution>
<execution>
<id>npx webpack (openhab-js)</id>
<goals>
<goal>npx</goal>
</goals>
<configuration>
<!--suppress UnresolvedMavenProperty -->
<arguments>webpack -c ./node_modules/openhab/build/webpack.config.js --entry-reset --entry
./node_modules/openhab/ -o ./dist</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>add-resource</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<resources>
<resource>
<directory>target/js/dist</directory>
<targetPath>node_modules</targetPath>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<!-- run SAT -->
[jsscripting] Extend synchronization to common ScriptEngine methods (#13924) * [jsscripting] Extend synchronization to common ScriptEngine methods This extends the multi-thread synchronization to "eval" and "invokeMethod" and moves synchronization for "invokeFunction" to the DelegatingScriptEngineWithInvocableAndAutocloseableAndSynchronization class. Fixes the multi-thread access requested warnings described in the community (https://community.openhab.org/t/openhab-3-4-milestone-discussion/138093/130) and related to https://github.com/openhab/openhab-core/pull/3180. * Revert "[jsscripting] Extend synchronization to common ScriptEngine methods" This reverts commit aadd21e45879c10aad29bf279ddbb0afd789b0aa. * [jsscripting] Extend synchronization to common ScriptEngine methods & Switch to ReentrantLock This extends the multi-thread synchronization to "eval" and "invokeMethod" and moves synchronization for "invokeFunction" to the InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable class. The synchronization mechanism changed from using synchronized to using a ReentrantLock together with catch_finally to avoid having deadlocks when an exception is thrown. Fixes the multi-thread access requested warnings described in the community (https://community.openhab.org/t/openhab-3-4-milestone-discussion/138093/130) and related to https://github.com/openhab/openhab-core/pull/3180. * [jsscripting] Reduce compiler warnings * [jsscripting] Replace finally blocks & Wrap returns in afterInvocation * [jsscripting] Fix deadlock caused by NoSuchMethodException in Invocable interface methods During testing my latest changes, I noticed that there is a deadlock when invokeFunction or invokeMethod are called on a non-existing method. This happens because the NoSuchMethodException keeps afterInvocation from running and therefore the lock never gets released. * [jsscripting] Also rethrow NPE & Fix PMD warnings/errors * [jsscripting] Wrap and rethrow other exceptions instead of returning them * [jsscripting] Address review comment from @jpg0 Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2022-12-14 20:12:54 +01:00
<plugin>
<groupId>org.openhab.tools.sat</groupId>
<artifactId>sat-plugin</artifactId>
<configuration>
<pmdFilter>${project.basedir}/suppressions.properties</pmdFilter>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.graalvm.polyglot</groupId>
<artifactId>polyglot</artifactId>
<version>${graaljs.version}</version>
</dependency>
<!-- Graal JavaScript ScriptEngine JSR 223 support -->
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js-scriptengine</artifactId>
<version>${graaljs.version}</version>
</dependency>
<!-- Graal TRegex engine (internally used by Graal JavaScript engine) -->
<dependency>
<groupId>org.graalvm.regex</groupId>
<artifactId>regex</artifactId>
<version>${graaljs.version}</version>
</dependency>
<!-- Graal JavaScript engine (depends on Graal TRegex engine, must be added after it) -->
<dependency>
<groupId>org.graalvm.polyglot</groupId>
<artifactId>js-community</artifactId>
<version>${graaljs.version}</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>