feat(extension): 支持从 Maven 仓库下载并安装扩展包.

支持该功能后, 可以使用户更容易安装扩展包, 尤其是无需配置的扩展包.
This commit is contained in:
2022-02-22 01:15:41 +08:00
parent d69112eefa
commit 13472d952e
4 changed files with 383 additions and 29 deletions

View File

@ -7,6 +7,7 @@ import org.eclipse.aether.artifact.Artifact
import java.io.File
import java.io.FileFilter
import java.io.FilenameFilter
import java.net.URL
internal fun ByteArray.toHaxString(): String = ByteUtils.bytesToHexString(this)
@ -93,4 +94,18 @@ private object UtilsInternal {
log.debug { "All registered hook resources have been closed." }
}, "Shutdown-AutoCloseable"))
}
}
}
fun URL.resolveToFile(canonical: Boolean = true): File {
if ("file" != protocol) {
throw ClassCastException("Only the URL of the `file` protocol can be converted into a File object.")
}
val urlString = toString().substringAfter(':')
val file = File(urlString)
return if (canonical) {
file.canonicalFile
} else {
file
}
}