Improve handling of failed dependency relocation

This commit is contained in:
Jason Penilla committed 2023-08-23 09:18:48 -07:00
1 parent 7ed005afeb
commit e2baa90f9b
1 file changed
+7 -4
@@ -90,17 +90,20 @@ public final class DependencyDownloader {
ret.add(resolve);
return null;
}
final Path output = resolve.resolveSibling(resolve.getFileName().toString().replace(".jar", "-relocated.jar"));
ret.add(output);
if (Files.isRegularFile(output)) {
final Path relocated = resolve.resolveSibling(resolve.getFileName().toString().replace(".jar", "-relocated.jar"));
ret.add(relocated);
if (Files.isRegularFile(relocated)) {
return null;
}
doingWork.run();
final Path output = relocated.resolveSibling(relocated.getFileName().toString() + ".tmp");
Files.deleteIfExists(output);
final JarRelocator relocator = new JarRelocator(resolve.toFile(), output.toFile(), this.relocations);
//this.logger.info("relocating {}", resolve);
relocator.run();
Files.move(output, relocated);
//this.logger.info("done relocating {}", resolve);
} catch (final IOException e) {
} catch (final IOException | IllegalArgumentException e) {
throw new RuntimeException("Exception resolving " + dep, e);
}
return null;