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

This commit is contained in:
modmuss50 2022-01-05 09:58:19 +00:00
parent 240a23f52d
commit 6fd3d5d021

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());