Include vanilla resources in final jar
This commit is contained in:
parent
65a0281cc3
commit
8cdb14754f
2 changed files with 50 additions and 1 deletions
|
@ -128,6 +128,12 @@ class Paperweight : Plugin<Project> {
|
|||
val applyMergedAt by tasks.registering<ApplyAccessTransform> {
|
||||
inputJar.set(vanillaTasks.fixJar.flatMap { it.outputJar })
|
||||
atFile.set(spigotTasks.mergeGeneratedAts.flatMap { it.outputFile })
|
||||
}
|
||||
|
||||
val copyResources by tasks.registering<CopyResources> {
|
||||
inputJar.set(applyMergedAt.flatMap { it.outputJar })
|
||||
vanillaJar.set(generalTasks.downloadServerJar.flatMap { it.outputJar })
|
||||
includes.set(listOf("/data/**", "/assets/**", "version.json", "yggdrasil_session_pubkey.der", "pack.mcmeta"))
|
||||
|
||||
outputJar.set(cache.resolve(Constants.FINAL_REMAPPED_JAR))
|
||||
}
|
||||
|
@ -135,7 +141,7 @@ class Paperweight : Plugin<Project> {
|
|||
val decompileJar by tasks.registering<RunForgeFlower> {
|
||||
executable.fileProvider(configurations.named(Constants.DECOMPILER_CONFIG).map { it.singleFile })
|
||||
|
||||
inputJar.set(applyMergedAt.flatMap { it.outputJar })
|
||||
inputJar.set(copyResources.flatMap { it.outputJar })
|
||||
libraries.set(vanillaTasks.downloadMcLibraries.flatMap { it.outputDir })
|
||||
}
|
||||
|
||||
|
|
43
src/main/kotlin/tasks/CopyResources.kt
Normal file
43
src/main/kotlin/tasks/CopyResources.kt
Normal file
|
@ -0,0 +1,43 @@
|
|||
package io.papermc.paperweight.tasks
|
||||
|
||||
import io.papermc.paperweight.util.file
|
||||
import io.papermc.paperweight.util.zip
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.provider.ListProperty
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.OutputFile
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
|
||||
abstract class CopyResources : BaseTask() {
|
||||
@get:InputFile
|
||||
abstract val inputJar: RegularFileProperty
|
||||
@get:InputFile
|
||||
abstract val vanillaJar: RegularFileProperty
|
||||
@get:Input
|
||||
abstract val includes: ListProperty<String>
|
||||
|
||||
@get:OutputFile
|
||||
abstract val outputJar: RegularFileProperty
|
||||
|
||||
@TaskAction
|
||||
fun run() {
|
||||
val out = outputJar.file
|
||||
val target = out.resolveSibling("${out.name}.dir")
|
||||
target.mkdirs()
|
||||
|
||||
fs.copy {
|
||||
from(archives.zipTree(vanillaJar)) {
|
||||
for (inc in this@CopyResources.includes.get()) {
|
||||
include(inc)
|
||||
}
|
||||
}
|
||||
into(target)
|
||||
from(archives.zipTree(inputJar))
|
||||
into(target)
|
||||
}
|
||||
|
||||
zip(target, outputJar)
|
||||
target.deleteRecursively()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue