From fb4be7a762939db9fe63a0e2c11f9e8deb919aa5 Mon Sep 17 00:00:00 2001 From: Matyrobbrt <65940752+Matyrobbrt@users.noreply.github.com> Date: Wed, 1 May 2024 12:04:42 +0300 Subject: [PATCH] Avoid deleting dummy repository files unless needed (#161) --- .../repository/IvyDummyRepositoryExtension.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/net/neoforged/gradle/common/extensions/repository/IvyDummyRepositoryExtension.java b/common/src/main/java/net/neoforged/gradle/common/extensions/repository/IvyDummyRepositoryExtension.java index 7d58ce2e1..387f4e2db 100644 --- a/common/src/main/java/net/neoforged/gradle/common/extensions/repository/IvyDummyRepositoryExtension.java +++ b/common/src/main/java/net/neoforged/gradle/common/extensions/repository/IvyDummyRepositoryExtension.java @@ -168,12 +168,16 @@ private void writeDummyDataIfNeeded( writeIvyMetadataFile(entry, jarFile, baseDir, metaFile); - Files.deleteIfExists(jarFile); - Files.createFile(jarFile); + if (!Files.isRegularFile(jarFile)) { + FileUtils.delete(jarFile); + Files.createFile(jarFile); + } final Path sourcesFile = entry.asSources().buildArtifactPath(getRepositoryDirectory().get().getAsFile().toPath()); - Files.deleteIfExists(sourcesFile); - Files.createFile(sourcesFile); + if (!Files.isRegularFile(sourcesFile)) { + FileUtils.delete(sourcesFile); + Files.createFile(sourcesFile); + } writeDummyDependencyDataIfNeeded(entry); }