@@ -348,6 +348,35 @@ fun FileCollection.toJarClassProviderRoots(): List<ClassProviderRoot> = files.as
348
348
.map { p -> ClassProviderRoot .fromJar(p) }
349
349
.toList()
350
350
351
+ // Longest path as of 1.20.4
352
+ private const val longestPath: String =
353
+ " paperweight/mc-dev-sources/data/minecraft/datapacks/update_1_21/data/minecraft/advancements/" +
354
+ " recipes/building_blocks/waxed_weathered_chiseled_copper_from_waxed_weathered_cut_copper_stonecutting.json"
355
+
356
+ fun testPathLength (projectLayout : ProjectLayout ) {
357
+ if (System .getProperty(" os.name" ).lowercase().contains(" win" )) {
358
+ val tmpProjDir = projectLayout.projectDirectory.path.resolveSibling(
359
+ projectLayout.projectDirectory.path.name + " _"
360
+ )
361
+ val cache = tmpProjDir.resolve(" .gradle/$CACHE_PATH " )
362
+ val testFile = cache.resolve(longestPath)
363
+
364
+ try {
365
+ testFile.parent.createDirectories()
366
+ testFile.writeText(" test" )
367
+ } catch (e: Exception ) {
368
+ throw PaperweightException (
369
+ " The directory this project is cloned in is too nested. Either enable long paths in Windows and Git, or use WSL.\n " +
370
+ " Windows documentation: https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry\n " +
371
+ " Git command: git config --global core.longpaths true" ,
372
+ e
373
+ )
374
+ } finally {
375
+ tmpProjDir.deleteRecursive()
376
+ }
377
+ }
378
+ }
379
+
351
380
private fun javaVersion (): Int {
352
381
val version = System .getProperty(" java.specification.version" )
353
382
val parts = version.split(" \\ ." .toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
0 commit comments