Skip to content

Commit

Permalink
Use "release" option to fix Java 8 binary compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
marianobarrios committed Jul 6, 2024
1 parent 8263cd5 commit 1b3f183
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
# The target JDK is used to build, the latest one to run Gradle itself
java-version: |
${{ matrix.java-version }}
21
Expand Down
11 changes: 7 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
var javaToolchain = System.getenv('JAVA_TOOLCHAIN')

java {
// If running from CI, the tool chain will be present
if (javaToolchain != null) {
toolchain {
languageVersion = JavaLanguageVersion.of(javaToolchain)
Expand All @@ -17,14 +18,16 @@ java {
}

compileJava {
sourceCompatibility = '8'
targetCompatibility = '8'
if (JavaVersion.current().getMajorVersion() >= JavaVersion.VERSION_1_9.getMajorVersion()) {
options.release = 8
}
options.compilerArgs.add('-Xlint')
}

compileTestJava {
sourceCompatibility = '8'
targetCompatibility = '8'
if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
options.release = 8
}
options.compilerArgs.add('-Xlint')
}

Expand Down

0 comments on commit 1b3f183

Please sign in to comment.