Use kotlin's Path extensions rather than Files.whatever

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>
This commit is contained in:
solonovamax 2023-11-08 20:38:25 -05:00
parent 0ab463f34f
commit 3f9f2bdce4
No known key found for this signature in database
GPG Key ID: 6525165901C66BC5

View File

@ -5,8 +5,6 @@ import java.net.URI
import java.net.URL
import java.nio.file.FileSystemNotFoundException
import java.nio.file.FileSystems
import java.nio.file.Files
import java.nio.file.StandardCopyOption
import org.gradle.api.DefaultTask
import org.gradle.api.Project
import org.gradle.api.plugins.BasePluginExtension
@ -17,6 +15,10 @@ import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.named
import org.yaml.snakeyaml.DumperOptions
import org.yaml.snakeyaml.Yaml
import kotlin.io.path.copyTo
import kotlin.io.path.createDirectories
import kotlin.io.path.createFile
import kotlin.io.path.exists
fun Project.configureDistribution() {
@ -51,7 +53,7 @@ fun Project.configureDistribution() {
FileSystems.getFileSystem(dest)
} catch (e: FileSystemNotFoundException) {
null
} ?: FileSystems.newFileSystem(dest, mapOf("create" to "false"), null);
} ?: FileSystems.newFileSystem(dest, mapOf("create" to "false"), null)
provider?.use { fs ->
forSubProjects(":common:addons") {
if (fs.isOpen) {
@ -63,10 +65,10 @@ fun Project.configureDistribution() {
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
val addonPath = fs.getPath("/addons/$boot${jar.archiveFileName.get()}")
if (!Files.exists(addonPath)) {
Files.createDirectories(addonPath.parent)
Files.createFile(addonPath)
Files.copy(jar.archiveFile.get().asFile.toPath(), addonPath, StandardCopyOption.REPLACE_EXISTING)
if (!addonPath.exists()) {
addonPath.parent.createDirectories()
addonPath.createFile()
jar.archiveFile.get().asFile.toPath().copyTo(addonPath, overwrite = true)
}
}
}
@ -136,7 +138,7 @@ fun Project.configureDistribution() {
dependsOn(downloadDefaultPacks)
configurations = listOf(project.configurations["shaded"])
archiveClassifier.set("shaded")
setVersion(project.version)
version = project.version
relocate("org.apache.commons", "com.dfsek.terra.lib.commons")
relocate("org.objectweb.asm", "com.dfsek.terra.lib.asm")
relocate("com.dfsek.paralithic", "com.dfsek.terra.lib.paralithic")