Skip to content

Commit

Permalink
Allow for compiling with Java 21
Browse files Browse the repository at this point in the history
* 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 committed Mar 31, 2024
1 parent d39aa87 commit 6c57b39
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 12 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
20 changes: 17 additions & 3 deletions launch/app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
<properties>
<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>
<bnd.version>7.0.0</bnd.version>
</properties>

Expand Down Expand Up @@ -383,6 +380,23 @@
</pluginManagement>
</build>
</profile>
<profile>
<id>j17</id>
<activation>
<jdk>[17.0,18.0);[21.0,22.0)</jdk>
</activation>
<properties>
<oh.java.version>17</oh.java.version>
<maven.compiler.release>${oh.java.version}</maven.compiler.release>
</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>
25 changes: 19 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@

<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>

<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 @@ -249,7 +245,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 +315,23 @@
<pax.url.suffix></pax.url.suffix>
</properties>
</profile>
<profile>
<id>j17</id>
<activation>
<jdk>[17.0,18.0);[21.0,22.0)</jdk>
</activation>
<properties>
<oh.java.version>17</oh.java.version>
<maven.compiler.release>${oh.java.version}</maven.compiler.release>
</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 6c57b39

Please sign in to comment.