mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 22:31:52 +00:00
testWithPaper task moved to Bukkit subproject
This commit is contained in:
+1
-63
@@ -2,10 +2,7 @@
|
|||||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.nio.channels.Channels
|
|
||||||
import java.nio.file.Files
|
|
||||||
import java.nio.file.Paths
|
|
||||||
import java.nio.file.StandardCopyOption
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
java
|
java
|
||||||
@@ -117,41 +114,7 @@ tasks.build {
|
|||||||
// testWithPaper.mustRunAfter(tasks.shadowJar)
|
// testWithPaper.mustRunAfter(tasks.shadowJar)
|
||||||
}
|
}
|
||||||
|
|
||||||
val testDir = "target/server/"
|
|
||||||
|
|
||||||
val setupServer = tasks.create("setupServer") {
|
|
||||||
dependsOn(tasks.shadowJar)
|
|
||||||
doFirst {
|
|
||||||
// clean
|
|
||||||
file("${testDir}/").deleteRecursively()
|
|
||||||
file("${testDir}/plugins").mkdirs()
|
|
||||||
|
|
||||||
// Downloading latest paper jar.
|
|
||||||
val paperUrl = URL("https://papermc.io/api/v1/paper/1.16.4/latest/download")
|
|
||||||
val paperReadableByteChannel = Channels.newChannel(paperUrl.openStream())
|
|
||||||
val paperFile = file("${testDir}/paper.jar")
|
|
||||||
val paperFileOutputStream = paperFile.outputStream()
|
|
||||||
val paperFileChannel = paperFileOutputStream.channel
|
|
||||||
paperFileChannel.transferFrom(paperReadableByteChannel, 0, Long.MAX_VALUE)
|
|
||||||
|
|
||||||
// Cloning test setup.
|
|
||||||
gitClone("https://github.com/PolyhedralDev/WorldGenTestServer")
|
|
||||||
// Copying plugins
|
|
||||||
Files.move(Paths.get("WorldGenTestServer/plugins"),
|
|
||||||
Paths.get("$testDir/plugins"),
|
|
||||||
StandardCopyOption.REPLACE_EXISTING)
|
|
||||||
// Copying config
|
|
||||||
val serverText = URL("https://raw.githubusercontent.com/PolyhedralDev/WorldGenTestServer/master/server.properties").readText()
|
|
||||||
file("${testDir}/server.properties").writeText(serverText)
|
|
||||||
val bukkitText = URL("https://raw.githubusercontent.com/PolyhedralDev/WorldGenTestServer/master/bukkit.yml").readText()
|
|
||||||
file("${testDir}/bukkit.yml").writeText(bukkitText.replace("\${world}", "world").replace("\${gen}", "Terra:DEFAULT"))
|
|
||||||
|
|
||||||
File("${testDir}/eula.txt").writeText("eula=true")
|
|
||||||
|
|
||||||
// clean up
|
|
||||||
file("WorldGenTestServer").deleteRecursively()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val downloadDefaultPacks = tasks.create("downloadDefaultPacks") {
|
val downloadDefaultPacks = tasks.create("downloadDefaultPacks") {
|
||||||
doFirst {
|
doFirst {
|
||||||
@@ -168,31 +131,6 @@ val downloadDefaultPacks = tasks.create("downloadDefaultPacks") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val testWithPaper = task<JavaExec>(name = "testWithPaper") {
|
|
||||||
standardInput = System.`in`
|
|
||||||
dependsOn(tasks.shadowJar)
|
|
||||||
// Copy Terra into dir
|
|
||||||
doFirst {
|
|
||||||
copy {
|
|
||||||
from("${project("platforms:bukkit").buildDir}/libs/Terra-${versionObj}.jar")
|
|
||||||
into("${testDir}/plugins/")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
main = "io.papermc.paperclip.Paperclip"
|
|
||||||
jvmArgs = listOf("-XX:+UseG1GC", "-XX:+ParallelRefProcEnabled", "-XX:MaxGCPauseMillis=200",
|
|
||||||
"-XX:+UnlockExperimentalVMOptions", "-XX:+DisableExplicitGC", "-XX:+AlwaysPreTouch",
|
|
||||||
"-XX:G1NewSizePercent=30", "-XX:G1MaxNewSizePercent=40", "-XX:G1HeapRegionSize=8M",
|
|
||||||
"-XX:G1ReservePercent=20", "-XX:G1HeapWastePercent=5", "-XX:G1MixedGCCountTarget=4",
|
|
||||||
"-XX:InitiatingHeapOccupancyPercent=15", "-XX:G1MixedGCLiveThresholdPercent=90",
|
|
||||||
"-XX:G1RSetUpdatingPauseTimePercent=5", "-XX:SurvivorRatio=32", "-XX:+PerfDisableSharedMem",
|
|
||||||
"-XX:MaxTenuringThreshold=1", "-Dusing.aikars.flags=https://mcflags.emc.gs",
|
|
||||||
"-Daikars.new.flags=true", "-DIReallyKnowWhatIAmDoingISwear")
|
|
||||||
maxHeapSize = "2G"
|
|
||||||
args = listOf("nogui")
|
|
||||||
workingDir = file("${testDir}/")
|
|
||||||
classpath = files("${testDir}/paper.jar")
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
import java.io.ByteArrayOutputStream
|
||||||
|
import java.net.URL
|
||||||
|
import java.nio.channels.Channels
|
||||||
|
import java.nio.file.Files
|
||||||
|
import java.nio.file.Paths
|
||||||
|
import java.nio.file.StandardCopyOption
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
java
|
java
|
||||||
maven
|
maven
|
||||||
@@ -48,6 +55,68 @@ tasks.withType<ProcessResources> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val testDir = "target/server/"
|
||||||
|
|
||||||
|
val setupServer = tasks.create("setupServer") {
|
||||||
|
dependsOn(tasks.shadowJar)
|
||||||
|
doFirst {
|
||||||
|
// clean
|
||||||
|
file("${testDir}/").deleteRecursively()
|
||||||
|
file("${testDir}/plugins").mkdirs()
|
||||||
|
|
||||||
|
// Downloading latest paper jar.
|
||||||
|
val paperUrl = URL("https://papermc.io/api/v1/paper/1.16.4/latest/download")
|
||||||
|
val paperReadableByteChannel = Channels.newChannel(paperUrl.openStream())
|
||||||
|
val paperFile = file("${testDir}/paper.jar")
|
||||||
|
val paperFileOutputStream = paperFile.outputStream()
|
||||||
|
val paperFileChannel = paperFileOutputStream.channel
|
||||||
|
paperFileChannel.transferFrom(paperReadableByteChannel, 0, Long.MAX_VALUE)
|
||||||
|
|
||||||
|
// Cloning test setup.
|
||||||
|
gitClone("https://github.com/PolyhedralDev/WorldGenTestServer")
|
||||||
|
// Copying plugins
|
||||||
|
Files.move(Paths.get("WorldGenTestServer/plugins"),
|
||||||
|
Paths.get("$testDir/plugins"),
|
||||||
|
StandardCopyOption.REPLACE_EXISTING)
|
||||||
|
// Copying config
|
||||||
|
val serverText = URL("https://raw.githubusercontent.com/PolyhedralDev/WorldGenTestServer/master/server.properties").readText()
|
||||||
|
file("${testDir}/server.properties").writeText(serverText)
|
||||||
|
val bukkitText = URL("https://raw.githubusercontent.com/PolyhedralDev/WorldGenTestServer/master/bukkit.yml").readText()
|
||||||
|
file("${testDir}/bukkit.yml").writeText(bukkitText.replace("\${world}", "world").replace("\${gen}", "Terra:DEFAULT"))
|
||||||
|
|
||||||
|
File("${testDir}/eula.txt").writeText("eula=true")
|
||||||
|
|
||||||
|
// clean up
|
||||||
|
file("WorldGenTestServer").deleteRecursively()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val testWithPaper = task<JavaExec>(name = "testWithPaper") {
|
||||||
|
standardInput = System.`in`
|
||||||
|
dependsOn(tasks.shadowJar)
|
||||||
|
// Copy Terra into dir
|
||||||
|
doFirst {
|
||||||
|
copy {
|
||||||
|
from("${buildDir}/libs/Terra-${version}.jar")
|
||||||
|
into("${testDir}/plugins/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main = "io.papermc.paperclip.Paperclip"
|
||||||
|
jvmArgs = listOf("-XX:+UseG1GC", "-XX:+ParallelRefProcEnabled", "-XX:MaxGCPauseMillis=200",
|
||||||
|
"-XX:+UnlockExperimentalVMOptions", "-XX:+DisableExplicitGC", "-XX:+AlwaysPreTouch",
|
||||||
|
"-XX:G1NewSizePercent=30", "-XX:G1MaxNewSizePercent=40", "-XX:G1HeapRegionSize=8M",
|
||||||
|
"-XX:G1ReservePercent=20", "-XX:G1HeapWastePercent=5", "-XX:G1MixedGCCountTarget=4",
|
||||||
|
"-XX:InitiatingHeapOccupancyPercent=15", "-XX:G1MixedGCLiveThresholdPercent=90",
|
||||||
|
"-XX:G1RSetUpdatingPauseTimePercent=5", "-XX:SurvivorRatio=32", "-XX:+PerfDisableSharedMem",
|
||||||
|
"-XX:MaxTenuringThreshold=1", "-Dusing.aikars.flags=https://mcflags.emc.gs",
|
||||||
|
"-Daikars.new.flags=true", "-DIReallyKnowWhatIAmDoingISwear")
|
||||||
|
maxHeapSize = "2G"
|
||||||
|
args = listOf("nogui")
|
||||||
|
workingDir = file("${testDir}/")
|
||||||
|
classpath = files("${testDir}/paper.jar")
|
||||||
|
}
|
||||||
|
|
||||||
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
|
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
|
||||||
|
|
||||||
archiveClassifier.set("")
|
archiveClassifier.set("")
|
||||||
@@ -61,4 +130,12 @@ tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJ
|
|||||||
relocate("com.dfsek.tectonic", "com.dfsek.terra.lib.tectonic")
|
relocate("com.dfsek.tectonic", "com.dfsek.terra.lib.tectonic")
|
||||||
relocate("net.jafama", "com.dfsek.terra.lib.jafama")
|
relocate("net.jafama", "com.dfsek.terra.lib.jafama")
|
||||||
minimize()
|
minimize()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun gitClone(name: String) {
|
||||||
|
val stdout = ByteArrayOutputStream()
|
||||||
|
exec {
|
||||||
|
commandLine = mutableListOf("git", "clone", name)
|
||||||
|
standardOutput = stdout
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user