[jsscripting] Fix build failure due to missing webpack dependency by cloning openhab-js & installing its dev dependencies (#21060)

Supersedes #21059.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
This commit is contained in:
Florian Hotze
2026-06-26 13:39:56 +02:00
committed by GitHub
parent cc3bf8c910
commit 331f60c71f
@@ -15,9 +15,8 @@
<name>openHAB Add-ons :: Bundles :: Automation :: JavaScript Scripting</name> <name>openHAB Add-ons :: Bundles :: Automation :: JavaScript Scripting</name>
<properties> <properties>
<!-- Remember to check if the fix https://github.com/openhab/openhab-core/pull/4437 still works when upgrading GraalJS -->
<node.version>v22.17.1</node.version> <node.version>v22.17.1</node.version>
<ohjs.version>openhab@5.18.2</ohjs.version> <ohjs.version>v5.18.2</ohjs.version>
</properties> </properties>
<dependencies> <dependencies>
@@ -41,17 +40,52 @@
<build> <build>
<plugins> <plugins>
<!-- bundle the openhab-js library --> <!-- clone openhab-js -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<providerImplementations>
<git>jgit</git>
</providerImplementations>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-jgit</artifactId>
<version>2.2.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>checkout-openhab-js</id>
<goals>
<goal>checkout</goal>
</goals>
<phase>initialize</phase>
<configuration>
<connectionUrl>scm:git:https://github.com/openhab/openhab-js.git</connectionUrl>
<checkoutDirectory>${project.build.directory}/js/openhab-js</checkoutDirectory>
<scmVersion>${ohjs.version}</scmVersion>
<scmVersionType>tag</scmVersionType>
<shallow>true</shallow>
</configuration>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>com.github.eirslett</groupId> <groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId> <artifactId>frontend-maven-plugin</artifactId>
<version>2.0.1</version> <version>2.0.1</version>
<configuration> <configuration>
<installDirectory>target/js</installDirectory> <installDirectory>${project.build.directory}/js</installDirectory>
<nodeVersion>${node.version}</nodeVersion> <nodeVersion>${node.version}</nodeVersion>
<workingDirectory>target/js</workingDirectory> <workingDirectory>${project.build.directory}/js/openhab-js</workingDirectory>
</configuration> </configuration>
<executions> <executions>
<!-- install Node.js and npm -->
<execution> <execution>
<id>Install node and npm</id> <id>Install node and npm</id>
<goals> <goals>
@@ -59,17 +93,18 @@
</goals> </goals>
<phase>generate-sources</phase> <phase>generate-sources</phase>
</execution> </execution>
<!-- install dependencies -->
<execution> <execution>
<id>npm install</id> <id>npm install</id>
<goals> <goals>
<goal>npm</goal> <goal>npm</goal>
</goals> </goals>
<phase>generate-sources</phase>
<configuration> <configuration>
<!--suppress UnresolvedMavenProperty --> <arguments>ci</arguments>
<arguments>install ${ohjs.version} webpack@^5.105.0 webpack-cli@^6.0.1 --prefix .</arguments>
<!-- webpack & webpack-cli versions should match to the ones from openhab-js -->
</configuration> </configuration>
</execution> </execution>
<!-- bundle openhab-js -->
<execution> <execution>
<id>npx webpack (openhab-js globals injection)</id> <id>npx webpack (openhab-js globals injection)</id>
<goals> <goals>
@@ -77,8 +112,7 @@
</goals> </goals>
<configuration> <configuration>
<!--suppress UnresolvedMavenProperty --> <!--suppress UnresolvedMavenProperty -->
<arguments>webpack -c ./node_modules/openhab/build/@globals-webpack.config.js --entry-reset --entry <arguments>webpack -c ./build/@globals-webpack.config.js --entry-reset --entry ./build/@openhab-globals.js -o ../dist</arguments>
./node_modules/openhab/build/@openhab-globals.js -o ./dist</arguments>
</configuration> </configuration>
</execution> </execution>
<execution> <execution>
@@ -87,9 +121,7 @@
<goal>npx</goal> <goal>npx</goal>
</goals> </goals>
<configuration> <configuration>
<!--suppress UnresolvedMavenProperty --> <arguments>webpack -c ./build/webpack.config.js --entry-reset --entry ./ -o ../dist</arguments>
<arguments>webpack -c ./node_modules/openhab/build/webpack.config.js --entry-reset --entry
./node_modules/openhab/ -o ./dist</arguments>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
@@ -100,6 +132,7 @@
<artifactId>build-helper-maven-plugin</artifactId> <artifactId>build-helper-maven-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<id>add-js-resource</id>
<goals> <goals>
<goal>add-resource</goal> <goal>add-resource</goal>
</goals> </goals>
@@ -107,7 +140,7 @@
<configuration> <configuration>
<resources> <resources>
<resource> <resource>
<directory>target/js/dist</directory> <directory>${project.build.directory}/js/dist</directory>
<targetPath>node_modules</targetPath> <targetPath>node_modules</targetPath>
</resource> </resource>
</resources> </resources>
@@ -123,6 +156,13 @@
<pmdFilter>${project.basedir}/suppressions.properties</pmdFilter> <pmdFilter>${project.basedir}/suppressions.properties</pmdFilter>
</configuration> </configuration>
</plugin> </plugin>
<!-- workaround for failing clean of checked out git repo breaking the Windows build, #19250 -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<force>true</force>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>