mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-04-29 22:27:31 +00:00
feat(config): 支持限定 Maven 仓库构件类型.
增加 Maven 仓库配置, 支持限定仓库可获取的构件发布类型(发布或快照). 此改动有利于用户增加仓库约束, 防止意外使用错误的扩展包版本.
This commit is contained in:
parent
0a5313e94a
commit
5e18149640
@ -106,6 +106,8 @@ internal data class MavenRepositoryConfig(
|
|||||||
val url: URL,
|
val url: URL,
|
||||||
val proxy: Proxy? = Proxy("http", "127.0.0.1", 1080),
|
val proxy: Proxy? = Proxy("http", "127.0.0.1", 1080),
|
||||||
val layout: String = "default",
|
val layout: String = "default",
|
||||||
|
val enableReleases: Boolean = true,
|
||||||
|
val enableSnapshots: Boolean = true,
|
||||||
// 可能要设计个 type 来判断解析成什么类型的 Authentication.
|
// 可能要设计个 type 来判断解析成什么类型的 Authentication.
|
||||||
val authentication: Authentication? = null
|
val authentication: Authentication? = null
|
||||||
) {
|
) {
|
||||||
@ -121,14 +123,14 @@ internal data class MavenRepositoryConfig(
|
|||||||
|
|
||||||
builder.setReleasePolicy(
|
builder.setReleasePolicy(
|
||||||
RepositoryPolicy(
|
RepositoryPolicy(
|
||||||
true,
|
enableReleases,
|
||||||
RepositoryPolicy.UPDATE_POLICY_NEVER,
|
RepositoryPolicy.UPDATE_POLICY_NEVER,
|
||||||
RepositoryPolicy.CHECKSUM_POLICY_FAIL
|
RepositoryPolicy.CHECKSUM_POLICY_FAIL
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
builder.setSnapshotPolicy(
|
builder.setSnapshotPolicy(
|
||||||
RepositoryPolicy(
|
RepositoryPolicy(
|
||||||
true,
|
enableSnapshots,
|
||||||
RepositoryPolicy.UPDATE_POLICY_ALWAYS,
|
RepositoryPolicy.UPDATE_POLICY_ALWAYS,
|
||||||
RepositoryPolicy.CHECKSUM_POLICY_WARN
|
RepositoryPolicy.CHECKSUM_POLICY_WARN
|
||||||
)
|
)
|
||||||
|
@ -142,12 +142,15 @@ internal object MavenRepositoryConfigSerializer
|
|||||||
return when (json) {
|
return when (json) {
|
||||||
is JsonObject -> {
|
is JsonObject -> {
|
||||||
MavenRepositoryConfig(
|
MavenRepositoryConfig(
|
||||||
|
id = json.get("id")?.asString,
|
||||||
url = URL(checkJsonKey(json, "url")),
|
url = URL(checkJsonKey(json, "url")),
|
||||||
proxy = if (json.has("proxy") && json.get("proxy").isJsonObject)
|
proxy = if (json.has("proxy") && json.get("proxy").isJsonObject)
|
||||||
context.deserialize<Proxy>(
|
context.deserialize<Proxy>(
|
||||||
json.getAsJsonObject("proxy"), Proxy::class.java
|
json.getAsJsonObject("proxy"), Proxy::class.java
|
||||||
) else null,
|
) else null,
|
||||||
layout = json.get("layout").asString ?: "default",
|
layout = json.get("layout").asString ?: "default",
|
||||||
|
enableReleases = json.get("enableReleases")?.asBoolean ?: true,
|
||||||
|
enableSnapshots = json.get("enableSnapshots")?.asBoolean ?: true,
|
||||||
authentication = if (json.has("authentication") && json.get("authentication").isJsonObject)
|
authentication = if (json.has("authentication") && json.get("authentication").isJsonObject)
|
||||||
context.deserialize<Authentication>(
|
context.deserialize<Authentication>(
|
||||||
json.getAsJsonObject("authentication"), Authentication::class.java
|
json.getAsJsonObject("authentication"), Authentication::class.java
|
||||||
|
Loading…
Reference in New Issue
Block a user