mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 00:15:35 +00:00
move compiled addons to run directories
This commit is contained in:
parent
f61883547e
commit
3dc564c0f7
@ -1,19 +1,47 @@
|
||||
package com.dfsek.terra
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.kotlin.dsl.withType
|
||||
import org.gradle.language.jvm.tasks.ProcessResources
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import java.util.function.Predicate
|
||||
import kotlin.streams.asStream
|
||||
|
||||
|
||||
fun Project.runDir(dir: File) {
|
||||
tasks.withType<ProcessResources> {
|
||||
doFirst {
|
||||
/**
|
||||
* Configures a directory where addons will be put.
|
||||
*/
|
||||
fun Project.addonDir(dir: File, task: Task) {
|
||||
task.doFirst {
|
||||
dir.parentFile.mkdirs()
|
||||
matchingAddons(dir) {
|
||||
it.name.startsWith("Terra-") // Assume everything that starts with Terra- is a core addon.
|
||||
}.forEach {
|
||||
println("Deleting old addon: " + it.absolutePath)
|
||||
it.delete()
|
||||
}
|
||||
project(":common:addons").subprojects.forEach { addonProject ->
|
||||
val jar = (addonProject.tasks.named("jar").get() as org.gradle.jvm.tasks.Jar);
|
||||
|
||||
val target = File(dir, jar.archiveFileName.get())
|
||||
|
||||
val base = "${jar.archiveBaseName.get()}-${project.version}"
|
||||
|
||||
println("Copying addon ${jar.archiveFileName.get()} to ${target.absolutePath}. Base name: $base")
|
||||
|
||||
jar.archiveFile.orNull?.asFile?.copyTo(target)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun matchingAddons(dir: File, matcher: Predicate<File>): Set<File> {
|
||||
val matching = HashSet<File>();
|
||||
dir.walk().maxDepth(1).asStream().filter(matcher).forEach(matching::add)
|
||||
return matching;
|
||||
}
|
||||
|
||||
fun Project.configureAddons() {
|
||||
tasks.withType<ProcessResources> {
|
||||
project(":common:addons").subprojects.forEach {
|
||||
|
@ -33,10 +33,6 @@ dependencies {
|
||||
"testImplementation"("com.google.guava:guava:30.0-jre")
|
||||
}
|
||||
|
||||
tasks.named<Jar>("jar") {
|
||||
archiveBaseName.set("Terra-biome")
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("mavenJava") {
|
||||
|
@ -1,3 +1,4 @@
|
||||
import com.dfsek.terra.addonDir
|
||||
import com.dfsek.terra.configureCommon
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import com.modrinth.minotaur.TaskModrinthUpload
|
||||
@ -12,6 +13,8 @@ plugins {
|
||||
}
|
||||
|
||||
configureCommon()
|
||||
addonDir(project.rootProject.file("./run/config/Terra/addons"), tasks.named("runClient").get())
|
||||
addonDir(project.rootProject.file("./run/config/Terra/addons"), tasks.named("runServer").get())
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
relocate("org.json", "com.dfsek.terra.lib.json")
|
||||
|
@ -1 +0,0 @@
|
||||
org.gradle.jvmargs=-Xmx4G
|
Loading…
x
Reference in New Issue
Block a user