Skip to content

Commit

Permalink
Support Java 21 (#1640)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
holgerfriedrich authored May 14, 2024
1 parent f406288 commit 11e9d6b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
4 changes: 3 additions & 1 deletion distributions/openhab/src/main/resources/bin/karaf
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ init() {
# Determine the JVM version and check that it is version 17
checkJvmVersion
if [ "${VERSION}" -ne "17" ]; then
die "JVM must be version 17. JVM version ${VERSION} is unsupported (JAVA_HOME=$JAVA_HOME)"
if [ "${VERSION}" -ne "21" ]; then
die "JVM must be version 17 or 21. JVM version ${VERSION} is unsupported (JAVA_HOME=$JAVA_HOME)"
fi
fi

# Check if a root instance is already running
Expand Down
6 changes: 4 additions & 2 deletions distributions/openhab/src/main/resources/bin/karaf.bat
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,10 @@ for /f tokens^=2-5^ delims^=.-_+^" %%j in ('"%JAVA%" -fullversion 2^>^&1') do (
)

if %JAVA_VERSION% NEQ 17 (
call :warn "JVM must be version 17. JVM version %JAVA_VERSION% is unsupported (JAVA_HOME=%JAVA_HOME%)"
goto END
if %JAVA_VERSION% NEQ 21 (
call :warn "JVM must be version 17 or 21. JVM version %JAVA_VERSION% is unsupported (JAVA_HOME=%JAVA_HOME%)"
goto END
)
)

if %JAVA_VERSION% GTR 8 (
Expand Down
10 changes: 8 additions & 2 deletions launch/app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<oh.java.version>17</oh.java.version>
<maven.compiler.source>${oh.java.version}</maven.compiler.source>
<maven.compiler.target>${oh.java.version}</maven.compiler.target>
<maven.compiler.release>${oh.java.version}</maven.compiler.release>
<bnd.version>7.0.0</bnd.version>
</properties>

Expand Down Expand Up @@ -383,6 +382,13 @@
</pluginManagement>
</build>
</profile>
<profile>
<id>j21</id>
<properties>
<oh.java.version>21</oh.java.version>
<maven.compiler.release>${oh.java.version}</maven.compiler.release>
</properties>
</profile>
</profiles>

</project>
16 changes: 11 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@
<karaf.version>4.4.5</karaf.version>

<oh.java.version>17</oh.java.version>
<maven.compiler.source>${oh.java.version}</maven.compiler.source>
<maven.compiler.target>${oh.java.version}</maven.compiler.target>
<maven.compiler.release>${oh.java.version}</maven.compiler.release>

<sat.version>0.15.0</sat.version>
<sat.version>0.16.0</sat.version>
<spotless.version>2.38.0</spotless.version>
<!-- Eclipse Java formatter version 4.26+ does not check test files -->
<spotless.eclipse.version>4.25</spotless.eclipse.version>
Expand Down Expand Up @@ -111,7 +110,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<version>3.13.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -249,7 +248,7 @@
<configuration>
<rules>
<requireJavaVersion>
<version>[17.0,18.0)</version>
<version>[17.0,18.0),[21.0,22.0)</version>
</requireJavaVersion>
</rules>
</configuration>
Expand Down Expand Up @@ -319,6 +318,13 @@
<pax.url.suffix></pax.url.suffix>
</properties>
</profile>
<profile>
<id>j21</id>
<properties>
<oh.java.version>21</oh.java.version>
<maven.compiler.release>${oh.java.version}</maven.compiler.release>
</properties>
</profile>
</profiles>

</project>

0 comments on commit 11e9d6b

Please sign in to comment.