Change back to our deleteRecursive utility instead of Kotlin's new built in one

Also, all the experimental path api we were using is stable now, so remove the opt-in flag
This commit is contained in:
Jason Penilla 2023-11-21 12:24:32 -07:00
parent 87e8db20d0
commit 7669316eac
No known key found for this signature in database
GPG key ID: 0E75A301420E48F8
23 changed files with 39 additions and 42 deletions

View file

@ -58,10 +58,7 @@ testing {
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "11"
freeCompilerArgs = listOf(
"-Xjvm-default=all",
"-opt-in=kotlin.io.path.ExperimentalPathApi"
)
freeCompilerArgs = listOf("-Xjvm-default=all")
}
}

View file

@ -82,7 +82,7 @@ abstract class ApplyCraftBukkitPatches : ControllableOutputTask() {
fun run() {
Git.checkForGit()
outputDir.path.deleteRecursively()
outputDir.path.deleteRecursive()
outputDir.path.parent.let {
it.createDirectories()
val git = Git(it)
@ -92,7 +92,7 @@ abstract class ApplyCraftBukkitPatches : ControllableOutputTask() {
val git = Git(outputDir.path)
val basePatchDirFile = outputDir.path.resolve("src/main/java")
basePatchDirFile.resolve(cleanDirPath.get()).deleteRecursively()
basePatchDirFile.resolve(cleanDirPath.get()).deleteRecursive()
val patchSource = patchDir.pathOrNull ?: patchZip.path // used for error messages
val rootPatchDir = patchDir.pathOrNull ?: patchZip.path.let { unzip(it, findOutputDir(it)) }
@ -138,7 +138,7 @@ abstract class ApplyCraftBukkitPatches : ControllableOutputTask() {
git("commit", "-m", "CraftBukkit $ ${Date()}", "--author=CraftBukkit <auto@mated.null>").setupOut().execute()
} finally {
if (rootPatchDir != patchDir.pathOrNull) {
rootPatchDir.deleteRecursively()
rootPatchDir.deleteRecursive()
}
}
}

View file

@ -101,7 +101,7 @@ abstract class ApplyGitPatches : ControllableOutputTask() {
checkoutRepoFromUpstream(git, upstream.path, upstreamBranch.get())
if (unneededFiles.isPresent && unneededFiles.get().size > 0) {
unneededFiles.get().forEach { path -> outputDir.path.resolve(path).deleteRecursively() }
unneededFiles.get().forEach { path -> outputDir.path.resolve(path).deleteRecursive() }
git(*Git.add(ignoreGitIgnore, ".")).setupOut().run()
git("commit", "-m", "Initial", "--author=Initial Source <auto@mated.null>").setupOut().run()
}
@ -113,7 +113,7 @@ abstract class ApplyGitPatches : ControllableOutputTask() {
}
} finally {
if (rootPatchDir != patchDir.pathOrNull) {
rootPatchDir.deleteRecursively()
rootPatchDir.deleteRecursive()
}
}
}
@ -168,7 +168,7 @@ fun ControllableOutputTask.applyGitPatches(
}
}
} finally {
tempDir.deleteRecursively()
tempDir.deleteRecursive()
}
}
@ -198,7 +198,7 @@ fun recreateCloneDirectory(target: Path) {
git("reset", "--hard", "HEAD").runSilently(silenceErr = true)
} else {
for (entry in target.listDirectoryEntries()) {
entry.deleteRecursively()
entry.deleteRecursive()
}
target.createDirectories()
}

View file

@ -154,7 +154,7 @@ abstract class ApplyPaperPatches : ControllableOutputTask() {
git("mv", "-f", obfFile.toString(), deobfFile.toString()).runSilently(silenceErr = true)
}
unneededFiles.orNull?.forEach { path -> outputFile.resolve(path).deleteRecursively() }
unneededFiles.orNull?.forEach { path -> outputFile.resolve(path).deleteRecursive() }
git(*Git.add(ignoreGitIgnore, ".")).executeSilently()
git("commit", "-m", "Initial", "--author=Initial Source <auto@mated.null>").executeSilently()
@ -168,7 +168,7 @@ abstract class ApplyPaperPatches : ControllableOutputTask() {
}
private fun createDir(dir: Path): Path {
dir.deleteRecursively()
dir.deleteRecursive()
dir.createDirectories()
return dir
}

View file

@ -68,6 +68,6 @@ abstract class CopyResources : BaseTask() {
}
zip(target, outputJar)
target.deleteRecursively()
target.deleteRecursive()
}
}

View file

@ -57,7 +57,7 @@ abstract class CreateDiffOutput : BaseTask() {
fun run() {
val output = outputDir.path
output.deleteRecursively()
output.deleteRecursive()
inputDir.path.copyRecursivelyTo(output)
}
}

View file

@ -115,7 +115,7 @@ object ServerBundler {
}
private fun extractLibraryJars(bundlerZip: Path, serverLibraryJars: Path) {
serverLibraryJars.deleteRecursively()
serverLibraryJars.deleteRecursive()
serverLibraryJars.parent.createDirectories()
bundlerZip.resolve("/META-INF/libraries").copyRecursivelyTo(serverLibraryJars)
}

View file

@ -81,7 +81,7 @@ abstract class FilterProjectDir : BaseTask() {
}
zip(target, output)
target.deleteRecursively()
target.deleteRecursive()
}
private fun collectFiles(dir: Path): Set<String> {

View file

@ -170,13 +170,13 @@ abstract class GenerateDevBundle : DefaultTask() {
tempPatchDir.copyRecursivelyTo(patchesZip)
}
} finally {
tempPatchDir.deleteRecursively()
tempPatchDir.deleteRecursive()
}
}
private fun generatePatches(output: Path) {
val workingDir = layout.cache.resolve(paperTaskOutput("tmpdir"))
workingDir.deleteRecursively()
workingDir.deleteRecursive()
workingDir.createDirectories()
sourceDir.path.copyRecursivelyTo(workingDir)
@ -211,7 +211,7 @@ abstract class GenerateDevBundle : DefaultTask() {
}
}
workingDir.deleteRecursively()
workingDir.deleteRecursive()
}
private fun relocate(relocations: List<Relocation>, workingDir: Path) {
@ -289,7 +289,7 @@ abstract class GenerateDevBundle : DefaultTask() {
return runDiff(dir, args)
} finally {
dir.deleteRecursively()
dir.deleteRecursive()
}
}

View file

@ -89,7 +89,7 @@ abstract class RebuildGitPatches : ControllableOutputTask() {
}
}
} else {
patchFolder.deleteRecursively()
patchFolder.deleteRecursive()
patchFolder.createDirectories()
}

View file

@ -169,8 +169,8 @@ abstract class RemapSources : JavaLauncherTask() {
writeSpigotRecompiledFiles(srcOut)
} finally {
srcOut.deleteRecursively()
testOut.deleteRecursively()
srcOut.deleteRecursive()
testOut.deleteRecursive()
}
}
@ -246,7 +246,7 @@ abstract class RemapSources : JavaLauncherTask() {
tempOut.copyRecursivelyTo(parameters.outputDir.path)
}
} finally {
tempOut.deleteRecursively()
tempOut.deleteRecursive()
}
}

View file

@ -93,7 +93,7 @@ abstract class SpigotDecompileJar : JavaLauncherTask() {
ensureDeleted(outputJarFile)
decomp.resolve(inputJarFile.name).moveTo(outputJarFile)
} finally {
decomp.deleteRecursively()
decomp.deleteRecursive()
}
}
}

View file

@ -65,7 +65,7 @@ abstract class ZippedTask : BaseTask() {
zip(outputDir, outputZipFile)
} finally {
outputDir.deleteRecursively()
outputDir.deleteRecursive()
}
}
}

View file

@ -114,7 +114,7 @@ fun downloadMinecraftLibraries(
sources: Boolean
): WorkQueue {
val excludes = listOf(targetDir.fileSystem.getPathMatcher("glob:*.etag"))
targetDir.deleteRecursively(excludes)
targetDir.deleteRecursive(excludes)
val queue = workerExecutor.noIsolation()
@ -175,11 +175,11 @@ abstract class DownloadSpigotDependencies : BaseTask() {
val out = outputDir.path
val excludes = listOf(out.fileSystem.getPathMatcher("glob:*.etag"))
out.deleteRecursively(excludes)
out.deleteRecursive(excludes)
val outSources = outputSourcesDir.path
val excludesSources = listOf(outSources.fileSystem.getPathMatcher("glob:*.etag"))
outSources.deleteRecursively(excludesSources)
outSources.deleteRecursive(excludesSources)
val spigotRepos = mutableSetOf<String>()
spigotRepos += apiSetup.repos

View file

@ -99,7 +99,7 @@ class PatchApplier(
}
fun generatePatches(target: Path) {
target.deleteRecursively()
target.deleteRecursive()
target.createDirectories()
git("checkout", remappedBranch).executeSilently()
git(

View file

@ -66,13 +66,13 @@ class PatchSourceRemapWorker(
}
private fun setup() {
outputDir.deleteRecursively()
outputDir.deleteRecursive()
outputDir.createDirectories()
}
private fun cleanup() {
inputDir.deleteRecursively()
inputDir.deleteRecursive()
outputDir.moveTo(inputDir)
outputDir.deleteRecursively()
outputDir.deleteRecursive()
}
}

View file

@ -265,7 +265,7 @@ abstract class RemapPatches : BaseTask() {
private fun createWorkDir(name: String, source: Path? = null, recreate: Boolean = true): Path {
return layout.cache.resolve("paperweight").resolve(name).apply {
if (recreate) {
deleteRecursively()
deleteRecursive()
createDirectories()
source?.copyRecursivelyTo(this)
}
@ -276,7 +276,7 @@ abstract class RemapPatches : BaseTask() {
val workDir = layout.cache.resolve("paperweight")
return workDir.resolve(name).apply {
if (recreate) {
deleteRecursively()
deleteRecursive()
createDirectories()
Git(workDir)("clone", source.absolutePathString(), this.absolutePathString()).executeSilently()
}

View file

@ -69,7 +69,7 @@ fun Path.deleteForcefully() {
deleteIfExists()
}
fun Path.deleteRecursively(excludes: Iterable<PathMatcher> = emptyList()) {
fun Path.deleteRecursive(excludes: Iterable<PathMatcher> = emptyList()) {
if (!exists()) {
return
}

View file

@ -224,7 +224,7 @@ fun ensureDeleted(vararg files: Any) {
for (file in files) {
val f = file.convertToPath()
try {
f.deleteRecursively()
f.deleteRecursive()
} catch (e: Exception) {
throw PaperweightException("Failed to delete file or directory $f", e)
}

View file

@ -82,7 +82,7 @@ abstract class CheckoutRepo : DefaultTask() {
val urlText = url.get().trim()
if (dir.resolve(".git").notExists()) {
dir.deleteRecursively()
dir.deleteRecursive()
dir.createDirectories()
Git(dir)("init", "--quiet").executeSilently()

View file

@ -117,7 +117,7 @@ abstract class PatcherApplyGitPatches : ControllableOutputTask() {
if (bareDirectory.get()) {
val up = upstreamDir.path
up.resolve(".git").deleteRecursively()
up.resolve(".git").deleteRecursive()
Git(up).let { upstreamGit ->
upstreamGit("init", "--quiet").executeSilently(silenceErr = true)
upstreamGit("checkout", "-b", upstreamBranch.get()).executeSilently(silenceErr = true)

View file

@ -57,7 +57,7 @@ fun extractDevBundle(
if (currentDevBundleHash.isNotBlank() && newDevBundleHash == currentDevBundleHash) {
return ExtractedBundle(false, readDevBundle(destinationDirectory), destinationDirectory)
}
destinationDirectory.deleteRecursively()
destinationDirectory.deleteRecursive()
}
destinationDirectory.createDirectories()

View file

@ -209,7 +209,7 @@ fun cleanSharedCaches(target: Project, root: Path) {
.toList()
}
for (path in toDelete) {
path.deleteRecursively()
path.deleteRecursive()
// clean up empty parent directories
var parent: Path = path.parent