2023-04-30 21:38:30 +00:00
|
|
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
2023-08-18 03:01:32 +00:00
|
|
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
2023-08-18 06:25:42 +00:00
|
|
|
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask
|
2023-04-30 21:38:30 +00:00
|
|
|
|
2023-03-24 03:58:12 +00:00
|
|
|
val ktor_version: String by project
|
|
|
|
val kotlin_version: String by project
|
|
|
|
val logback_version: String by project
|
|
|
|
val exposed_version: String by project
|
|
|
|
val h2_version: String by project
|
|
|
|
val koin_version: String by project
|
|
|
|
|
|
|
|
plugins {
|
2023-04-29 13:40:22 +00:00
|
|
|
kotlin("jvm") version "1.8.21"
|
|
|
|
id("io.ktor.plugin") version "2.3.0"
|
2023-04-22 02:20:11 +00:00
|
|
|
id("org.graalvm.buildtools.native") version "0.9.21"
|
2023-09-19 07:21:35 +00:00
|
|
|
id("io.gitlab.arturbosch.detekt") version "1.23.1"
|
2023-05-04 02:48:39 +00:00
|
|
|
id("com.google.devtools.ksp") version "1.8.21-1.0.11"
|
2023-08-18 03:01:32 +00:00
|
|
|
id("org.springframework.boot") version "3.1.2"
|
|
|
|
kotlin("plugin.spring") version "1.8.21"
|
2023-09-20 05:53:23 +00:00
|
|
|
id("org.openapi.generator") version "7.0.1"
|
2023-03-24 03:58:12 +00:00
|
|
|
// id("org.jetbrains.kotlin.plugin.serialization") version "1.8.10"
|
|
|
|
}
|
|
|
|
|
2023-08-18 03:01:32 +00:00
|
|
|
apply {
|
|
|
|
plugin("io.spring.dependency-management")
|
|
|
|
}
|
|
|
|
|
2023-03-24 03:58:12 +00:00
|
|
|
group = "dev.usbharu"
|
|
|
|
version = "0.0.1"
|
|
|
|
application {
|
2023-08-18 03:01:32 +00:00
|
|
|
mainClass.set("dev.usbharu.hideout.SpringApplicationKt")
|
2023-03-24 03:58:12 +00:00
|
|
|
|
|
|
|
val isDevelopment: Boolean = project.ext.has("development")
|
|
|
|
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=$isDevelopment")
|
|
|
|
}
|
|
|
|
|
2023-03-30 11:55:12 +00:00
|
|
|
tasks.withType<Test> {
|
|
|
|
useJUnitPlatform()
|
|
|
|
}
|
|
|
|
|
2023-04-29 13:40:22 +00:00
|
|
|
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask<*>>().configureEach {
|
|
|
|
compilerOptions.languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_8)
|
|
|
|
compilerOptions.apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_8)
|
|
|
|
}
|
|
|
|
|
2023-08-18 03:01:32 +00:00
|
|
|
tasks.withType<KotlinCompile> {
|
|
|
|
kotlinOptions {
|
|
|
|
freeCompilerArgs += "-Xjsr305=strict"
|
|
|
|
}
|
2023-09-20 05:53:23 +00:00
|
|
|
dependsOn("openApiGenerateMastodonCompatibleApi")
|
|
|
|
mustRunAfter("openApiGenerateMastodonCompatibleApi")
|
2023-08-18 03:01:32 +00:00
|
|
|
}
|
|
|
|
|
2023-04-30 21:38:30 +00:00
|
|
|
tasks.withType<ShadowJar> {
|
|
|
|
manifest {
|
|
|
|
attributes(
|
|
|
|
"Implementation-Version" to project.version.toString()
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-01 01:48:59 +00:00
|
|
|
tasks.clean {
|
|
|
|
delete += listOf("$rootDir/src/main/resources/static")
|
|
|
|
}
|
|
|
|
|
2023-09-20 05:53:23 +00:00
|
|
|
//tasks.create<GenerateTask>("openApiGenerateServer", GenerateTask::class) {
|
|
|
|
// generatorName.set("kotlin-spring")
|
|
|
|
// inputSpec.set("$rootDir/src/main/resources/openapi/api.yaml")
|
|
|
|
// outputDir.set("$buildDir/generated/sources/openapi")
|
|
|
|
// apiPackage.set("dev.usbharu.hideout.controller.generated")
|
|
|
|
// modelPackage.set("dev.usbharu.hideout.domain.model.generated")
|
|
|
|
// configOptions.put("interfaceOnly", "true")
|
|
|
|
// configOptions.put("useSpringBoot3", "true")
|
|
|
|
// additionalProperties.put("useTags", "true")
|
|
|
|
// schemaMappings.putAll(
|
|
|
|
// mapOf(
|
|
|
|
// "ReactionResponse" to "dev.usbharu.hideout.domain.model.hideout.dto.ReactionResponse",
|
|
|
|
// "Account" to "dev.usbharu.hideout.domain.model.hideout.dto.Account",
|
|
|
|
// "JwtToken" to "dev.usbharu.hideout.domain.model.hideout.dto.JwtToken",
|
|
|
|
// "PostRequest" to "dev.usbharu.hideout.domain.model.hideout.form.Post",
|
|
|
|
// "PostResponse" to "dev.usbharu.hideout.domain.model.hideout.dto.PostResponse",
|
|
|
|
// "Reaction" to "dev.usbharu.hideout.domain.model.hideout.form.Reaction",
|
|
|
|
// "RefreshToken" to "dev.usbharu.hideout.domain.model.hideout.form.RefreshToken",
|
|
|
|
// "UserLogin" to "dev.usbharu.hideout.domain.model.hideout.form.UserLogin",
|
|
|
|
// "UserResponse" to "dev.usbharu.hideout.domain.model.hideout.dto.UserResponse",
|
|
|
|
// "UserCreate" to "dev.usbharu.hideout.domain.model.hideout.form.UserCreate",
|
|
|
|
// "Visibility" to "dev.usbharu.hideout.domain.model.hideout.entity.Visibility",
|
|
|
|
// )
|
|
|
|
// )
|
|
|
|
//
|
|
|
|
//// importMappings.putAll(mapOf("ReactionResponse" to "ReactionResponse"))
|
|
|
|
//// typeMappings.putAll(mapOf("ReactionResponse" to "ReactionResponse"))
|
|
|
|
//}
|
2023-08-18 06:25:42 +00:00
|
|
|
|
2023-09-20 04:55:25 +00:00
|
|
|
tasks.create<GenerateTask>("openApiGenerateMastodonCompatibleApi", GenerateTask::class) {
|
|
|
|
generatorName.set("kotlin-spring")
|
|
|
|
inputSpec.set("$rootDir/src/main/resources/openapi/mastodon.yaml")
|
|
|
|
outputDir.set("$buildDir/generated/sources/mastodon")
|
|
|
|
apiPackage.set("dev.usbharu.hideout.controller.mastodon.generated")
|
|
|
|
modelPackage.set("dev.usbharu.hideout.domain.mastodon.model.generated")
|
|
|
|
configOptions.put("interfaceOnly", "true")
|
|
|
|
configOptions.put("useSpringBoot3", "true")
|
|
|
|
configOptions.put("reactive", "true")
|
|
|
|
additionalProperties.put("useTags", "true")
|
|
|
|
|
|
|
|
// importMappings.putAll(mapOf("ReactionResponse" to "ReactionResponse"))
|
|
|
|
// typeMappings.putAll(mapOf("ReactionResponse" to "ReactionResponse"))
|
|
|
|
}
|
|
|
|
|
2023-03-24 03:58:12 +00:00
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
}
|
|
|
|
|
2023-04-05 07:59:16 +00:00
|
|
|
kotlin {
|
|
|
|
target {
|
|
|
|
compilations.all {
|
2023-08-18 03:01:32 +00:00
|
|
|
kotlinOptions.jvmTarget = JavaVersion.VERSION_17.toString()
|
2023-04-05 07:59:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-04 02:48:39 +00:00
|
|
|
sourceSets.main {
|
2023-09-20 04:55:25 +00:00
|
|
|
kotlin.srcDirs(
|
|
|
|
"$buildDir/generated/ksp/main",
|
|
|
|
"$buildDir/generated/sources/openapi/src/main/kotlin",
|
|
|
|
"$buildDir/generated/sources/mastodon/src/main/kotlin"
|
|
|
|
)
|
2023-05-04 02:48:39 +00:00
|
|
|
}
|
|
|
|
|
2023-03-24 03:58:12 +00:00
|
|
|
dependencies {
|
|
|
|
implementation("io.ktor:ktor-server-core-jvm:$ktor_version")
|
2023-04-30 04:47:59 +00:00
|
|
|
implementation("io.ktor:ktor-server-auth:$ktor_version")
|
|
|
|
implementation("io.ktor:ktor-server-auth-jwt:$ktor_version")
|
2023-03-24 03:58:12 +00:00
|
|
|
implementation("io.ktor:ktor-server-sessions-jvm:$ktor_version")
|
|
|
|
implementation("io.ktor:ktor-server-auto-head-response-jvm:$ktor_version")
|
|
|
|
implementation("io.ktor:ktor-server-cors-jvm:$ktor_version")
|
|
|
|
implementation("io.ktor:ktor-server-default-headers-jvm:$ktor_version")
|
|
|
|
implementation("io.ktor:ktor-server-forwarded-header-jvm:$ktor_version")
|
|
|
|
implementation("io.ktor:ktor-server-call-logging-jvm:$ktor_version")
|
|
|
|
implementation("io.ktor:ktor-server-content-negotiation-jvm:$ktor_version")
|
|
|
|
implementation("io.ktor:ktor-serialization-jackson:$ktor_version")
|
|
|
|
implementation("org.jetbrains.exposed:exposed-core:$exposed_version")
|
|
|
|
implementation("org.jetbrains.exposed:exposed-jdbc:$exposed_version")
|
|
|
|
implementation("com.h2database:h2:$h2_version")
|
|
|
|
implementation("org.xerial:sqlite-jdbc:3.40.1.0")
|
|
|
|
implementation("io.ktor:ktor-server-websockets-jvm:$ktor_version")
|
2023-04-22 00:13:53 +00:00
|
|
|
implementation("io.ktor:ktor-server-cio-jvm:$ktor_version")
|
2023-07-06 08:50:28 +00:00
|
|
|
implementation("io.ktor:ktor-server-compression:$ktor_version")
|
2023-03-24 03:58:12 +00:00
|
|
|
implementation("ch.qos.logback:logback-classic:$logback_version")
|
|
|
|
|
|
|
|
implementation("io.insert-koin:koin-core:$koin_version")
|
|
|
|
implementation("io.insert-koin:koin-ktor:$koin_version")
|
|
|
|
implementation("io.insert-koin:koin-logger-slf4j:$koin_version")
|
2023-05-04 02:48:39 +00:00
|
|
|
implementation("io.insert-koin:koin-annotations:1.2.0")
|
2023-07-06 08:50:28 +00:00
|
|
|
implementation("io.ktor:ktor-server-compression-jvm:2.3.0")
|
2023-05-04 02:48:39 +00:00
|
|
|
ksp("io.insert-koin:koin-ksp-compiler:1.2.0")
|
|
|
|
|
2023-08-18 03:01:32 +00:00
|
|
|
implementation("org.springframework.boot:spring-boot-starter-web")
|
2023-08-28 12:05:34 +00:00
|
|
|
implementation("org.springframework.boot:spring-boot-starter-security")
|
|
|
|
implementation("org.springframework.boot:spring-boot-starter-oauth2-authorization-server")
|
|
|
|
implementation("org.springframework.boot:spring-boot-starter-oauth2-resource-server")
|
2023-08-18 06:25:42 +00:00
|
|
|
implementation("jakarta.validation:jakarta.validation-api")
|
|
|
|
implementation("jakarta.annotation:jakarta.annotation-api:2.1.0")
|
|
|
|
compileOnly("io.swagger.core.v3:swagger-annotations:2.2.6")
|
|
|
|
implementation("io.swagger.core.v3:swagger-models:2.2.6")
|
2023-08-28 12:05:34 +00:00
|
|
|
implementation("org.jetbrains.exposed:exposed-java-time:$exposed_version")
|
|
|
|
implementation("org.jetbrains.exposed:spring-transaction:$exposed_version")
|
2023-09-19 02:01:55 +00:00
|
|
|
implementation("org.springframework.data:spring-data-commons")
|
|
|
|
implementation("org.springframework.boot:spring-boot-starter-jdbc")
|
|
|
|
implementation("org.springframework.boot:spring-boot-starter-data-jdbc")
|
2023-09-19 06:46:51 +00:00
|
|
|
implementation("org.springframework.boot:spring-boot-starter-webflux")
|
|
|
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
|
2023-09-19 07:21:35 +00:00
|
|
|
testImplementation("org.springframework.boot:spring-boot-test-autoconfigure")
|
|
|
|
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
2023-05-04 02:48:39 +00:00
|
|
|
|
2023-04-29 13:25:41 +00:00
|
|
|
implementation("io.ktor:ktor-client-logging-jvm:$ktor_version")
|
|
|
|
implementation("io.ktor:ktor-server-host-common-jvm:$ktor_version")
|
|
|
|
implementation("io.ktor:ktor-server-status-pages-jvm:$ktor_version")
|
2023-03-24 03:58:12 +00:00
|
|
|
|
|
|
|
testImplementation("io.ktor:ktor-server-tests-jvm:$ktor_version")
|
|
|
|
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
|
2023-08-18 06:25:42 +00:00
|
|
|
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4")
|
2023-03-30 06:33:19 +00:00
|
|
|
|
|
|
|
implementation("io.ktor:ktor-client-core:$ktor_version")
|
|
|
|
implementation("io.ktor:ktor-client-cio:$ktor_version")
|
2023-03-30 11:01:04 +00:00
|
|
|
implementation("io.ktor:ktor-client-content-negotiation:$ktor_version")
|
2023-03-31 07:25:08 +00:00
|
|
|
testImplementation("io.ktor:ktor-client-mock:$ktor_version")
|
2023-03-31 03:23:58 +00:00
|
|
|
implementation("tech.barbero.http-messages-signing:http-messages-signing-core:1.0.0")
|
|
|
|
|
2023-03-30 11:55:12 +00:00
|
|
|
testImplementation("org.junit.jupiter:junit-jupiter:5.8.1")
|
2023-04-10 02:37:08 +00:00
|
|
|
testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0")
|
|
|
|
testImplementation("org.mockito:mockito-inline:5.2.0")
|
|
|
|
|
2023-04-05 07:59:16 +00:00
|
|
|
|
|
|
|
implementation("org.drewcarlson:kjob-core:0.6.0")
|
2023-04-29 13:25:41 +00:00
|
|
|
testImplementation("io.ktor:ktor-server-test-host-jvm:$ktor_version")
|
2023-04-07 04:00:29 +00:00
|
|
|
|
|
|
|
testImplementation("org.slf4j:slf4j-simple:2.0.7")
|
|
|
|
|
2023-04-29 14:57:25 +00:00
|
|
|
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.22.0")
|
2023-03-24 03:58:12 +00:00
|
|
|
}
|
2023-03-24 04:09:43 +00:00
|
|
|
|
|
|
|
jib {
|
|
|
|
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
|
|
|
|
dockerClient.environment = mapOf(
|
|
|
|
"DOCKER_HOST" to "localhost:2375"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ktor {
|
|
|
|
docker {
|
|
|
|
localImageName.set("hideout")
|
|
|
|
}
|
|
|
|
}
|
2023-04-22 00:13:53 +00:00
|
|
|
|
|
|
|
graalvmNative {
|
|
|
|
binaries {
|
|
|
|
named("main") {
|
|
|
|
fallback.set(false)
|
|
|
|
verbose.set(true)
|
2023-08-18 06:25:42 +00:00
|
|
|
agent {
|
2023-04-22 02:20:11 +00:00
|
|
|
enabled.set(false)
|
|
|
|
}
|
2023-04-22 00:13:53 +00:00
|
|
|
|
|
|
|
buildArgs.add("--initialize-at-build-time=io.ktor,kotlin,kotlinx")
|
2023-04-22 02:20:11 +00:00
|
|
|
// buildArgs.add("--trace-class-initialization=ch.qos.logback.classic.Logger")
|
|
|
|
// buildArgs.add("--trace-object-instantiation=ch.qos.logback.core.AsyncAppenderBase"+"$"+"Worker")
|
|
|
|
// buildArgs.add("--trace-object-instantiation=ch.qos.logback.classic.Logger")
|
2023-04-22 00:13:53 +00:00
|
|
|
buildArgs.add("--initialize-at-build-time=org.slf4j.LoggerFactory,ch.qos.logback")
|
2023-04-22 02:20:11 +00:00
|
|
|
// buildArgs.add("--trace-object-instantiation=kotlinx.coroutines.channels.ArrayChannel")
|
2023-04-22 00:13:53 +00:00
|
|
|
buildArgs.add("--initialize-at-build-time=kotlinx.coroutines.channels.ArrayChannel")
|
|
|
|
buildArgs.add("-H:+InstallExitHandlers")
|
|
|
|
buildArgs.add("-H:+ReportUnsupportedElementsAtRuntime")
|
|
|
|
buildArgs.add("-H:+ReportExceptionStackTraces")
|
|
|
|
|
2023-04-22 02:20:11 +00:00
|
|
|
runtimeArgs.add("-config=$buildDir/resources/main/application-native.conf")
|
2023-04-22 00:13:53 +00:00
|
|
|
imageName.set("graal-server")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-04-29 14:57:25 +00:00
|
|
|
|
|
|
|
detekt {
|
|
|
|
parallel = true
|
|
|
|
config = files("detekt.yml")
|
|
|
|
buildUponDefaultConfig = true
|
|
|
|
basePath = rootDir.absolutePath
|
2023-04-29 16:25:54 +00:00
|
|
|
autoCorrect = true
|
2023-04-29 14:57:25 +00:00
|
|
|
}
|
2023-05-05 03:41:04 +00:00
|
|
|
|
|
|
|
tasks.withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
|
2023-09-19 07:21:35 +00:00
|
|
|
exclude("**/org/koin/ksp/generated/**", "**/generated/**")
|
2023-05-05 03:41:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tasks.withType<io.gitlab.arturbosch.detekt.DetektCreateBaselineTask>().configureEach {
|
2023-09-19 07:21:35 +00:00
|
|
|
exclude("**/org/koin/ksp/generated/**", "**/generated/**")
|
|
|
|
}
|
|
|
|
|
|
|
|
configurations.matching { it.name == "detekt" }.all {
|
|
|
|
resolutionStrategy.eachDependency {
|
|
|
|
if (requested.group == "org.jetbrains.kotlin") {
|
|
|
|
useVersion("1.9.0")
|
|
|
|
}
|
|
|
|
}
|
2023-05-05 03:41:04 +00:00
|
|
|
}
|