diff --git a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/taskcontainers/DevBundleTasks.kt b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/taskcontainers/DevBundleTasks.kt index 5cd1ff8f..3582de2b 100644 --- a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/taskcontainers/DevBundleTasks.kt +++ b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/taskcontainers/DevBundleTasks.kt @@ -107,7 +107,6 @@ class DevBundleTasks( serverProject.set(serverProj) runtimeConfiguration.set(project.configurations.named(SERVER_RUNTIME_CLASSPATH)) - relocations.set(gson.toJson(listOf())) decompiledJar.pathProvider(decompileJar) atFile.pathProvider(accessTransformFile) diff --git a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/GenerateDevBundle.kt b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/GenerateDevBundle.kt index 5ff4581e..6854c8b5 100644 --- a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/GenerateDevBundle.kt +++ b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/GenerateDevBundle.kt @@ -33,10 +33,8 @@ import java.nio.file.Path import java.util.Locale import java.util.concurrent.TimeUnit import java.util.regex.Pattern -import java.util.stream.Collectors import javax.inject.Inject import kotlin.io.path.* -import org.apache.tools.ant.types.selectors.SelectorUtils import org.gradle.api.DefaultTask import org.gradle.api.Project import org.gradle.api.artifacts.Configuration @@ -99,9 +97,6 @@ abstract class GenerateDevBundle : DefaultTask() { @get:Classpath abstract val runtimeConfiguration: Property - @get:Input - abstract val relocations: Property - @get:Input abstract val paramMappingsUrl: Property @@ -178,8 +173,6 @@ abstract class GenerateDevBundle : DefaultTask() { workingDir.createDirectories() sourceDir.path.copyRecursivelyTo(workingDir) - relocate(relocations(), workingDir) - Files.walk(workingDir).use { stream -> decompiledJar.path.openZip().use { decompJar -> val decompRoot = decompJar.rootDirectories.single() @@ -212,60 +205,6 @@ abstract class GenerateDevBundle : DefaultTask() { workingDir.deleteRecursive() } - private fun relocate(relocations: List, workingDir: Path) { - val wrappedRelocations = relocations.map { RelocationWrapper(it) } - - Files.walk(workingDir).use { stream -> - stream.filter { it.isRegularFile() && it.name.endsWith(".java") } - .forEach { path -> replaceRelocationsInFile(path, wrappedRelocations) } - } - - relocateFiles(wrappedRelocations, workingDir) - } - - private fun replaceRelocationsInFile(path: Path, relocations: List) { - var content = path.readText(Charsets.UTF_8) - - // Use hashes as intermediary to avoid double relocating - - for (relocation in relocations) { - content = content.replace(relocation.fromDot, '.' + relocation.hashCode().toString()) - .replace(relocation.fromSlash, '/' + relocation.hashCode().toString()) - } - - for (relocation in relocations) { - content = content.replace('.' + relocation.hashCode().toString(), relocation.toDot) - .replace('/' + relocation.hashCode().toString(), relocation.toSlash) - } - - path.writeText(content, Charsets.UTF_8) - } - - private fun relocateFiles(relocations: List, workingDir: Path) { - Files.walk(workingDir).use { stream -> stream.collect(Collectors.toList()) } - .asSequence().filter { it.isRegularFile() && it.name.endsWith(".java") } - .forEach { path -> - val potential = path.relativeTo(workingDir).invariantSeparatorsPathString - for (relocation in relocations) { - if (potential.startsWith(relocation.fromSlash)) { - if (excluded(relocation.relocation, potential)) { - break - } - val dest = workingDir.resolve(potential.replace(relocation.fromSlash, relocation.toSlash)) - dest.parent.createDirectories() - path.moveTo(dest) - break - } - } - } - } - - private fun excluded(relocation: Relocation, potential: String): Boolean = relocation.excludes.map { - it.replace('.', '/') - }.any { exclude -> - SelectorUtils.matchPath(exclude, potential, true) - } - private fun diffFiles(fileName: String, original: Path, patched: Path): String { val dir = createTempDirectory("diff") try { @@ -318,7 +257,7 @@ abstract class GenerateDevBundle : DefaultTask() { } private fun asString(out: ByteArrayOutputStream) = String(out.toByteArray(), Charset.defaultCharset()) - .replace(System.getProperty("line.separator"), "\n") + .replace(System.lineSeparator(), "\n") @Suppress("SameParameterValue") private fun createBundleConfig(dataTargetDir: String, patchTargetDir: String): DevBundleConfig { @@ -334,8 +273,6 @@ abstract class GenerateDevBundle : DefaultTask() { ) } - private fun relocations(): List = gson.fromJson(relocations.get()) - private fun createBuildDataConfig(targetDir: String): BuildData { return BuildData( paramMappings = MavenDep(paramMappingsUrl.get(), listOf(paramMappingsCoordinates.get())), @@ -346,7 +283,7 @@ abstract class GenerateDevBundle : DefaultTask() { compileDependencies = determineLibraries(vanillaServerLibraries.get()).sorted(), runtimeDependencies = collectRuntimeDependencies().map { it.coordinates }.sorted(), libraryRepositories = libraryRepositories.get(), - relocations = relocations(), + relocations = emptyList(), // Nothing is relocated in the dev bundle as of 1.20.5 minecraftRemapArgs = TinyRemapper.minecraftRemapArgs, pluginRemapArgs = TinyRemapper.pluginRemapArgs, ) @@ -379,13 +316,7 @@ abstract class GenerateDevBundle : DefaultTask() { } } - val result = new.map { it.toString() }.toMutableSet() - - // Remove relocated libraries - val libs = relocations().mapNotNull { it.owningLibraryCoordinates } - result.removeIf { coords -> libs.any { coords.startsWith(it) } } - - return result + return new.map { it.toString() }.toSet() } private val ResolvedArtifactResult.coordinates: String