Skip to content

Commit

Permalink
Rename src/vanilla to src/minecraft
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Dec 20, 2024
1 parent bd0e9e5 commit 62ab0ce
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ abstract class ForkConfig @Inject constructor(

val rootDirectory: DirectoryProperty = objects.directoryProperty().convention(layout.projectDirectory.dir("../"))
val serverDirectory: DirectoryProperty = objects.dirFrom(rootDirectory, providers.provider { "$name-server" })
val serverPatchesDir: DirectoryProperty = objects.dirFrom(serverDirectory, "vanilla-patches")
val serverPatchesDir: DirectoryProperty = objects.dirFrom(serverDirectory, "minecraft-patches")
val rejectsDir: DirectoryProperty = objects.dirFrom(serverPatchesDir, "rejected")
val sourcePatchDir: DirectoryProperty = objects.dirFrom(serverPatchesDir, "sources")
val resourcePatchDir: DirectoryProperty = objects.dirFrom(serverPatchesDir, "resources")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
package io.papermc.paperweight.core.taskcontainers

import io.papermc.paperweight.core.extension.ForkConfig
import io.papermc.paperweight.core.tasks.ForkSetup
import io.papermc.paperweight.core.tasks.SetupForkMinecraftSources
import io.papermc.paperweight.core.tasks.patching.ApplyFilePatches
import io.papermc.paperweight.core.tasks.patching.ApplyFilePatchesFuzzy
import io.papermc.paperweight.tasks.*
Expand Down Expand Up @@ -59,21 +59,21 @@ class ServerPatchingTasks(
private val baseResources: Provider<Directory>,
private val gitFilePatches: Provider<Boolean>,
outputRoot: Path,
private val outputSrc: Path = outputRoot.resolve("src/vanilla/java"),
private val outputResources: Path = outputRoot.resolve("src/vanilla/resources"),
private val outputSrcFile: Path = outputRoot.resolve("file/src/vanilla/java"),
private val outputSrc: Path = outputRoot.resolve("src/minecraft/java"),
private val outputResources: Path = outputRoot.resolve("src/minecraft/resources"),
private val outputSrcFile: Path = outputRoot.resolve("file/src/minecraft/java"),
private val tasks: TaskContainer = project.tasks
) {
private val taskGroup = if (readOnly) "upstream vanilla server patching" else "vanilla server patching"
private val taskGroup = if (readOnly) "upstream minecraft patching" else "minecraft patching"
private fun Task.group() {
group = taskGroup
}

private val namePart = if (readOnly) "${configName.capitalized()}Vanilla" else if (paper) "" else "Vanilla"
private val namePart = if (readOnly) "${configName.capitalized()}Minecraft" else if (paper) "" else "Minecraft"

private fun ApplyFilePatches.configureApplyFilePatches() {
group()
description = "Applies $configName file patches to the vanilla sources"
description = "Applies $configName file patches to the Minecraft sources"

input.set(baseSources)
if (readOnly) {
Expand All @@ -97,7 +97,7 @@ class ServerPatchingTasks(

val applyResourcePatches = tasks.register<ApplyFilePatches>("apply${namePart}ResourcePatches") {
group()
description = "Applies $configName file patches to the vanilla resources"
description = "Applies $configName file patches to the Minecraft resources"

input.set(baseResources)
output.set(outputResources)
Expand All @@ -109,13 +109,13 @@ class ServerPatchingTasks(

val applyFilePatches = tasks.register<Task>("apply${namePart}FilePatches") {
group()
description = "Applies all $configName vanilla file patches"
description = "Applies all $configName Minecraft file patches"
dependsOn(applySourcePatches, applyResourcePatches)
}

val applyFeaturePatches = tasks.register<ApplyFeaturePatches>("apply${namePart}FeaturePatches") {
group()
description = "Applies all $configName vanilla feature patches"
description = "Applies all $configName Minecraft feature patches"
dependsOn(applyFilePatches)

if (readOnly) {
Expand All @@ -127,7 +127,7 @@ class ServerPatchingTasks(

val applyPatches = tasks.register<Task>("apply${namePart}Patches") {
group()
description = "Applies all $configName vanilla patches"
description = "Applies all $configName Minecraft patches"
dependsOn(applyFilePatches, applyFeaturePatches)
}

Expand Down Expand Up @@ -160,8 +160,8 @@ class ServerPatchingTasks(
libraries.from(softspoon.indexLibraryFiles.map { it.libraries })
}

val setup = tasks.register<ForkSetup>("run${namePart}Setup") {
description = "Applies $configName ATs and library imports to vanilla sources"
val setup = tasks.register<SetupForkMinecraftSources>("run${namePart}Setup") {
description = "Applies $configName ATs and library imports to Minecraft sources"

inputDir.set(baseSources)
outputDir.set(layout.cache.resolve(paperTaskOutput()))
Expand Down Expand Up @@ -201,7 +201,7 @@ class ServerPatchingTasks(

val rebuildSourcePatches = tasks.register<RebuildFilePatches>(rebuildSourcePatchesName) {
group()
description = "Rebuilds $configName file patches to the vanilla sources"
description = "Rebuilds $configName file patches to the Minecraft sources"

base.set(baseSources)
input.set(outputSrc)
Expand All @@ -216,7 +216,7 @@ class ServerPatchingTasks(

val rebuildResourcePatches = tasks.register<RebuildFilePatches>(rebuildResourcePatchesName) {
group()
description = "Rebuilds $configName file patches to the vanilla resources"
description = "Rebuilds $configName file patches to the Minecraft resources"

base.set(baseResources)
input.set(outputResources)
Expand All @@ -225,13 +225,13 @@ class ServerPatchingTasks(

val rebuildFilePatches = tasks.register<Task>(rebuildFilePatchesName) {
group()
description = "Rebuilds all $configName file patches to vanilla"
description = "Rebuilds all $configName file patches to Minecraft"
dependsOn(rebuildSourcePatches, rebuildResourcePatches)
}

val rebuildFeaturePatches = tasks.register<RebuildGitPatches>(rebuildFeaturePatchesName) {
group()
description = "Rebuilds all $configName feature patches to the vanilla sources"
description = "Rebuilds all $configName feature patches to the Minecraft sources"
dependsOn(rebuildFilePatches)

inputDir.set(outputSrc)
Expand All @@ -241,21 +241,21 @@ class ServerPatchingTasks(

val rebuildPatches = tasks.register<Task>(rebuildPatchesName) {
group()
description = "Rebuilds all $configName patches to vanilla"
description = "Rebuilds all $configName patches to Minecraft"
dependsOn(rebuildFilePatches, rebuildFeaturePatches)
}

val fixupSourcePatches = tasks.register<FixupFilePatches>("fixup${namePart}SourcePatches") {
group()
description = "Puts the currently tracked source changes into the $configName vanilla sources file patches commit"
description = "Puts the currently tracked source changes into the $configName Minecraft sources file patches commit"

repo.set(outputSrc)
upstream.set("upstream/main")
}

val fixupResourcePatches = tasks.register<FixupFilePatches>("fixup${namePart}ResourcePatches") {
group()
description = "Puts the currently tracked resource changes into the $configName vanilla resources file patches commit"
description = "Puts the currently tracked resource changes into the $configName Minecraft resources file patches commit"

repo.set(outputResources)
upstream.set("upstream/main")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ package io.papermc.paperweight.core.taskcontainers

import io.papermc.paperweight.core.coreExt
import io.papermc.paperweight.core.extension.ForkConfig
import io.papermc.paperweight.core.tasks.SetupVanilla
import io.papermc.paperweight.core.tasks.SetupMinecraftSources
import io.papermc.paperweight.tasks.*
import io.papermc.paperweight.tasks.mache.DecompileJar
import io.papermc.paperweight.tasks.mache.RemapJar
Expand Down Expand Up @@ -127,7 +127,7 @@ class SoftSpoonTasks(
libraries.from(indexLibraryFiles.map { it.libraries })
}

private fun SetupVanilla.configureSetupMacheSources() {
private fun SetupMinecraftSources.configureSetupMacheSources() {
group = "mache"

mache.from(project.configurations.named(MACHE_CONFIG))
Expand All @@ -136,8 +136,8 @@ class SoftSpoonTasks(
predicate.set { Files.isRegularFile(it) && it.toString().endsWith(".java") }
}

val setupMacheSources by tasks.registering(SetupVanilla::class) {
description = "Setup vanilla source dir (applying mache patches and paper ATs)."
val setupMacheSources by tasks.registering(SetupMinecraftSources::class) {
description = "Setup Minecraft source dir (applying mache patches and paper ATs)."
configureSetupMacheSources()
libraryImports.set(importLibraryFiles.flatMap { it.outputDir })
outputDir.set(layout.cache.resolve(BASE_PROJECT).resolve("sources"))
Expand All @@ -147,15 +147,15 @@ class SoftSpoonTasks(
ats.jst.from(jstConfig)
}

val setupMacheSourcesForDevBundle by tasks.registering(SetupVanilla::class) {
description = "Setup vanilla source dir (applying mache patches)."
val setupMacheSourcesForDevBundle by tasks.registering(SetupMinecraftSources::class) {
description = "Setup Minecraft source dir (applying mache patches)."
configureSetupMacheSources()
outputDir.set(layout.cache.resolve(BASE_PROJECT).resolve("sources_dev_bundle"))
}

val setupMacheResources by tasks.registering(SetupVanilla::class) {
val setupMacheResources by tasks.registering(SetupMinecraftSources::class) {
group = "mache"
description = "Setup vanilla resources dir"
description = "Setup Minecraft resources dir"

inputFile.set(allTasks.extractFromBundler.flatMap { it.serverJar })
predicate.set { Files.isRegularFile(it) && !it.toString().endsWith(".class") }
Expand Down Expand Up @@ -199,13 +199,13 @@ class SoftSpoonTasks(
extendsFrom(macheMinecraftLibraries.get())
}

// add vanilla source set
// add Minecraft source dir
project.the<JavaPluginExtension>().sourceSets.named(SourceSet.MAIN_SOURCE_SET_NAME) {
java {
srcDirs(project.projectDir.resolve("src/vanilla/java"))
srcDirs(project.projectDir.resolve("src/minecraft/java"))
}
resources {
srcDirs(project.projectDir.resolve("src/vanilla/resources"))
srcDirs(project.projectDir.resolve("src/minecraft/resources"))
}
}
}
Expand All @@ -222,7 +222,7 @@ class SoftSpoonTasks(
}
}

// Setup Paper's vanilla patching tasks
// Setup Paper's Minecraft patching tasks
val paperOutputRoot = if (hasFork) {
project.upstreamsDirectory().get().path.resolve("server-work/paper")
} else {
Expand Down Expand Up @@ -312,45 +312,45 @@ class SoftSpoonTasks(
cfg.upstream.directoryPatchSets.names.joinToString(", ")
)

// setup aggregate vanilla & upstream -server patching tasks
// setup aggregate Minecraft & upstream -server patching tasks
val applyAllServerFilePatches = project.tasks.register("applyAllServerFilePatches") {
group = "patching"
description = "Applies all vanilla and upstream server file patches " +
description = "Applies all Minecraft and upstream server file patches " +
"(equivalent to '${serverTasks.applyFilePatches.name} applyServerFilePatches')"
dependsOn(serverTasks.applyFilePatches)
dependsOn("applyServerFilePatches")
}
val applyAllServerFeaturePatches = project.tasks.register("applyAllServerFeaturePatches") {
group = "patching"
description = "Applies all vanilla and upstream server feature patches " +
description = "Applies all Minecraft and upstream server feature patches " +
"(equivalent to '${serverTasks.applyFeaturePatches.name} applyServerFeaturePatches')"
dependsOn(serverTasks.applyFeaturePatches)
dependsOn("applyServerFeaturePatches")
}
val applyAllServerPatches = project.tasks.register("applyAllServerPatches") {
group = "patching"
description = "Applies all vanilla and upstream server patches " +
description = "Applies all Minecraft and upstream server patches " +
"(equivalent to '${serverTasks.applyPatches.name} applyServerPatches')"
dependsOn(serverTasks.applyPatches)
dependsOn("applyServerPatches")
}
val rebuildAllServerFilePatches = project.tasks.register("rebuildAllServerFilePatches") {
group = "patching"
description = "Rebuilds all vanilla and upstream server file patches " +
description = "Rebuilds all Minecraft and upstream server file patches " +
"(equivalent to '${serverTasks.rebuildFilePatchesName} rebuildServerFilePatches')"
dependsOn(serverTasks.rebuildFilePatchesName)
dependsOn("rebuildServerFilePatches")
}
val rebuildAllServerFeaturePatches = project.tasks.register("rebuildAllServerFeaturePatches") {
group = "patching"
description = "Rebuilds all vanilla and upstream server feature patches " +
description = "Rebuilds all Minecraft and upstream server feature patches " +
"(equivalent to '${serverTasks.rebuildFeaturePatchesName} rebuildServerFeaturePatches')"
dependsOn(serverTasks.rebuildFeaturePatchesName)
dependsOn("rebuildServerFeaturePatches")
}
val rebuildAllServerPatches = project.tasks.register("rebuildAllServerPatches") {
group = "patching"
description = "Rebuilds all vanilla and upstream server patches " +
description = "Rebuilds all Minecraft and upstream server patches " +
"(equivalent to '${serverTasks.rebuildPatchesName} rebuildServerPatches')"
dependsOn(serverTasks.rebuildPatchesName)
dependsOn("rebuildServerPatches")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import org.gradle.kotlin.dsl.*

abstract class ForkSetup : JavaLauncherTask() {
abstract class SetupForkMinecraftSources : JavaLauncherTask() {

@get:InputDirectory
abstract val inputDir: DirectoryProperty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import org.gradle.kotlin.dsl.*

abstract class SetupVanilla : JavaLauncherTask() {
abstract class SetupMinecraftSources : JavaLauncherTask() {

@get:PathSensitive(PathSensitivity.NONE)
@get:InputFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ class FunctionalTest {

// add AT to source -> patch and AT file is updated
println("adding at to source")
modifyFile(tempDir.resolve("test-server/src/vanilla/java/Test.java")) {
modifyFile(tempDir.resolve("test-server/src/minecraft/java/Test.java")) {
it.replace(
"\"2\";",
"\"2\"; // Woo"
).replace("public final String getTest2() {", "public String getTest2() {// Paper-AT: public-f getTest2()Ljava/lang/String;")
}

Git(tempDir.resolve("test-server/src/vanilla/java")).let { git ->
Git(tempDir.resolve("test-server/src/minecraft/java")).let { git ->
git("add", ".").executeSilently()
git("commit", "--fixup", "file").executeSilently()
git("rebase", "--autosquash", "upstream/main").executeSilently()
Expand All @@ -120,11 +120,11 @@ class FunctionalTest {

// feature patch
println("\nmodifying feature patch\n")
modifyFile(tempDir.resolve("test-server/src/vanilla/java/Test.java")) {
modifyFile(tempDir.resolve("test-server/src/minecraft/java/Test.java")) {
it.replace("wonderful feature", "amazing feature")
}

Git(tempDir.resolve("test-server/src/vanilla/java")).let { git ->
Git(tempDir.resolve("test-server/src/minecraft/java")).let { git ->
git("add", ".").executeSilently()
git("commit", "--amend", "--no-edit").executeSilently()
}
Expand Down Expand Up @@ -163,9 +163,9 @@ class FunctionalTest {
.build()

assertEquals(appP2.task(":test-server:applyPatches")?.outcome, TaskOutcome.SUCCESS)
assertContains(tempDir.resolve("test-server/src/vanilla/java/oshi/PlatformEnum.java").readText(), "Windows CE")
assertFalse(tempDir.resolve("test-server/src/vanilla/java/oshi/SystemInfo.java").readText().contains("MACOS"))
assertContains(tempDir.resolve("test-server/src/vanilla/java/org/alcibiade/asciiart/widget/PictureWidget.java").readText(), "Trollface")
assertContains(tempDir.resolve("test-server/src/minecraft/java/oshi/PlatformEnum.java").readText(), "Windows CE")
assertFalse(tempDir.resolve("test-server/src/minecraft/java/oshi/SystemInfo.java").readText().contains("MACOS"))
assertContains(tempDir.resolve("test-server/src/minecraft/java/org/alcibiade/asciiart/widget/PictureWidget.java").readText(), "Trollface")
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,24 @@ abstract class SetupPaperScript : BaseTask() {
Command("root", listOf(), "Jumps to the root directory (%root%)", listOf("cd %root%")),
Command("api", listOf("a"), "Jumps to the api directory", listOf("cd %root%/paper-api")),
Command("server", listOf("s"), "Jumps to the server directory", listOf("cd %root%/paper-server")),
Command("vanilla", listOf("v"), "Jumps to the vanilla directory", listOf("cd %root%/paper-server/src/vanilla/java")),
Command("resources", listOf("r"), "Jumps to the resources directory", listOf("cd %root%/paper-server/src/vanilla/resources")),
Command(
"minecraft",
listOf("m"),
"Jumps to the Minecraft sources directory",
listOf("cd %root%/paper-server/src/minecraft/java")
),
Command(
"resources",
listOf("r"),
"Jumps to the Minecraft resources directory",
listOf("cd %root%/paper-server/src/minecraft/resources")
),
Command(
"fixupSourcePatches",
listOf("fs"),
"Puts the current source changes into the file patches commit",
listOf(
"cd %root%/paper-server/src/vanilla/java",
"cd %root%/paper-server/src/minecraft/java",
"git add .",
"git commit --fixup file",
"git -c sequence.editor=: rebase -i --autosquash mache/main"
Expand All @@ -82,7 +92,7 @@ abstract class SetupPaperScript : BaseTask() {
listOf("fr"),
"Puts the current resource changes into the file patches commit",
listOf(
"cd %root%/paper-server/src/vanilla/resources",
"cd %root%/paper-server/src/minecraft/resources",
"git add .",
"git commit --fixup file",
"git -c sequence.editor=: rebase -i --autosquash mache/main"
Expand Down

0 comments on commit 62ab0ce

Please sign in to comment.