Skip to content

Commit

Permalink
chore: upgrade to Java 21 and Gradle 8.5 #405
Browse files Browse the repository at this point in the history
  • Loading branch information
fengelniederhammer committed Dec 6, 2023
1 parent 3091158 commit 015e493
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 36 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/lapis2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
-
uses: actions/checkout@v4
-
name: Set up JDK 19
name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '19'
java-version: '21'
distribution: 'adopt'
-
name: Execute Tests
Expand All @@ -39,10 +39,10 @@ jobs:
-
uses: actions/checkout@v4
-
name: Set up JDK 19
name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '19'
java-version: '21'
distribution: 'adopt'
-
name: Login to GitHub Container Registry
Expand Down Expand Up @@ -90,10 +90,10 @@ jobs:
-
uses: actions/checkout@v4
-
name: Set up JDK 19
name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '19'
java-version: '21'
distribution: 'adopt'
-
name: Setup Node.js
Expand Down
23 changes: 13 additions & 10 deletions lapis2/build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id 'org.springframework.boot' version '3.1.5'
id 'org.springframework.boot' version '3.2.0'
id 'io.spring.dependency-management' version '1.1.4'
id 'org.jetbrains.kotlin.jvm' version '1.9.20'
id 'org.jetbrains.kotlin.plugin.spring' version '1.9.20'
id 'org.jetbrains.kotlin.jvm' version '1.9.21'
id 'org.jetbrains.kotlin.plugin.spring' version '1.9.21'
id 'org.jlleitschuh.gradle.ktlint' version "11.6.1"
id 'org.springdoc.openapi-gradle-plugin' version "1.8.0"
id 'antlr'
}

group = 'org.genspectrum'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '19'

java {
sourceCompatibility = '21'
targetCompatibility = '21'
}

kotlin {
jvmToolchain(21)
}

repositories {
mavenCentral()
Expand Down Expand Up @@ -43,10 +50,6 @@ dependencies {

compileKotlin {
dependsOn generateGrammarSource
compilerOptions {
freeCompilerArgs.add("-Xexport-kdoc")
jvmTarget.set(JvmTarget.JVM_19)
}
}

tasks.named('runKtlintCheckOverMainSourceSet') {
Expand All @@ -69,7 +72,7 @@ tasks.named('test') {
}

tasks.named('bootBuildImage') {
environment["BP_JVM_VERSION"] = "20"
environment["BP_JVM_VERSION"] = "21"
environment["BPE_SPRING_PROFILES_ACTIVE"] = "docker"
environment["BPE_LAPIS_REFERENCE_GENOME_FILENAME"] = "./reference_genomes.json"
imageName = "ghcr.io/genspectrum/${project.name}"
Expand Down
Binary file modified lapis2/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions lapis2/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
12 changes: 4 additions & 8 deletions lapis2/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,11 +80,11 @@ do
esac
done

# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
APP_BASE_NAME=${0##*/}

# 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"'

Expand Down Expand Up @@ -143,16 +143,12 @@ fi
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
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
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down
1 change: 0 additions & 1 deletion lapis2/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.genspectrum.lapis.controller
import mu.KotlinLogging
import org.genspectrum.lapis.model.SiloNotImplementedError
import org.genspectrum.lapis.silo.SiloException
import org.springframework.core.annotation.Order
import org.springframework.http.HttpStatus
import org.springframework.http.HttpStatusCode
import org.springframework.http.MediaType
Expand All @@ -12,11 +13,32 @@ import org.springframework.web.bind.annotation.ControllerAdvice
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.ResponseStatus
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
import org.springframework.web.servlet.resource.NoResourceFoundException

private val log = KotlinLogging.logger {}

private typealias ErrorResponse = ResponseEntity<LapisErrorResponse>

/**
* Taken from https://github.com/spring-projects/spring-framework/issues/31569#issuecomment-1825444419
* Due to https://github.com/spring-projects/spring-framework/commit/c00508d6cf2408d06a0447ed193ad96466d0d7b4
*
* This forwards "404" errors to the ErrorController to allow it to return a view.
* Thus, browsers get their own error page.
*
* Spring reworked handling of "404 not found" errors. This was introduced with the upgrade to Spring boot 3.2.0.
* This can be removed/reworked once Spring decides on how to return a view from an ExceptionHandler
* or allows them to respect the Accept header.
*/
@ControllerAdvice
@Order(-1)
internal class ExceptionToErrorControllerBypass {
@ExceptionHandler(NoResourceFoundException::class)
fun handleResourceNotFound(e: Exception): Nothing {
throw e
}
}

@ControllerAdvice
class ExceptionHandler : ResponseEntityExceptionHandler() {
@ExceptionHandler(Throwable::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@ import org.springframework.stereotype.Component

@Component
class StatisticsLogObjectMapper(objectMapperBuilder: Jackson2ObjectMapperBuilder) {
private val mapper: ObjectMapper

init {
mapper = objectMapperBuilder.build()
mapper.registerModule(JavaTimeModule())
mapper.registerModule(kotlinModule())
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false)
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
private val mapper = objectMapperBuilder.build<ObjectMapper>().apply {
registerModule(JavaTimeModule())
registerModule(kotlinModule())
configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false)
configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
setSerializationInclusion(JsonInclude.Include.NON_NULL)
}

fun writeValueAsString(requestContext: RequestContext): String {
Expand Down

0 comments on commit 015e493

Please sign in to comment.