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