Skip to content

Commit 11e9d6b

Browse files
Support Java 21 (#1640)
* Allow for compiling with Java 21 * Support Java 17 and 21, default compilation to Java 17 class files * Add profile "j21" to compile to Java 21 class files * Upgrade SAT to 0.16.0 * Adapt Karaf scpipts to allow both Java 17 and 21 Signed-off-by: Holger Friedrich <[email protected]>
1 parent f406288 commit 11e9d6b

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

distributions/openhab/src/main/resources/bin/karaf

+3-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ init() {
160160
# Determine the JVM version and check that it is version 17
161161
checkJvmVersion
162162
if [ "${VERSION}" -ne "17" ]; then
163-
die "JVM must be version 17. JVM version ${VERSION} is unsupported (JAVA_HOME=$JAVA_HOME)"
163+
if [ "${VERSION}" -ne "21" ]; then
164+
die "JVM must be version 17 or 21. JVM version ${VERSION} is unsupported (JAVA_HOME=$JAVA_HOME)"
165+
fi
164166
fi
165167

166168
# Check if a root instance is already running

distributions/openhab/src/main/resources/bin/karaf.bat

+4-2
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,10 @@ for /f tokens^=2-5^ delims^=.-_+^" %%j in ('"%JAVA%" -fullversion 2^>^&1') do (
215215
)
216216

217217
if %JAVA_VERSION% NEQ 17 (
218-
call :warn "JVM must be version 17. JVM version %JAVA_VERSION% is unsupported (JAVA_HOME=%JAVA_HOME%)"
219-
goto END
218+
if %JAVA_VERSION% NEQ 21 (
219+
call :warn "JVM must be version 17 or 21. JVM version %JAVA_VERSION% is unsupported (JAVA_HOME=%JAVA_HOME%)"
220+
goto END
221+
)
220222
)
221223

222224
if %JAVA_VERSION% GTR 8 (

launch/app/pom.xml

+8-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1616
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
1717
<oh.java.version>17</oh.java.version>
18-
<maven.compiler.source>${oh.java.version}</maven.compiler.source>
19-
<maven.compiler.target>${oh.java.version}</maven.compiler.target>
18+
<maven.compiler.release>${oh.java.version}</maven.compiler.release>
2019
<bnd.version>7.0.0</bnd.version>
2120
</properties>
2221

@@ -383,6 +382,13 @@
383382
</pluginManagement>
384383
</build>
385384
</profile>
385+
<profile>
386+
<id>j21</id>
387+
<properties>
388+
<oh.java.version>21</oh.java.version>
389+
<maven.compiler.release>${oh.java.version}</maven.compiler.release>
390+
</properties>
391+
</profile>
386392
</profiles>
387393

388394
</project>

pom.xml

+11-5
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,9 @@
6464
<karaf.version>4.4.5</karaf.version>
6565

6666
<oh.java.version>17</oh.java.version>
67-
<maven.compiler.source>${oh.java.version}</maven.compiler.source>
68-
<maven.compiler.target>${oh.java.version}</maven.compiler.target>
67+
<maven.compiler.release>${oh.java.version}</maven.compiler.release>
6968

70-
<sat.version>0.15.0</sat.version>
69+
<sat.version>0.16.0</sat.version>
7170
<spotless.version>2.38.0</spotless.version>
7271
<!-- Eclipse Java formatter version 4.26+ does not check test files -->
7372
<spotless.eclipse.version>4.25</spotless.eclipse.version>
@@ -111,7 +110,7 @@
111110
<plugin>
112111
<groupId>org.apache.maven.plugins</groupId>
113112
<artifactId>maven-compiler-plugin</artifactId>
114-
<version>3.11.0</version>
113+
<version>3.13.0</version>
115114
</plugin>
116115
<plugin>
117116
<groupId>org.apache.maven.plugins</groupId>
@@ -249,7 +248,7 @@
249248
<configuration>
250249
<rules>
251250
<requireJavaVersion>
252-
<version>[17.0,18.0)</version>
251+
<version>[17.0,18.0),[21.0,22.0)</version>
253252
</requireJavaVersion>
254253
</rules>
255254
</configuration>
@@ -319,6 +318,13 @@
319318
<pax.url.suffix></pax.url.suffix>
320319
</properties>
321320
</profile>
321+
<profile>
322+
<id>j21</id>
323+
<properties>
324+
<oh.java.version>21</oh.java.version>
325+
<maven.compiler.release>${oh.java.version}</maven.compiler.release>
326+
</properties>
327+
</profile>
322328
</profiles>
323329

324330
</project>

0 commit comments

Comments
 (0)