Skip to content

Commit cecca9d

Browse files
committed
try to remap patches
1 parent a1acc70 commit cecca9d

File tree

3 files changed

+474
-2
lines changed

3 files changed

+474
-2
lines changed

paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/PatchRemapTasks.kt

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,44 @@ open class PatchRemapTasks(
8383

8484
val patchCraftBukkit by tasks.registering<ApplyCraftBukkitPatches> {
8585
// TODO temp to speed stuff up
86-
//sourceJar.set(spigotDecompileJar.flatMap { it.outputJar })
87-
sourceJar.set(cache.resolve("paperweight/taskCache/spigotDecompileJar.jar"))
86+
sourceJar.set(spigotDecompileJar.flatMap { it.outputJar })
87+
//sourceJar.set(cache.resolve("paperweight/taskCache/spigotDecompileJar.jar"))
8888
cleanDirPath.set("net/minecraft")
8989
patchDir.set(extension.patchRemap.patchDir)
9090
craftBukkitDir.set(extension.patchRemap.craftBukkitDir)
9191
outputDir.set(extension.patchRemap.patchedCraftBukkitDir)
9292

9393
//dependsOn(cloneForPatchRemap)
9494
}
95+
96+
//val filterSpigotMojMapExcludes by tasks.registering<FilterSpigotExcludes> {
97+
// inputZip.set(spigotMojMapRemapJar.flatMap { it.outputJar })
98+
// excludesFile.set(extension.patchRemap.excludesFile)
99+
//}
100+
//
101+
//val spigotDecompileMojMapJar by tasks.registering<SpigotDecompileJar> {
102+
// inputJar.set(filterSpigotMojMapExcludes.flatMap { it.outputZip })
103+
// fernFlowerJar.set(extension.patchRemap.fernFlowerJar)
104+
// decompileCommand.set(buildDataInfo.map { it.decompileCommand })
105+
//}
106+
107+
val remapCraftBukkitSources by tasks.registering<RemapSources> {
108+
vanillaJar.set(allTasks.extractFromBundler.flatMap { it.serverJar })
109+
//mojangMappedVanillaJar.set(fixJar.flatMap { it.outputJar })
110+
//vanillaRemappedSpigotJar.set(filterSpigotExcludes.flatMap { it.outputZip })
111+
//mappings.set(generateSpigotMappings.flatMap { it.outputMappings })
112+
mappings.set(cache.resolve(SPIGOT_MOJANG_YARN_MAPPINGS))
113+
//sources.set(patchCraftBukkit.flatMap { it.outputDir }) // todo temp to speed stuff up
114+
sources.set(extension.patchRemap.patchedCraftBukkitDir);
115+
//spigotDeps.from(downloadSpigotDependencies.map { it.outputDir.asFileTree })
116+
//additionalAts.set(mergePaperAts.flatMap { it.outputFile })
117+
}
118+
119+
// todo first try diffing against remapped mcp config source
120+
// if that fails, we have to diff against spigot decompiled mojmap+yarn mapped vanilla jar
121+
val diffCraftBukkitAgainstVanilla by tasks.registering<DiffCraftBukkitAgainstVanilla> {
122+
craftBukkit.set(remapCraftBukkitSources.flatMap { it.sourcesOutputZip })
123+
//vanilla.set(allTasks.prepareBase.flatMap { it.output })
124+
vanilla.set(cache.resolve(BASE_PROJECT))
125+
}
95126
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package io.papermc.paperweight.tasks.patchremap
2+
3+
import codechicken.diffpatch.cli.DiffOperation
4+
import io.papermc.paperweight.tasks.BaseTask
5+
import io.papermc.paperweight.util.defaultOutput
6+
import io.papermc.paperweight.util.filesMatchingRecursive
7+
import io.papermc.paperweight.util.path
8+
import org.gradle.api.file.DirectoryProperty
9+
import org.gradle.api.file.RegularFileProperty
10+
import org.gradle.api.tasks.InputDirectory
11+
import org.gradle.api.tasks.InputFile
12+
import org.gradle.api.tasks.OutputDirectory
13+
import org.gradle.api.tasks.TaskAction
14+
import java.nio.file.Files
15+
16+
abstract class DiffCraftBukkitAgainstVanilla: BaseTask() {
17+
18+
@get:InputFile
19+
abstract val craftBukkit: RegularFileProperty
20+
21+
@get:InputDirectory
22+
abstract val vanilla: DirectoryProperty
23+
24+
@get:OutputDirectory
25+
abstract val patches: RegularFileProperty
26+
27+
override fun init() {
28+
patches.convention(defaultOutput())
29+
}
30+
31+
@TaskAction
32+
open fun run() {
33+
val diffOp = DiffOperation.builder()
34+
.logTo(System.out)
35+
.aPath(vanilla.path.resolve("src/vanilla"))
36+
.bPath(craftBukkit.path)
37+
.outputPath(patches.path.resolve("dum"))
38+
.verbose(false)
39+
.summary(true)
40+
.lineEnding("\n")
41+
//.ignorePattern(ignorePattern.get())
42+
.build()
43+
44+
diffOp.operate()
45+
46+
patches.path.resolve("dum").filesMatchingRecursive("*.patch").forEach { p ->
47+
if (Files.readAllLines(p)[1].contains("+++ /dev/null")) {
48+
Files.delete(p)
49+
}
50+
}
51+
Files.walk(patches.path.resolve("dum"))
52+
.filter { Files.isDirectory(it) }
53+
.filter { it.toFile().listFiles()?.isEmpty() ?: false }
54+
.forEach { Files.delete(it) }
55+
}
56+
}

0 commit comments

Comments
 (0)