mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 06:28:53 +00:00
Download dependencies at runtime on all platforms (not just Paper), and read dependency info from file in plugin jar generated by Gradle task (#259)
* Download dependencies at runtime on all platforms (not just Paper), and read dependency info from file in plugin jar generated by Gradle task * Add maven central as fallback for paper mirror * filter duplicate dependencies * fix fabric runServer * add todo * enable hangar publishing * - exclude unneeded deps from runtime dl - sort deps and relocations in the list file - other misc fixes * move jdbi relocation * don't log anything when we don't download or relocate any dependencies * add back mariadb driver and download more dependencies at runtime and other related build changes * build cleanup * build cleanup * remove useless dependencies block
This commit is contained in:
1 parent
82c22a08fa
commit
307395ce5b
16 files changed
+694
-95
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import java.io.InputStream
|
||||
import java.nio.file.Path
|
||||
import java.security.DigestInputStream
|
||||
import java.security.MessageDigest
|
||||
import kotlin.io.path.inputStream
|
||||
|
||||
enum class HashingAlgorithm(algorithm: String) {
|
||||
SHA256("SHA-256"),
|
||||
SHA1("SHA-1");
|
||||
|
||||
private val threadLocalMessageDigest = ThreadLocal.withInitial { MessageDigest.getInstance(algorithm) }
|
||||
|
||||
val digest: MessageDigest
|
||||
get() = threadLocalMessageDigest.get()
|
||||
}
|
||||
|
||||
fun Path.hashFile(algorithm: HashingAlgorithm): ByteArray = inputStream().use { input -> input.hash(algorithm) }
|
||||
|
||||
fun InputStream.hash(algorithm: HashingAlgorithm): ByteArray {
|
||||
val digestStream = DigestInputStream(this, algorithm.digest)
|
||||
digestStream.use { stream ->
|
||||
val buffer = ByteArray(1024)
|
||||
while (stream.read(buffer) != -1) {
|
||||
// reading
|
||||
}
|
||||
}
|
||||
return digestStream.messageDigest.digest()
|
||||
}
|
||||
|
||||
fun ByteArray.asHexString(): String {
|
||||
val sb: StringBuilder = StringBuilder(size * 2)
|
||||
for (aHash in this) {
|
||||
sb.append("%02x".format(aHash.toInt() and 0xFF))
|
||||
}
|
||||
return sb.toString()
|
||||
}
|
||||
Reference in new issue
Block a user