Fix build

This commit is contained in:
Him188 2020-11-09 15:46:05 +08:00
parent fd438c2e4c
commit 85600d35b0
4 changed files with 10 additions and 44 deletions

View File

@ -28,7 +28,7 @@ import net.mamoe.mirai.console.plugin.loader.PluginLoadException
import net.mamoe.mirai.console.plugin.loader.PluginLoader
import net.mamoe.mirai.console.plugin.name
import net.mamoe.mirai.console.util.CoroutineScopeUtils.childScope
import net.mamoe.mirai.console.util.SemVersion.Companion.contains
import net.mamoe.mirai.console.util.SemVersion
import net.mamoe.mirai.utils.info
import java.io.File
import java.nio.file.Path
@ -248,8 +248,8 @@ internal fun List<PluginDescription>.findDependency(dependency: PluginDependency
}
internal fun PluginDescription.checkSatisfies(dependency: PluginDependency, plugin: PluginDescription) {
val requirement = dependency.versionRequirement
if (requirement != null && this.version !in requirement) {
val requirement = dependency.versionRequirement ?: return
if (SemVersion.parseRangeRequirement(requirement).test(this.version)) {
throw PluginLoadException("Plugin '${plugin.id}' ('${plugin.id}') requires '${dependency.id}' with version $requirement while the resolved is ${this.version}")
}
}

View File

@ -25,7 +25,7 @@ import net.mamoe.mirai.console.util.SemVersion
* @see PluginDescription.dependencies
*/
@Serializable(with = PluginDependency.PluginDependencyAsStringSerializer::class)
public class PluginDependency @JvmOverloads constructor(
public data class PluginDependency @JvmOverloads constructor(
/**
* 依赖插件 ID, [PluginDescription.id]
*/
@ -37,7 +37,7 @@ public class PluginDependency @JvmOverloads constructor(
*
* @see SemVersion.Requirement
*/
public val versionRequirement: SemVersion.Requirement? = null,
public val versionRequirement: String? = null,
/**
* 若为 `false`, 插件在找不到此依赖时也能正常加载.
*/
@ -63,32 +63,12 @@ public class PluginDependency @JvmOverloads constructor(
public override fun toString(): String = buildString {
append(id)
versionRequirement?.rule?.let(::append)
versionRequirement?.let(::append)
if (isOptional) {
append('?')
}
}
public override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as PluginDependency
if (id != other.id) return false
if (versionRequirement?.rule != other.versionRequirement?.rule) return false
if (isOptional != other.isOptional) return false
return true
}
public override fun hashCode(): Int {
var result = id.hashCode()
result = 31 * result + (versionRequirement?.rule?.hashCode() ?: 0)
result = 31 * result + isOptional.hashCode()
return result
}
public companion object {
/**
* 解析 "$id:$versionRequirement?"
@ -101,7 +81,7 @@ public class PluginDependency @JvmOverloads constructor(
val (id, version) = string.removeSuffix("?").let {
it.substringBeforeLast(':') to it.substringAfterLast(':', "")
}
return PluginDependency(id, SemVersion.parseRangeRequirement(version), optional)
return PluginDependency(id, version, optional)
}
}

View File

@ -191,20 +191,6 @@ public class JvmPluginDescriptionBuilder(
}
}
/**
* isOptional = false
*
* @see PluginDependency
*/
@ILoveKuriyamaMiraiForever
public fun dependsOn(
@ResolveContext(PLUGIN_ID) pluginId: String,
versionRequirement: SemVersion.Requirement,
isOptional: Boolean = false,
): JvmPluginDescriptionBuilder = apply {
this.dependencies.add(PluginDependency(pluginId, versionRequirement, isOptional))
}
/**
* @see PluginDependency
*/
@ -214,7 +200,7 @@ public class JvmPluginDescriptionBuilder(
@ResolveContext(VERSION_REQUIREMENT) versionRequirement: String,
isOptional: Boolean = false,
): JvmPluginDescriptionBuilder = apply {
this.dependencies.add(PluginDependency(pluginId, SemVersion.parseRangeRequirement(versionRequirement), isOptional))
this.dependencies.add(PluginDependency(pluginId, versionRequirement, isOptional))
}
/**
@ -255,7 +241,7 @@ public class JvmPluginDescriptionBuilder(
internal data class SimpleJvmPluginDescription
@JvmOverloads constructor(
override val id: String,
override val name: String = id,
override val name: String,
override val version: SemVersion,
override val author: String = "",
override val info: String = "",

View File

@ -10,6 +10,6 @@
package net.mamoe.mirai.console.gradle
internal object VersionConstants {
const val CONSOLE_VERSION = "1.0-RC-1" // value is written here automatically during build
const val CONSOLE_VERSION = "1.0-RC2-dev-1" // value is written here automatically during build
const val CORE_VERSION = "1.3.3" // value is written here automatically during build
}