Skip to content

Commit

Permalink
Merge pull request #145 from openbase/feature/updateToJava21
Browse files Browse the repository at this point in the history
Update to Java 21 & Replace deprecated getBuildDir
  • Loading branch information
DivineThreepwood authored Aug 10, 2024
2 parents 956490d + 7712936 commit 790b607
Show file tree
Hide file tree
Showing 16 changed files with 140 additions and 82 deletions.
32 changes: 17 additions & 15 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:

steps:
- name: "Checkout Branch"
uses: actions/checkout@v3
uses: actions/checkout@v4

### Checks if there are any file changes that are not in the .github/ or doc/ directories
### Checks if there are any file changes that are not in the .github/ or doc/ directories. Only then will the build and test pipeline run.
- name: "Check for changes outside CI and docs"
id: check
env:
Expand All @@ -32,7 +32,7 @@ jobs:
changesOutsideDocsCI=false
for file in $changed_files; do
if [[ $file -ne ".github/"* && $file -ne "doc/"* ]]; then
if [[ $file != .github/* && $file != doc/* ]]; then
echo "file: $file is not part of CI or docs"
echo "Start testing pipeline."
changesOutsideDocsCI=true
Expand All @@ -43,6 +43,7 @@ jobs:
done
if [[ $changesOutsideDocsCI == true ]]; then
echo "testing_needed=true" >> "$GITHUB_OUTPUT"
echo "Changes outside CI and docs detected. Start testing pipeline."
else
echo "testing_needed=false" >> "$GITHUB_OUTPUT"
echo "No need for the build and test pipeline to run. Exiting."
Expand All @@ -55,23 +56,23 @@ jobs:
needs: check
if: |
(github.event.pull_request.draft == false)
&& (needs.check.outputs.worth_testing == true)
&& (needs.check.outputs.testing_needed == 'true')
runs-on: ubuntu-latest

steps:
- name: "Checkout Branch"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "Setup Java"
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
java-version: 21
cache: 'gradle'

- name: Setup Gradle cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('versions.properties') }}-${{ github.sha }}
Expand All @@ -83,35 +84,36 @@ jobs:
run: ./gradlew --build-cache build -x test

- name: Upload build reports
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: ${{ failure() || contains(github.event.pull_request.labels.*.name, 'force reports') }}
with:
name: Build Reports
path: "**/build/reports"


test:
name: "Test"
timeout-minutes: 120
needs: build
if: |
(github.event.pull_request.draft == false)
&& (needs.check.outputs.testing_needed == true)
&& (needs.check.outputs.testing_needed == 'true')
runs-on: ubuntu-latest

steps:
- name: "Checkout Branch"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "Setup Java"
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
java-version: 21
cache: 'gradle'

- name: Setup Gradle cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('versions.properties') }}-${{ github.sha }}
Expand All @@ -123,7 +125,7 @@ jobs:
run: ./gradlew --build-cache check

- name: Upload test reports
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: ${{ failure() || contains(github.event.pull_request.labels.*.name, 'force reports') }}
with:
name: Test Reports
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/deploy-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
-
name: Docker bco meta
id: bco-meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
Expand All @@ -43,26 +43,26 @@ jobs:
type=sha
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3
-
name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to GHCR
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push bco
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile
Expand All @@ -75,7 +75,7 @@ jobs:
-
name: Docker bco device meta
id: bco-device-meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
Expand All @@ -92,11 +92,11 @@ jobs:
type=semver,pattern={{major}}
type=sha
-
uses: benjlevesque/short-sha@v1.2
uses: benjlevesque/short-sha@v3.0
id: short-sha
-
name: Build and push bco device manager
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: ./docker/device-manager/openhab
build-args: |
Expand All @@ -109,7 +109,7 @@ jobs:
-
name: Docker bco demo meta
id: bco-demo-meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
Expand All @@ -127,7 +127,7 @@ jobs:
type=sha
-
name: Build and push bco demo
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: ./docker/bco-demo
build-args: |
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/publish-jars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@ jobs:
packages: write
steps:
- name: "Checkout Branch"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "Setup Java"
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
java-version: 21
cache: 'gradle'

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Publish Packages

uses: gradle/gradle-build-action@v2
with:
arguments: publishToSonatype closeAndReleaseSonatypeStagingRepository
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ nexusPublishing {

tasks.withType(KotlinCompile::class).all {
kotlinOptions {
jvmTarget = "17"
jvmTarget = "21"
}
}
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ dependencies {

tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "17"
jvmTarget = "21"
}
}
10 changes: 5 additions & 5 deletions buildSrc/src/main/kotlin/org.openbase.bco.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ group = "org.openbase"
val releaseVersion = !version.toString().endsWith("-SNAPSHOT")

java {
sourceCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = sourceCompatibility
withSourcesJar()
withJavadocJar()
}

dependencies {
implementation("org.jetbrains.kotlin:kotlin-reflect:1.9.20")
api("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.20")
implementation("org.jetbrains.kotlin:kotlin-script-runtime:1.9.20")
implementation("org.jetbrains.kotlin:kotlin-reflect:2.0.0")
api("org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.0")
implementation("org.jetbrains.kotlin:kotlin-script-runtime:2.0.0")
testImplementation("org.junit.jupiter:junit-jupiter:[5.8,5.9-alpha)")
testImplementation("org.junit.jupiter:junit-jupiter-api:[5.8,5.9-alpha)")
testImplementation(Testing.mockK)
Expand All @@ -45,7 +45,7 @@ dependencies {
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "17"
jvmTarget = "21"
}
}

Expand Down
2 changes: 1 addition & 1 deletion doc/docs/developer/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sidebar_position: 1

## Requirements

* Java JDK 17
* Java JDK 21
* Git
* Docker

Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Install dependencies
FROM eclipse-temurin:17-jdk AS builder
FROM eclipse-temurin:21-jdk AS builder

ENV \
JAVA_OPTS="" \
Expand Down Expand Up @@ -38,7 +38,7 @@ RUN cd lib/jul && \
RUN ./gradlew :bco.app.util:installDist -x test -x javadoc --no-daemon --stacktrace

# Switch to baseline image
FROM eclipse-temurin:17-jre
FROM eclipse-temurin:21-jre

# # Install app
COPY --from=builder /workspace/module/app/util/build/install/bco/bin /usr/bin/
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
17 changes: 9 additions & 8 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -144,15 +145,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -201,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
Loading

0 comments on commit 790b607

Please sign in to comment.