mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-04-30 06:37:29 +00:00
feat(config): 支持指定本地仓库的路径.
可指定本地仓库的路径, 用于代替用户目录下的默认 Maven 本地仓库, 这么做可以在任意位置设置共享本地仓库.
This commit is contained in:
parent
1cd26b3b25
commit
1281dbcabe
@ -138,7 +138,8 @@ internal data class MavenRepositoryConfig(
|
||||
internal data class AppConfig(
|
||||
val proxy: ProxyConfig = ProxyConfig(),
|
||||
val metrics: MetricsConfig = MetricsConfig(),
|
||||
val mavenRepositories: List<MavenRepositoryConfig> = emptyList()
|
||||
val mavenRepositories: List<MavenRepositoryConfig> = emptyList(),
|
||||
val mavenLocalRepository: String? = null
|
||||
)
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@ import io.prometheus.client.exporter.HTTPServer
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import mu.KotlinLogging
|
||||
import net.lamgc.scalabot.util.registerShutdownHook
|
||||
import org.eclipse.aether.repository.LocalRepository
|
||||
import org.telegram.telegrambots.bots.DefaultBotOptions
|
||||
import org.telegram.telegrambots.meta.TelegramBotsApi
|
||||
import org.telegram.telegrambots.meta.generics.BotSession
|
||||
@ -53,6 +54,12 @@ internal class Launcher : AutoCloseable {
|
||||
|
||||
private val botApi = TelegramBotsApi(DefaultBotSession::class.java)
|
||||
private val botSessionMap = mutableMapOf<ScalaBot, BotSession>()
|
||||
private val mavenLocalRepository =
|
||||
if (Const.config.mavenLocalRepository != null && Const.config.mavenLocalRepository.isNotEmpty()) {
|
||||
LocalRepository(Const.config.mavenLocalRepository)
|
||||
} else {
|
||||
LocalRepository("${System.getProperty("user.home")}/.m2/repository")
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun launch(): Boolean {
|
||||
@ -106,6 +113,7 @@ internal class Launcher : AutoCloseable {
|
||||
}.toList()
|
||||
val extensionPackageFinders = setOf(
|
||||
MavenRepositoryExtensionFinder(
|
||||
localRepository = mavenLocalRepository,
|
||||
remoteRepositories = remoteRepositories,
|
||||
proxy = Const.config.proxy.toAetherProxy()
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user