mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
implement shuttle
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
||||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||
import kotlin.system.measureTimeMillis
|
||||
|
||||
plugins {
|
||||
java
|
||||
@@ -91,6 +92,7 @@ subprojects {
|
||||
mavenCentral()
|
||||
maven(paperMavenPublicUrl)
|
||||
maven("https://jitpack.io")
|
||||
maven("https://s01.oss.sonatype.org/content/repositories/snapshots")
|
||||
}
|
||||
|
||||
extensions.configure<PublishingExtension> {
|
||||
@@ -105,6 +107,76 @@ subprojects {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register<Jar>("createMojmapShuttleJar") {
|
||||
dependsOn(":divinemc-server:createMojmapPaperclipJar", "shuttle:shadowJar")
|
||||
|
||||
outputs.upToDateWhen { false }
|
||||
|
||||
val paperclipJarTask = project(":divinemc-server").tasks.getByName("createMojmapPaperclipJar")
|
||||
val shuttleJarTask = project(":shuttle").tasks.getByName("shadowJar")
|
||||
|
||||
val paperclipJar = paperclipJarTask.outputs.files.singleFile
|
||||
val shuttleJar = shuttleJarTask.outputs.files.singleFile
|
||||
val outputDir = paperclipJar.parentFile
|
||||
val tempDir = File(outputDir, "tempJarWork")
|
||||
val newJarName = "divinemc-shuttle-${properties["version"]}-mojmap.jar"
|
||||
|
||||
doFirst {
|
||||
val time = measureTimeMillis {
|
||||
println("Recompiling Paperclip with Shuttle sources...")
|
||||
|
||||
tempDir.deleteRecursively()
|
||||
tempDir.mkdirs()
|
||||
|
||||
copy {
|
||||
from(zipTree(paperclipJar))
|
||||
into(tempDir)
|
||||
}
|
||||
|
||||
val oldPackagePath = "io/papermc/paperclip/"
|
||||
tempDir.walkTopDown()
|
||||
.filter { it.isFile && it.relativeTo(tempDir).path.startsWith(oldPackagePath) }
|
||||
.forEach { it.delete() }
|
||||
|
||||
val shuttlePackagePath = "org/bxteam/shuttle/"
|
||||
copy {
|
||||
from(zipTree(shuttleJar))
|
||||
include("$shuttlePackagePath**")
|
||||
into(tempDir)
|
||||
}
|
||||
|
||||
tempDir.walkBottomUp()
|
||||
.filter { it.isDirectory && it.listFiles().isNullOrEmpty() }
|
||||
.forEach { it.delete() }
|
||||
|
||||
val metaInfDir = File(tempDir, "META-INF")
|
||||
metaInfDir.mkdirs()
|
||||
File(metaInfDir, "main-class").writeText("net.minecraft.server.Main")
|
||||
}
|
||||
println("Finished build in ${time}ms")
|
||||
}
|
||||
|
||||
archiveFileName.set(newJarName)
|
||||
destinationDirectory.set(outputDir)
|
||||
from(tempDir)
|
||||
|
||||
manifest {
|
||||
attributes(
|
||||
"Main-Class" to "org.bxteam.shuttle.Shuttle",
|
||||
"Enable-Native-Access" to "ALL-UNNAMED",
|
||||
"Premain-Class" to "org.bxteam.shuttle.patch.InstrumentationManager",
|
||||
"Agent-Class" to "org.bxteam.shuttle.patch.InstrumentationManager",
|
||||
"Launcher-Agent-Class" to "org.bxteam.shuttle.patch.InstrumentationManager",
|
||||
"Can-Redefine-Classes" to true,
|
||||
"Can-Retransform-Classes" to true
|
||||
)
|
||||
}
|
||||
|
||||
doLast {
|
||||
tempDir.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("printMinecraftVersion") {
|
||||
doLast {
|
||||
println(providers.gradleProperty("mcVersion").get().trim())
|
||||
|
||||
Reference in New Issue
Block a user