Delete existing sources jar when re-running jar processors. Fixes #560

dev/0.11
modmuss50 2022-01-05 09:58:19 +00:00
parent 240a23f52d
commit 6fd3d5d021
1 changed files with 10 additions and 0 deletions

View File

@ -76,6 +76,7 @@ public abstract class ProcessedNamedMinecraftProvider<M extends MinecraftProvide
for (Path inputJar : inputJars) {
final Path outputJar = getProcessedPath(inputJar);
deleteSimilarJars(outputJar);
Files.copy(inputJar, outputJar, StandardCopyOption.REPLACE_EXISTING);
jarProcessorManager.process(outputJar.toFile());
@ -87,6 +88,15 @@ public abstract class ProcessedNamedMinecraftProvider<M extends MinecraftProvide
}
}
private void deleteSimilarJars(Path jar) throws IOException {
Files.deleteIfExists(jar);
for (Path path : Files.list(jar.getParent()).filter(Files::isRegularFile)
.filter(path -> path.getFileName().startsWith(jar.getFileName().toString().replace(".jar", ""))).toList()) {
Files.deleteIfExists(path);
}
}
@Override
protected String getName(String name) {
return "%s%s-%s".formatted(projectMappedName, name, getTargetNamespace().toString());