Skip to content

Commit

Permalink
feat(config): 支持限定 Maven 仓库构件类型.
Browse files Browse the repository at this point in the history
增加 Maven 仓库配置, 支持限定仓库可获取的构件发布类型(发布或快照).
此改动有利于用户增加仓库约束, 防止意外使用错误的扩展包版本.
  • Loading branch information
LamGC committed May 18, 2022
1 parent 0a5313e commit 5e18149
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scalabot-app/src/main/kotlin/AppConfigs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ internal data class MavenRepositoryConfig(
val url: URL,
val proxy: Proxy? = Proxy("http", "127.0.0.1", 1080),
val layout: String = "default",
val enableReleases: Boolean = true,
val enableSnapshots: Boolean = true,
// 可能要设计个 type 来判断解析成什么类型的 Authentication.
val authentication: Authentication? = null
) {
Expand All @@ -121,14 +123,14 @@ internal data class MavenRepositoryConfig(

builder.setReleasePolicy(
RepositoryPolicy(
true,
enableReleases,
RepositoryPolicy.UPDATE_POLICY_NEVER,
RepositoryPolicy.CHECKSUM_POLICY_FAIL
)
)
builder.setSnapshotPolicy(
RepositoryPolicy(
true,
enableSnapshots,
RepositoryPolicy.UPDATE_POLICY_ALWAYS,
RepositoryPolicy.CHECKSUM_POLICY_WARN
)
Expand Down
3 changes: 3 additions & 0 deletions scalabot-app/src/main/kotlin/util/Serializers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,15 @@ internal object MavenRepositoryConfigSerializer
return when (json) {
is JsonObject -> {
MavenRepositoryConfig(
id = json.get("id")?.asString,
url = URL(checkJsonKey(json, "url")),
proxy = if (json.has("proxy") && json.get("proxy").isJsonObject)
context.deserialize<Proxy>(
json.getAsJsonObject("proxy"), Proxy::class.java
) else null,
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)
context.deserialize<Authentication>(
json.getAsJsonObject("authentication"), Authentication::class.java
Expand Down

0 comments on commit 5e18149

Please sign in to comment.