private void extractFileInDestinationDir() {
markerFileHandler.createMarkerFile();
final String downloadedPath = fileToExtract.getAbsolutePath();
try {
if (downloadedPath.endsWith(".zip")) {
Spacelift.task(fileToExtract, UnzipTool.class).toDir(destinationDir).execute().await();
} else if (downloadedPath.endsWith(".tar.gz")) {
Spacelift.task(fileToExtract, UntarTool.class).gzip(true).toDir(destinationDir).execute().await();
} else if (downloadedPath.endsWith(".tar.bz2")) {
Spacelift.task(fileToExtract, UntarTool.class).bzip2(true).toDir(destinationDir).execute().await();
} else {
throw new IllegalArgumentException(
"The distribution " + fileToExtract + " is compressed by unsupported format. "
+ "Supported formats are .zip, .tar.gz, .tar.bz2");
}
} catch (ExecutionException ee) {
throw new IllegalStateException(
"Something bad happened when the file: " + downloadedPath + " was being extracted. "
+ "For more information see the stacktrace", ee);
}
markerFileHandler.deleteMarkerFile();
System.out.println(String.format("Resolver: Successfully extracted maven binaries from %s", fileToExtract));
}