From e824bef1262927e81cf429347cc1f27f323a7b9d Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Wed, 29 Jul 2020 20:20:04 +0800 Subject: [PATCH] build: migration to Spring Boot 2.3.2 --- komga/Dockerfile | 9 +++-- komga/build.gradle.kts | 37 ++++++++++--------- .../datasource/DataSourcesConfiguration.kt | 8 +++- .../komga/infrastructure/jms/ArtemisConfig.kt | 5 +-- komga/src/main/resources/application.yml | 1 + 5 files changed, 34 insertions(+), 26 deletions(-) diff --git a/komga/Dockerfile b/komga/Dockerfile index 14af0227..e2d827e2 100644 --- a/komga/Dockerfile +++ b/komga/Dockerfile @@ -1,13 +1,14 @@ FROM adoptopenjdk:11-jre-hotspot VOLUME /tmp ARG DEPENDENCY=build/dependency -COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib -COPY ${DEPENDENCY}/META-INF /app/META-INF -COPY ${DEPENDENCY}/BOOT-INF/classes /app +COPY ${DEPENDENCY}/dependencies/ /app/ +COPY ${DEPENDENCY}/spring-boot-loader/ /app/ +COPY ${DEPENDENCY}/snapshot-dependencies/ /app/ +COPY ${DEPENDENCY}/application/ /app/ ENV KOMGA_DATABASE_BACKUP_PATH="/config/database-backup.zip" ENV KOMGA_DATABASE_FILE="/config/database.sqlite" ENV SPRING_DATASOURCE_URL="jdbc:h2:/config/database.h2" ENV SPRING_ARTEMIS_EMBEDDED_DATA_DIRECTORY="/config/artemis" ENV LOGGING_FILE_NAME="/config/logs/komga.log" -ENTRYPOINT ["java","-cp","app:app/lib/*","org.gotson.komga.ApplicationKt"] +ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"] EXPOSE 8080 diff --git a/komga/build.gradle.kts b/komga/build.gradle.kts index 27987dc6..de24a9b5 100644 --- a/komga/build.gradle.kts +++ b/komga/build.gradle.kts @@ -6,6 +6,7 @@ import com.rohanprabhu.gradle.plugins.kdjooq.jooqCodegenConfiguration import com.rohanprabhu.gradle.plugins.kdjooq.target import org.apache.tools.ant.taskdefs.condition.Os import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.springframework.boot.gradle.tasks.bundling.BootJar plugins { @@ -15,11 +16,11 @@ plugins { kotlin("plugin.spring") version kotlinVersion kotlin("kapt") version kotlinVersion } - id("org.springframework.boot") version "2.2.6.RELEASE" + id("org.springframework.boot") version "2.3.2.RELEASE" id("com.github.ben-manes.versions") version "0.28.0" id("com.gorylenko.gradle-git-properties") version "2.2.2" id("com.rohanprabhu.kotlin-dsl-jooq") version "0.4.5" - id("org.flywaydb.flyway") version "6.4.0" + id("org.flywaydb.flyway") version "6.4.4" id("com.github.johnrengelman.processes") version "0.5.0" id("org.springdoc.openapi-gradle-plugin") version "1.3.0" jacoco @@ -27,9 +28,6 @@ plugins { group = "org.gotson" -val developmentOnly = configurations.create("developmentOnly") -configurations.runtimeClasspath.get().extendsFrom(developmentOnly) - repositories { jcenter() mavenCentral() @@ -39,15 +37,10 @@ dependencies { implementation(kotlin("stdlib-jdk8")) implementation(kotlin("reflect")) - constraints { - implementation("org.flywaydb:flyway-core:6.4.0") { - because("support for H2 1.4.200 requires 6.1.0+") - } - } - - implementation(platform("org.springframework.boot:spring-boot-dependencies:2.2.6.RELEASE")) + implementation(platform("org.springframework.boot:spring-boot-dependencies:2.3.2.RELEASE")) implementation("org.springframework.boot:spring-boot-starter-web") + implementation("org.springframework.boot:spring-boot-starter-validation") implementation("org.springframework.boot:spring-boot-starter-data-jdbc") implementation("org.springframework.boot:spring-boot-starter-actuator") implementation("org.springframework.boot:spring-boot-starter-security") @@ -55,7 +48,7 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-artemis") implementation("org.springframework.boot:spring-boot-starter-jooq") - kapt("org.springframework.boot:spring-boot-configuration-processor:2.2.6.RELEASE") + kapt("org.springframework.boot:spring-boot-configuration-processor:2.3.2.RELEASE") implementation("org.apache.activemq:artemis-jms-server") @@ -63,7 +56,7 @@ dependencies { implementation("io.github.microutils:kotlin-logging:1.7.9") implementation("io.micrometer:micrometer-registry-influx") - implementation("io.hawt:hawtio-springboot:2.10.0") + implementation("io.hawt:hawtio-springboot:2.10.1") run { val springdocVersion = "1.3.4" @@ -110,7 +103,7 @@ dependencies { testImplementation("com.tngtech.archunit:archunit-junit5:0.13.1") - developmentOnly("org.springframework.boot:spring-boot-devtools") + developmentOnly("org.springframework.boot:spring-boot-devtools:2.3.2.RELEASE") } val webui = "$rootDir/komga-webui" @@ -122,6 +115,10 @@ tasks { } } + withType { + layered() + } + withType { useJUnitPlatform() systemProperty("spring.profiles.active", "test") @@ -134,10 +131,14 @@ tasks { } //unpack Spring Boot's fat jar for better Docker image layering - register("unpack") { + register("unpack") { dependsOn(bootJar) - from(zipTree(getByName("bootJar").outputs.files.singleFile)) - into("$buildDir/dependency") + classpath = files(jar) + jvmArgs = listOf("-Djarmode=layertools") + args = "extract --destination $buildDir/dependency".split(" ") + doFirst { + delete("$buildDir/dependency") + } } register("npmInstall") { diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/datasource/DataSourcesConfiguration.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/datasource/DataSourcesConfiguration.kt index c12f53f5..38c2fa04 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/datasource/DataSourcesConfiguration.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/datasource/DataSourcesConfiguration.kt @@ -8,12 +8,16 @@ import org.springframework.boot.jdbc.DataSourceBuilder import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Primary +import org.springframework.data.jdbc.repository.config.AbstractJdbcConfiguration +import org.springframework.data.relational.core.dialect.Dialect +import org.springframework.data.relational.core.dialect.H2Dialect +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations import javax.sql.DataSource @Configuration class DataSourcesConfiguration( private val komgaProperties: KomgaProperties -) { +) : AbstractJdbcConfiguration() { @Bean("sqliteDataSource") @Primary @@ -35,4 +39,6 @@ class DataSourcesConfiguration( fun h2DataSource(): DataSource = h2DataSourceProperties().initializeDataSourceBuilder().type(HikariDataSource::class.java).build() + @Bean + override fun jdbcDialect(operations: NamedParameterJdbcOperations): Dialect = H2Dialect.INSTANCE } diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jms/ArtemisConfig.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jms/ArtemisConfig.kt index af4e7216..3e39bbbc 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jms/ArtemisConfig.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jms/ArtemisConfig.kt @@ -1,7 +1,7 @@ package org.gotson.komga.infrastructure.jms +import org.apache.activemq.artemis.api.core.QueueConfiguration import org.apache.activemq.artemis.api.core.RoutingType -import org.apache.activemq.artemis.core.config.CoreQueueConfiguration import org.apache.activemq.artemis.core.settings.impl.AddressSettings import org.springframework.boot.autoconfigure.jms.artemis.ArtemisConfigurationCustomizer import org.springframework.context.annotation.Configuration @@ -24,9 +24,8 @@ class ArtemisConfig : ArtemisConfigurationCustomizer { defaultConsumerWindowSize = 0 }) it.addQueueConfiguration( - CoreQueueConfiguration() + QueueConfiguration(QUEUE_TASKS) .setAddress(QUEUE_TASKS) - .setName(QUEUE_TASKS) .setLastValueKey(QUEUE_UNIQUE_ID) .setRoutingType(RoutingType.ANYCAST) ) diff --git a/komga/src/main/resources/application.yml b/komga/src/main/resources/application.yml index 424fb95e..a2103a3a 100644 --- a/komga/src/main/resources/application.yml +++ b/komga/src/main/resources/application.yml @@ -41,6 +41,7 @@ spring: server: servlet.session.timeout: 7d forward-headers-strategy: framework + shutdown: graceful management: endpoints.web.exposure.include: "*"