Skip to content

Commit

Permalink
Build for Java 21
Browse files Browse the repository at this point in the history
  • Loading branch information
marianobarrios committed Nov 3, 2023
1 parent 38a0e63 commit 72f11b8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java-version: [ 8, 11, 17, 20 ]
java-version: [ 8, 11, 17, 21 ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ matrix.java-version }}
- run: ./gradlew assemble check --info
java-version: |
${{ matrix.java-version }}
21
- run: ./gradlew assemble check --info
env:
JAVA_TOOLCHAIN: ${{ matrix.java-version }}
30 changes: 15 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@ plugins {
id 'scala'
id 'signing'
id 'maven-publish'
// pinned version due to Java 8 compatibility
id "com.diffplug.spotless" version "6.11.0"
// pinned version due to https://github.com/spotbugs/spotbugs/issues/2041
id "com.github.spotbugs" version "5.0.13"
id "com.diffplug.spotless" version "6.22.0"
id "com.github.spotbugs" version "5.2.1"
}

var javaToolchain = System.getenv('JAVA_TOOLCHAIN')

java {
if (javaToolchain != null) {
toolchain {
languageVersion = JavaLanguageVersion.of(javaToolchain)
}
}
}

compileJava {
Expand Down Expand Up @@ -39,20 +47,14 @@ dependencies {

spotless {
java {
palantirJavaFormat()
// remove when spotless moved to this Palantir version
palantirJavaFormat("2.38.0")
}
scala {
scalafmt('3.7.1').configFile('.scalafmt.conf')
}
}

// There are some compatibility issues with spotless older Java versions,
// but we don't need to cross-do style checks anyway
if (JavaVersion.current().ordinal() < JavaVersion.VERSION_17.ordinal()) {
tasks.findByName("spotlessScala").enabled(false)
tasks.findByName("spotlessJava").enabled(false)
}

spotbugs {
ignoreFailures = false
showProgress = true
Expand Down Expand Up @@ -113,9 +115,7 @@ task allocationTest(type: JavaExec) {
jvmArgs = ['-XX:+UnlockExperimentalVMOptions', '-XX:+UseEpsilonGC']
}

if (JavaVersion.current().ordinal() >= JavaVersion.VERSION_11.ordinal()) {
check.dependsOn allocationTest
}
check.dependsOn allocationTest

publishing {
publications {
Expand Down
14 changes: 14 additions & 0 deletions src/test/scala/tlschannel/TestLogger.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package tlschannel;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;

@TestInstance(Lifecycle.PER_CLASS)
public class TestLogger {

@Test
public void logJdk() {
System.out.println("java.version: " + System.getProperty("java.version"));
}
}

0 comments on commit 72f11b8

Please sign in to comment.