mirror of
https://github.com/GayPizzaSpecifications/concrete.git
synced 2025-08-05 22:21:33 +00:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
4f82639658
|
|||
5429dcddd5
|
|||
1a968a6489
|
|||
aa2750bdc0
|
@ -5,4 +5,3 @@ Concrete is a Gradle plugin for Bukkit projects. Originally spawned out of the G
|
||||
## Contributors
|
||||
|
||||
- [@azenla](https://github.com/azenla)
|
||||
- [@kubeliv](https://github.com/kubeliv)
|
||||
|
@ -9,7 +9,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "gay.pizza.foundation"
|
||||
version = "0.15.0"
|
||||
version = "0.16.0"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@ -17,9 +17,9 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10")
|
||||
implementation("org.jetbrains.kotlin:kotlin-serialization:1.8.10")
|
||||
implementation("gradle.plugin.com.github.johnrengelman:shadow:7.1.2")
|
||||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.21")
|
||||
implementation("org.jetbrains.kotlin:kotlin-serialization:1.8.21")
|
||||
implementation("com.github.johnrengelman:shadow:8.1.1")
|
||||
implementation("com.google.code.gson:gson:2.10.1")
|
||||
|
||||
// Implementation of crypto used in smart downloader.
|
||||
@ -128,7 +128,7 @@ publishing {
|
||||
}
|
||||
|
||||
tasks.withType<Wrapper> {
|
||||
gradleVersion = "8.0"
|
||||
gradleVersion = "8.1.1"
|
||||
}
|
||||
|
||||
java {
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -1,7 +1,6 @@
|
||||
package gay.pizza.foundation.concrete
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.create
|
||||
import org.gradle.kotlin.dsl.get
|
||||
import org.gradle.language.jvm.tasks.ProcessResources
|
||||
|
||||
|
@ -1,9 +1,13 @@
|
||||
package gay.pizza.foundation.concrete
|
||||
|
||||
import java.net.URI
|
||||
import java.nio.file.Files
|
||||
import java.net.http.HttpClient
|
||||
import java.net.http.HttpRequest
|
||||
import java.net.http.HttpResponse.BodyHandlers
|
||||
import java.nio.file.Path
|
||||
import java.security.MessageDigest
|
||||
import kotlin.io.path.exists
|
||||
import kotlin.io.path.inputStream
|
||||
|
||||
class SmartDownloader(
|
||||
private val localFilePath: Path,
|
||||
@ -20,23 +24,25 @@ class SmartDownloader(
|
||||
}
|
||||
|
||||
private fun downloadRemoteFile() {
|
||||
val url = remoteDownloadUrl.toURL()
|
||||
val remoteFileStream = url.openStream()
|
||||
val localFileStream = Files.newOutputStream(localFilePath)
|
||||
remoteFileStream.transferTo(localFileStream)
|
||||
val httpClient = HttpClient.newHttpClient()
|
||||
val request = HttpRequest.newBuilder()
|
||||
.GET()
|
||||
.uri(remoteDownloadUrl)
|
||||
.build()
|
||||
httpClient.send(request, BodyHandlers.ofFile(localFilePath))
|
||||
val hashResult = checkLocalFileHash()
|
||||
if (hashResult != HashResult.ValidHash) {
|
||||
throw RuntimeException("Download of $remoteDownloadUrl did not result in valid hash.")
|
||||
throw RuntimeException("Download of $remoteDownloadUrl did not result in a valid hash.")
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkLocalFileHash(): HashResult {
|
||||
if (!Files.exists(localFilePath)) {
|
||||
if (!localFilePath.exists()) {
|
||||
return HashResult.DoesNotExist
|
||||
}
|
||||
|
||||
val digest = MessageDigest.getInstance("SHA-256")
|
||||
val localFileStream = Files.newInputStream(localFilePath)
|
||||
val localFileStream = localFilePath.inputStream()
|
||||
val buffer = ByteArray(16 * 1024)
|
||||
|
||||
while (true) {
|
||||
|
Reference in New Issue
Block a user