mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-04-29 22:27:31 +00:00
refactor(launch): 将 AppPaths 从 Launcher 解耦.
解耦后有助于后续改进, 以及单元测试的编写.
This commit is contained in:
parent
c94e0476b5
commit
30a2cb34d5
@ -61,7 +61,10 @@ internal fun startMetricsServer(config: MetricsConfig = Const.config.metrics): H
|
||||
return httpServer
|
||||
}
|
||||
|
||||
internal class Launcher(private val config: AppConfig = Const.config) : AutoCloseable {
|
||||
internal class Launcher(
|
||||
private val config: AppConfig = Const.config,
|
||||
private val configFile: File = AppPaths.CONFIG_APPLICATION.file,
|
||||
) : AutoCloseable {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
@ -75,9 +78,7 @@ internal class Launcher(private val config: AppConfig = Const.config) : AutoClos
|
||||
private fun getMavenLocalRepository(): LocalRepository {
|
||||
val localPath =
|
||||
if (config.mavenLocalRepository != null && config.mavenLocalRepository!!.isNotEmpty()) {
|
||||
val repoPath = AppPaths.DATA_ROOT.file.toPath()
|
||||
.resolve(config.mavenLocalRepository!!)
|
||||
.apply {
|
||||
val repoPath = configFile.toPath().resolve(config.mavenLocalRepository!!).apply {
|
||||
if (!exists()) {
|
||||
if (!parent.isWritable() || !parent.isReadable()) {
|
||||
throw IOException("Unable to read and write the directory where Maven repository is located.")
|
||||
|
Loading…
Reference in New Issue
Block a user