Reformat all code

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>
This commit is contained in:
solonovamax committed 2021-08-30 17:34:44 -04:00
1 parent 1655381413
commit c445a0434d
753 files changed
+10461 -8783

No files matched your search

@@ -1,6 +1,13 @@
package com.dfsek.terra
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.io.FileWriter
import java.net.URL
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
import org.gradle.api.DefaultTask
import org.gradle.api.Project
import org.gradle.api.plugins.BasePluginExtension
@@ -11,29 +18,22 @@ import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.named
import org.yaml.snakeyaml.DumperOptions
import org.yaml.snakeyaml.Yaml
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.io.FileWriter
import java.net.URL
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
fun Project.configureDistribution() {
apply(plugin = "com.github.johnrengelman.shadow")
val downloadDefaultPacks = tasks.create("downloadDefaultPacks") {
group = "terra"
doFirst {
file("${buildDir}/resources/main/packs/").deleteRecursively()
val defaultPackUrl = URL("https://github.com/PolyhedralDev/TerraDefaultConfig/releases/download/latest/default.zip")
downloadPack(defaultPackUrl, project)
val netherPackUrl = URL("https://github.com/PolyhedralDev/TerraDefaultConfig/releases/download/latest/nether.zip")
downloadPack(netherPackUrl, project)
}
}
val installAddons = tasks.create("installAddons") {
group = "terra"
project(":common:addons").subprojects.forEach {
@@ -41,7 +41,7 @@ fun Project.configureDistribution() {
dependsOn(it.tasks.getByName("build")) // Depend on addon JARs
}
}
doFirst {
// The addons are copied into a JAR because of a ShadowJar bug
// which expands *all* JARs, even resource ones, into the fat JAR.
@@ -52,13 +52,13 @@ fun Project.configureDistribution() {
// https://github.com/johnrengelman/shadow/issues/111
val dest = File(buildDir, "/resources/main/addons.jar")
dest.parentFile.mkdirs()
val zip = ZipOutputStream(FileOutputStream(dest))
project(":common:addons").subprojects.forEach { addonProject ->
val jar = (addonProject.tasks.named("jar").get() as Jar)
println("Packaging addon ${jar.archiveFileName.get()} to ${dest.absolutePath}.")
val entry = ZipEntry("addons/${jar.archiveFileName.get()}")
zip.putNextEntry(entry)
FileInputStream(jar.archiveFile.get().asFile).copyTo(zip)
@@ -67,7 +67,7 @@ fun Project.configureDistribution() {
zip.close()
}
}
val generateResourceManifest = tasks.create("generateResourceManifest") {
group = "terra"
dependsOn(downloadDefaultPacks)
@@ -75,24 +75,24 @@ fun Project.configureDistribution() {
doFirst {
val resources = HashMap<String, MutableList<String>>()
val packsDir = File("${project.buildDir}/resources/main/packs/")
packsDir.walkTopDown().forEach {
if (it.isDirectory || !it.name.endsWith(".zip")) return@forEach
resources.computeIfAbsent("packs") { ArrayList() }.add(it.name)
}
val langDir = File("${project(":common:implementation").buildDir}/resources/main/lang/")
langDir.walkTopDown().forEach {
if (it.isDirectory || !it.name.endsWith(".yml")) return@forEach
resources.computeIfAbsent("lang") { ArrayList() }.add(it.name)
}
project(":common:addons").subprojects.forEach { addonProject ->
val jar = (addonProject.tasks.named("jar").get() as Jar).archiveFileName.get()
resources.computeIfAbsent("addons") { ArrayList() }.add(jar)
}
val options = DumperOptions()
options.indent = 2
options.indentWithIndicator = true
@@ -100,25 +100,25 @@ fun Project.configureDistribution() {
options.isPrettyFlow = true
options.defaultFlowStyle = DumperOptions.FlowStyle.BLOCK
options.defaultScalarStyle = DumperOptions.ScalarStyle.DOUBLE_QUOTED
val yaml = Yaml(options)
val manifest = File("${project.buildDir}/resources/main/resources.yml")
if (manifest.exists()) manifest.delete()
manifest.createNewFile()
yaml.dump(resources, FileWriter(manifest))
}
}
tasks["processResources"].dependsOn(generateResourceManifest)
tasks.named<ShadowJar>("shadowJar") {
// Tell shadow to download the packs
dependsOn(downloadDefaultPacks)
configurations = listOf(project.configurations["shaded"])
archiveClassifier.set("shaded")
setVersion(project.version)
relocate("org.apache.commons", "com.dfsek.terra.lib.commons")
@@ -126,11 +126,11 @@ fun Project.configureDistribution() {
relocate("org.json", "com.dfsek.terra.lib.json")
relocate("org.yaml", "com.dfsek.terra.lib.yaml")
}
configure<BasePluginExtension> {
archivesName.set(project.name)
}
tasks.named<DefaultTask>("build") {
dependsOn(tasks["shadowJar"])
}