Build using Toothpick scripts (#122)

Co-authored-by: BillyGalbreath <blake.galbreath@gmail.com>
This commit is contained in:
Jason
2020-12-18 05:04:33 -08:00
committed by GitHub
parent 391f9addfd
commit 69c6484904
77 changed files with 1224 additions and 745 deletions

View File

@@ -0,0 +1,39 @@
package task
import cmd
import ensureSuccess
import jenkins
import org.gradle.api.Project
import org.gradle.api.Task
import rootProjectDir
import taskGroup
import toothpick
internal fun Project.createPaperclipTask(
receiver: Task.() -> Unit = {}
): Task = tasks.create("paperclip") {
receiver(this)
group = taskGroup
doLast {
val workDir = toothpick.paperDir.resolve("work")
val paperclipDir = workDir.resolve("Paperclip")
val vanillaJarPath =
workDir.resolve("Minecraft/${toothpick.minecraftVersion}/${toothpick.minecraftVersion}.jar").absolutePath
val patchedJarPath = toothpick.serverProject.projectDir.resolve(
"build/libs/${toothpick.forkNameLowercase}-server-$version-all.jar"
).absolutePath
logger.lifecycle(">>> Building paperclip")
val paperclipCmd = arrayListOf(
"mvn", "clean", "package",
"-Dmcver=${toothpick.minecraftVersion}",
"-Dpaperjar=$patchedJarPath",
"-Dvanillajar=$vanillaJarPath"
)
if (jenkins) paperclipCmd.add("-Dstyle.color=never")
ensureSuccess(cmd(*paperclipCmd.toTypedArray(), dir = paperclipDir, printOut = true))
val paperClip = paperclipDir.resolve("assembly/target/paperclip-${toothpick.minecraftVersion}.jar")
val destination = rootProjectDir.resolve("${toothpick.forkNameLowercase}-paperclip.jar")
paperClip.copyTo(destination, overwrite = true)
logger.lifecycle(">>> ${toothpick.forkNameLowercase}-paperclip.jar saved to root project directory")
}
}