Skip to content

Commit cb6324d

Browse files
committed
Transition to spring boot 4
some deprecations here and there
1 parent 22de173 commit cb6324d

16 files changed

Lines changed: 65 additions & 68 deletions

server/Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
FROM gradle:9.0.0-jdk21-alpine AS build
1+
FROM gradle:9.2.1-jdk25-alpine AS build
22
COPY --chown=gradle:gradle . /home/gradle/src
33
WORKDIR /home/gradle/src
4-
RUN gradle build -x test
5-
RUN ls -la /home/gradle/src/build/libs
4+
RUN gradle build
65

7-
FROM eclipse-temurin:21.0.7_6-jre-alpine-3.21
6+
FROM eclipse-temurin:25.0.1_8-jre-alpine-3.23
87
EXPOSE 8010:8080
98
COPY --link --from=build /home/gradle/src/build/libs/galahad.jar /home/gradle/src/application.properties ./
109
ENTRYPOINT ["java", "-Xms4g", "-Xmx8g", "-Dspring.profiles.active=prod", "-jar","galahad.jar"]

server/build.gradle.kts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
plugins {
2-
kotlin("jvm") version "2.2.10"
3-
kotlin("plugin.spring") version "2.2.10"
4-
id("org.springframework.boot") version "3.5.5"
2+
kotlin("jvm") version "2.3.0"
3+
kotlin("plugin.spring") version "2.3.0"
4+
id("org.springframework.boot") version "4.0.1"
55
id("io.spring.dependency-management") version "1.1.7"
66
}
77

88
group = "org.ivdnt"
99

1010
kotlin {
11-
jvmToolchain(21)
11+
jvmToolchain(25)
1212
}
1313

1414
repositories {
@@ -20,31 +20,32 @@ dependencies {
2020
// Spring
2121
// Versions controlled by Spring Boot plugin
2222
implementation("org.springframework.boot:spring-boot-starter-web")
23-
implementation("org.springframework.boot:spring-boot-devtools")
24-
testImplementation("org.springframework.boot:spring-boot-starter-test")
23+
developmentOnly("org.springframework.boot:spring-boot-devtools")
24+
// testImplementation("org.springframework.boot:spring-boot-starter-test")
25+
testImplementation("org.springframework.boot:spring-boot-starter-webmvc-test")
2526

2627
// kotlin
2728
// Versions controlled by Kotlin jvm plugin
2829
implementation("org.jetbrains.kotlin:kotlin-reflect")
2930
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
3031

3132
// swagger
32-
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.11")
33+
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:3.0.1")
3334

3435
// logging
3536
implementation("org.apache.logging.log4j:log4j-api-kotlin:1.5.0")
3637

3738
// yaml
38-
implementation("org.yaml:snakeyaml:2.4")
39+
implementation("org.yaml:snakeyaml:2.5")
3940

4041
// json
4142
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
4243

4344
// xml
44-
implementation("com.fasterxml:aalto-xml:1.3.3")
45+
implementation("com.fasterxml:aalto-xml:1.3.4")
4546

4647
// cache
47-
implementation("com.github.ben-manes.caffeine:caffeine:3.2.2")
48+
implementation("com.github.ben-manes.caffeine:caffeine:3.2.3")
4849

4950
// reading microsoft word docx
5051
implementation("org.apache.poi:poi-ooxml:5.4.1")

server/gradlew

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/gradlew.bat

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/src/main/kotlin/org/ivdnt/galahad/app/Galahad.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import org.springframework.boot.autoconfigure.SpringBootApplication
1212
import org.springframework.boot.context.properties.ConfigurationProperties
1313
import org.springframework.boot.runApplication
1414
import org.springframework.context.annotation.Bean
15-
import org.springframework.context.annotation.ComponentScan
1615
import org.springframework.context.annotation.Configuration
1716
import org.springframework.core.convert.converter.Converter
1817
import org.springframework.scheduling.annotation.EnableScheduling
1918
import java.io.File
2019
import java.util.*
20+
import java.util.logging.Logger
2121

2222
var application_profile: String = System.getenv("spring.profiles.active") ?: "prod"
2323

@@ -28,7 +28,6 @@ fun main(args: Array<String>) {
2828

2929
@Configuration
3030
@ConfigurationProperties(prefix = "")
31-
@EnableScheduling
3231
class Config {
3332
lateinit var workDir: String
3433

@@ -41,8 +40,8 @@ class Config {
4140
}
4241
}
4342

44-
@ComponentScan("org.ivdnt.galahad")
45-
@SpringBootApplication
43+
@SpringBootApplication(scanBasePackages = ["org.ivdnt.galahad"])
44+
@EnableScheduling
4645
class Galahad {
4746
/** Customize OpenAPI documentation header. */
4847
@Bean

server/src/main/kotlin/org/ivdnt/galahad/web/controller/ErrorController.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import jakarta.servlet.http.HttpServletResponse
66
import org.apache.logging.log4j.kotlin.Logging
77
import org.ivdnt.galahad.exceptions.ErrorResponse
88
import org.springframework.beans.factory.annotation.Autowired
9-
import org.springframework.boot.web.servlet.error.ErrorController
9+
import org.springframework.boot.webmvc.error.ErrorController
1010
import org.springframework.http.HttpStatus
1111
import org.springframework.web.bind.annotation.CrossOrigin
12+
import org.springframework.web.bind.annotation.ExceptionHandler
1213
import org.springframework.web.bind.annotation.RequestMapping
1314
import org.springframework.web.bind.annotation.RestController
1415

@@ -17,10 +18,13 @@ class ErrorController : ErrorController, Logging {
1718
@Autowired
1819
private val response: HttpServletResponse? = null
1920

21+
2022
@RequestMapping("/error")
2123
@Hidden
2224
@CrossOrigin
25+
@ExceptionHandler
2326
fun handleError(request: HttpServletRequest): ErrorResponse {
27+
2428
// Get the default status code (probably 500), or override it with the actual status code if it is a RESTException.
2529
var statusCode = HttpStatus.valueOf(request.getAttribute("jakarta.servlet.error.status_code") as Int? ?: 500)
2630
val jakartaException = request.getAttribute("jakarta.servlet.error.exception") as Exception?

server/src/main/kotlin/org/ivdnt/galahad/web/service/DocumentsService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class DocumentsService(val corpora: CorporaService) : Logging {
5858
uploadZipFile(file, corpus)
5959
} else {
6060
createDocumentWithSourceLayer(
61-
corpus, file.originalFilename, file.inputStream
61+
corpus, file.originalFilename!!, file.inputStream
6262
)
6363
}
6464
}

server/src/test/kotlin/org/ivdnt/galahad/evaluation/assays/BenchmarksControllerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import org.ivdnt.galahad.util.TestUtil
1111
import org.junit.jupiter.api.Assertions.*
1212
import org.junit.jupiter.api.Test
1313
import org.springframework.beans.factory.annotation.Autowired
14-
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
14+
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest
1515
import org.springframework.test.context.ContextConfiguration
1616
import org.springframework.test.web.servlet.MockMvc
1717
import org.springframework.test.web.servlet.MvcResult

server/src/test/kotlin/org/ivdnt/galahad/taggers/TaggerStoreControllerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import org.junit.jupiter.api.Assertions.*
88
import org.junit.jupiter.api.Test
99
import org.junit.jupiter.api.assertThrows
1010
import org.springframework.beans.factory.annotation.Autowired
11-
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
11+
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest
1212
import org.springframework.test.context.ContextConfiguration
1313

1414
@WebMvcTest(properties = ["spring.main.allow-bean-definition-overriding=true"])
Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,32 @@
1-
package com.myproject.config
2-
3-
import com.fasterxml.jackson.annotation.JsonInclude
4-
import com.fasterxml.jackson.databind.ObjectMapper
5-
import com.fasterxml.jackson.databind.PropertyNamingStrategy
6-
import org.springframework.context.annotation.Bean
7-
import org.springframework.context.annotation.Configuration
8-
import org.springframework.http.converter.HttpMessageConverter
9-
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder
10-
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
11-
import org.springframework.web.servlet.config.annotation.EnableWebMvc
12-
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport
13-
14-
@Configuration
15-
@EnableWebMvc
16-
class WebConfig : WebMvcConfigurationSupport() {
17-
public override fun configureMessageConverters(converters: MutableList<HttpMessageConverter<*>?>) {
18-
converters.add(jackson2HttpMessageConverter())
19-
}
20-
21-
@Bean
22-
fun jackson2HttpMessageConverter(): MappingJackson2HttpMessageConverter {
23-
val converter = MappingJackson2HttpMessageConverter()
24-
val builder = this.jacksonBuilder()
25-
converter.setObjectMapper(builder.build())
26-
return converter
27-
}
28-
29-
fun jacksonBuilder(): Jackson2ObjectMapperBuilder {
30-
val builder = Jackson2ObjectMapperBuilder()
31-
builder.serializationInclusion(JsonInclude.Include.NON_NULL)
32-
return builder
33-
}
34-
}
1+
//package org.ivdnt.galahad.util
2+
//
3+
//import com.fasterxml.jackson.annotation.JsonInclude
4+
//import org.springframework.context.annotation.Bean
5+
//import org.springframework.context.annotation.Configuration
6+
//import org.springframework.http.converter.HttpMessageConverter
7+
//import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder
8+
//import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
9+
//import org.springframework.web.servlet.config.annotation.EnableWebMvc
10+
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport
11+
//
12+
//@Configuration
13+
//@EnableWebMvc
14+
//class WebConfig : WebMvcConfigurationSupport() {
15+
// public override fun configureMessageConverters(converters: MutableList<HttpMessageConverter<*>?>) {
16+
// converters.add(jackson2HttpMessageConverter())
17+
// }
18+
//
19+
// @Bean
20+
// fun jackson2HttpMessageConverter(): MappingJackson2HttpMessageConverter {
21+
// val converter = MappingJackson2HttpMessageConverter()
22+
// val builder = this.jacksonBuilder()
23+
// converter.setObjectMapper(builder.build())
24+
// return converter
25+
// }
26+
//
27+
// fun jacksonBuilder(): Jackson2ObjectMapperBuilder {
28+
// val builder = Jackson2ObjectMapperBuilder()
29+
// builder.serializationInclusion(JsonInclude.Include.NON_NULL)
30+
// return builder
31+
// }
32+
//}

0 commit comments

Comments
 (0)