mirror of https://github.com/usbharu/Hideout.git
Compare commits
1 Commits
d606b25ea9
...
bdd816cd1c
Author | SHA1 | Date |
---|---|---|
|
bdd816cd1c |
|
@ -57,8 +57,29 @@ subprojects {
|
||||||
kotlin {
|
kotlin {
|
||||||
jvmToolchain(21)
|
jvmToolchain(21)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val mergeChildResources by tasks.registering(Copy::class) {
|
||||||
|
// 各子プロジェクトの resources を処理後に取得
|
||||||
|
dependsOn(subprojects.map { it.tasks.named("processResources") })
|
||||||
|
|
||||||
|
subprojects.forEach { sub ->
|
||||||
|
// 各サブプロジェクトの 'bootBuildInfo' タスクを待機するように設定
|
||||||
|
dependsOn(sub.tasks.named("bootBuildInfo"))
|
||||||
|
|
||||||
|
// サブプロジェクトの 'resources/main' をマージ
|
||||||
|
from(sub.layout.buildDirectory.dir("resources/main"))
|
||||||
|
}
|
||||||
|
into(layout.buildDirectory.dir("resources/main"))
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named<ProcessResources>("processResources") {
|
||||||
|
dependsOn(mergeChildResources)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
register("run") {
|
register("run") {
|
||||||
dependsOn(gradle.includedBuild("hideout-core").task(":run"))
|
dependsOn(gradle.includedBuild("hideout-core").task(":run"))
|
||||||
|
@ -83,7 +104,7 @@ tasks {
|
||||||
}
|
}
|
||||||
named<BootJar>("bootJar") {
|
named<BootJar>("bootJar") {
|
||||||
layered {
|
layered {
|
||||||
enabled.set(false)
|
enabled = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import com.github.jk1.license.importer.XmlReportImporter
|
||||||
import com.github.jk1.license.render.*
|
import com.github.jk1.license.render.*
|
||||||
import kotlinx.kover.gradle.plugin.dsl.CoverageUnit
|
import kotlinx.kover.gradle.plugin.dsl.CoverageUnit
|
||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||||
|
import org.springframework.boot.gradle.tasks.bundling.BootJar
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.kotlin.jvm)
|
alias(libs.plugins.kotlin.jvm)
|
||||||
|
@ -138,8 +139,18 @@ tasks {
|
||||||
).toMutableList()
|
).toMutableList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
named<BootJar>("bootJar") {
|
||||||
|
layered {
|
||||||
|
// enabled.set(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
springBoot {
|
||||||
|
buildInfo()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
kover {
|
kover {
|
||||||
|
|
|
@ -16,17 +16,27 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.config
|
package dev.usbharu.hideout.core.config
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.infrastructure.springframework.MergedPropertiesMessageSource
|
import org.springframework.boot.autoconfigure.context.MessageSourceProperties
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties
|
||||||
import org.springframework.context.MessageSource
|
import org.springframework.context.MessageSource
|
||||||
import org.springframework.context.annotation.Bean
|
import org.springframework.context.annotation.Bean
|
||||||
import org.springframework.context.annotation.Configuration
|
import org.springframework.context.annotation.Configuration
|
||||||
import org.springframework.context.annotation.Profile
|
import org.springframework.context.annotation.Profile
|
||||||
|
import org.springframework.context.support.ReloadableResourceBundleMessageSource
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Profile("dev")
|
@Profile("dev")
|
||||||
class MessageSourceConfig {
|
class MessageSourceConfig {
|
||||||
@Bean
|
@Bean
|
||||||
fun messageSource(): MessageSource {
|
fun messageSource(messageSourceProperties: MessageSourceProperties): MessageSource {
|
||||||
return MergedPropertiesMessageSource()
|
val reloadableResourceBundleMessageSource = ReloadableResourceBundleMessageSource()
|
||||||
|
reloadableResourceBundleMessageSource.setBasename("classpath:" + messageSourceProperties.basename)
|
||||||
|
reloadableResourceBundleMessageSource.setCacheSeconds(0)
|
||||||
|
return reloadableResourceBundleMessageSource
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Profile("dev")
|
||||||
|
@ConfigurationProperties(prefix = "spring.messages")
|
||||||
|
fun messageSourceProperties(): MessageSourceProperties = MessageSourceProperties()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
package dev.usbharu.hideout.core.infrastructure.springframework
|
|
||||||
|
|
||||||
import org.springframework.context.support.AbstractMessageSource
|
|
||||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver
|
|
||||||
import java.io.InputStreamReader
|
|
||||||
import java.nio.charset.StandardCharsets
|
|
||||||
import java.text.MessageFormat
|
|
||||||
import java.util.*
|
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
|
||||||
|
|
||||||
class MergedPropertiesMessageSource : AbstractMessageSource() {
|
|
||||||
|
|
||||||
private val messages: MutableMap<Locale, Properties> = ConcurrentHashMap()
|
|
||||||
|
|
||||||
init {
|
|
||||||
loadAllLocaleProperties("classpath*:/messages/hideout-web-messages*.properties")
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun loadAllLocaleProperties(locationPattern: String) {
|
|
||||||
val resolver = PathMatchingResourcePatternResolver()
|
|
||||||
val resources = resolver.getResources(locationPattern)
|
|
||||||
|
|
||||||
for (resource in resources) {
|
|
||||||
val filename = resource.filename ?: continue
|
|
||||||
|
|
||||||
val localeSuffix = filename
|
|
||||||
.removePrefix("hideout-web-messages")
|
|
||||||
.removeSuffix(".properties")
|
|
||||||
.takeIf { it.isNotBlank() }
|
|
||||||
?: "default"
|
|
||||||
|
|
||||||
val locale = if (localeSuffix == "default") {
|
|
||||||
Locale.ROOT
|
|
||||||
} else {
|
|
||||||
Locale.forLanguageTag(localeSuffix.replace('_', '-'))
|
|
||||||
}
|
|
||||||
|
|
||||||
val props = messages.getOrPut(locale) { Properties() }
|
|
||||||
|
|
||||||
resource.inputStream.use { stream ->
|
|
||||||
InputStreamReader(stream, StandardCharsets.UTF_8).use { reader ->
|
|
||||||
val newProps = Properties()
|
|
||||||
newProps.load(reader)
|
|
||||||
props.putAll(newProps) // 上書きあり
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun resolveCode(code: String, locale: Locale): MessageFormat? {
|
|
||||||
val props = messages[locale] ?: messages[Locale.ROOT] ?: return null
|
|
||||||
val msg = props.getProperty(code) ?: return null
|
|
||||||
return MessageFormat(msg, locale)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun resolveCodeWithoutArguments(code: String, locale: Locale): String? {
|
|
||||||
val props = messages[locale] ?: messages[Locale.ROOT] ?: return null
|
|
||||||
return props.getProperty(code)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<property name="LOG_FILE" value="logs/logFile.log"/>
|
<property name="LOG_FILE" value="logs/logFile.log"/>
|
||||||
<property name="CONSOLE_LOG_THRESHOLD" value="${CONSOLE_LOG_THRESHOLD:-INFO}"/>
|
<property name="CONSOLE_LOG_THRESHOLD" value="${CONSOLE_LOG_THRESHOLD:-TRACE}"/>
|
||||||
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
||||||
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
|
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
|
||||||
<include resource="org/springframework/boot/logging/logback/file-appender.xml"/>
|
<include resource="org/springframework/boot/logging/logback/file-appender.xml"/>
|
||||||
|
|
Loading…
Reference in New Issue