feat: SpringBootで起動できるように

This commit is contained in:
usbharu 2023-08-18 12:01:32 +09:00
parent ad65094c3e
commit 60706ee413
4 changed files with 32 additions and 4 deletions

View File

@ -1,4 +1,5 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
val ktor_version: String by project
val kotlin_version: String by project
@ -13,13 +14,19 @@ plugins {
id("org.graalvm.buildtools.native") version "0.9.21"
id("io.gitlab.arturbosch.detekt") version "1.22.0"
id("com.google.devtools.ksp") version "1.8.21-1.0.11"
id("org.springframework.boot") version "3.1.2"
kotlin("plugin.spring") version "1.8.21"
// id("org.jetbrains.kotlin.plugin.serialization") version "1.8.10"
}
apply {
plugin("io.spring.dependency-management")
}
group = "dev.usbharu"
version = "0.0.1"
application {
mainClass.set("io.ktor.server.cio.EngineMain")
mainClass.set("dev.usbharu.hideout.SpringApplicationKt")
val isDevelopment: Boolean = project.ext.has("development")
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=$isDevelopment")
@ -34,6 +41,12 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask<*>>().con
compilerOptions.apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_8)
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
}
}
tasks.withType<ShadowJar> {
manifest {
attributes(
@ -53,7 +66,7 @@ repositories {
kotlin {
target {
compilations.all {
kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()
kotlinOptions.jvmTarget = JavaVersion.VERSION_17.toString()
}
}
}
@ -90,6 +103,9 @@ dependencies {
implementation("io.ktor:ktor-server-compression-jvm:2.3.0")
ksp("io.insert-koin:koin-ksp-compiler:1.2.0")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("io.ktor:ktor-client-logging-jvm:$ktor_version")
implementation("io.ktor:ktor-server-host-common-jvm:$ktor_version")

View File

@ -4,7 +4,7 @@ logback_version=1.4.6
kotlin.code.style=official
exposed_version=0.41.1
h2_version=2.1.214
koin_version=3.3.1
koin_version=3.4.3
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.caching=true

View File

@ -0,0 +1,12 @@
package dev.usbharu.hideout
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
@SpringBootApplication
class SpringApplication
fun main(args: Array<String>) {
runApplication<SpringApplication>(*args)
}

View File

@ -4,7 +4,7 @@
<pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="TRACE">
<root level="INFO">
<appender-ref ref="STDOUT"/>
</root>
<logger name="org.eclipse.jetty" level="INFO"/>