@@ -33,10 +33,8 @@ import java.nio.file.Path
33
33
import java.util.Locale
34
34
import java.util.concurrent.TimeUnit
35
35
import java.util.regex.Pattern
36
- import java.util.stream.Collectors
37
36
import javax.inject.Inject
38
37
import kotlin.io.path.*
39
- import org.apache.tools.ant.types.selectors.SelectorUtils
40
38
import org.gradle.api.DefaultTask
41
39
import org.gradle.api.Project
42
40
import org.gradle.api.artifacts.Configuration
@@ -99,9 +97,6 @@ abstract class GenerateDevBundle : DefaultTask() {
99
97
@get:Classpath
100
98
abstract val runtimeConfiguration: Property <Configuration >
101
99
102
- @get:Input
103
- abstract val relocations: Property <String >
104
-
105
100
@get:Input
106
101
abstract val paramMappingsUrl: Property <String >
107
102
@@ -178,8 +173,6 @@ abstract class GenerateDevBundle : DefaultTask() {
178
173
workingDir.createDirectories()
179
174
sourceDir.path.copyRecursivelyTo(workingDir)
180
175
181
- relocate(relocations(), workingDir)
182
-
183
176
Files .walk(workingDir).use { stream ->
184
177
decompiledJar.path.openZip().use { decompJar ->
185
178
val decompRoot = decompJar.rootDirectories.single()
@@ -212,60 +205,6 @@ abstract class GenerateDevBundle : DefaultTask() {
212
205
workingDir.deleteRecursive()
213
206
}
214
207
215
- private fun relocate (relocations : List <Relocation >, workingDir : Path ) {
216
- val wrappedRelocations = relocations.map { RelocationWrapper (it) }
217
-
218
- Files .walk(workingDir).use { stream ->
219
- stream.filter { it.isRegularFile() && it.name.endsWith(" .java" ) }
220
- .forEach { path -> replaceRelocationsInFile(path, wrappedRelocations) }
221
- }
222
-
223
- relocateFiles(wrappedRelocations, workingDir)
224
- }
225
-
226
- private fun replaceRelocationsInFile (path : Path , relocations : List <RelocationWrapper >) {
227
- var content = path.readText(Charsets .UTF_8 )
228
-
229
- // Use hashes as intermediary to avoid double relocating
230
-
231
- for (relocation in relocations) {
232
- content = content.replace(relocation.fromDot, ' .' + relocation.hashCode().toString())
233
- .replace(relocation.fromSlash, ' /' + relocation.hashCode().toString())
234
- }
235
-
236
- for (relocation in relocations) {
237
- content = content.replace(' .' + relocation.hashCode().toString(), relocation.toDot)
238
- .replace(' /' + relocation.hashCode().toString(), relocation.toSlash)
239
- }
240
-
241
- path.writeText(content, Charsets .UTF_8 )
242
- }
243
-
244
- private fun relocateFiles (relocations : List <RelocationWrapper >, workingDir : Path ) {
245
- Files .walk(workingDir).use { stream -> stream.collect(Collectors .toList()) }
246
- .asSequence().filter { it.isRegularFile() && it.name.endsWith(" .java" ) }
247
- .forEach { path ->
248
- val potential = path.relativeTo(workingDir).invariantSeparatorsPathString
249
- for (relocation in relocations) {
250
- if (potential.startsWith(relocation.fromSlash)) {
251
- if (excluded(relocation.relocation, potential)) {
252
- break
253
- }
254
- val dest = workingDir.resolve(potential.replace(relocation.fromSlash, relocation.toSlash))
255
- dest.parent.createDirectories()
256
- path.moveTo(dest)
257
- break
258
- }
259
- }
260
- }
261
- }
262
-
263
- private fun excluded (relocation : Relocation , potential : String ): Boolean = relocation.excludes.map {
264
- it.replace(' .' , ' /' )
265
- }.any { exclude ->
266
- SelectorUtils .matchPath(exclude, potential, true )
267
- }
268
-
269
208
private fun diffFiles (fileName : String , original : Path , patched : Path ): String {
270
209
val dir = createTempDirectory(" diff" )
271
210
try {
@@ -318,7 +257,7 @@ abstract class GenerateDevBundle : DefaultTask() {
318
257
}
319
258
320
259
private fun asString (out : ByteArrayOutputStream ) = String (out .toByteArray(), Charset .defaultCharset())
321
- .replace(System .getProperty( " line.separator " ), " \n " )
260
+ .replace(System .lineSeparator( ), " \n " )
322
261
323
262
@Suppress(" SameParameterValue" )
324
263
private fun createBundleConfig (dataTargetDir : String , patchTargetDir : String ): DevBundleConfig {
@@ -334,8 +273,6 @@ abstract class GenerateDevBundle : DefaultTask() {
334
273
)
335
274
}
336
275
337
- private fun relocations (): List <Relocation > = gson.fromJson(relocations.get())
338
-
339
276
private fun createBuildDataConfig (targetDir : String ): BuildData {
340
277
return BuildData (
341
278
paramMappings = MavenDep (paramMappingsUrl.get(), listOf (paramMappingsCoordinates.get())),
@@ -346,7 +283,7 @@ abstract class GenerateDevBundle : DefaultTask() {
346
283
compileDependencies = determineLibraries(vanillaServerLibraries.get()).sorted(),
347
284
runtimeDependencies = collectRuntimeDependencies().map { it.coordinates }.sorted(),
348
285
libraryRepositories = libraryRepositories.get(),
349
- relocations = relocations (),
286
+ relocations = emptyList (), // Nothing is relocated in the dev bundle as of 1.20.5
350
287
minecraftRemapArgs = TinyRemapper .minecraftRemapArgs,
351
288
pluginRemapArgs = TinyRemapper .pluginRemapArgs,
352
289
)
@@ -379,13 +316,7 @@ abstract class GenerateDevBundle : DefaultTask() {
379
316
}
380
317
}
381
318
382
- val result = new.map { it.toString() }.toMutableSet()
383
-
384
- // Remove relocated libraries
385
- val libs = relocations().mapNotNull { it.owningLibraryCoordinates }
386
- result.removeIf { coords -> libs.any { coords.startsWith(it) } }
387
-
388
- return result
319
+ return new.map { it.toString() }.toSet()
389
320
}
390
321
391
322
private val ResolvedArtifactResult .coordinates: String
0 commit comments