log.info("extracting zip file: " + sauceConnectArchiveFile + " into " + sauceConnectDirectory); Spacelift.task(sauceConnectArchiveFile, UnzipTool.class) .toDir(sauceConnectDirectory.toString()) .execute().await();
/** * Prepares the BrowserStackLocal binary. Creates the directory target/browserstacklocal; downloads a zip file * containing the binary; extracts it into the created directory and marks the binary as executable. */ private void prepareBrowserStackLocal() { String platformBinaryNameUrl = getPlatformBinaryNameUrl(); File browserStackLocalZipFile = browserStackLocalDirectory.resolve(platformBinaryNameUrl).toFile(); String url = basicUrl + platformBinaryNameUrl; log.info("Creating directory: " + browserStackLocalDirectory); browserStackLocalDirectory.toFile().mkdir(); log.info("downloading zip file from: " + url + " to " + browserStackLocalZipFile); Spacelift.task(DownloadTool.class) .from(url) .to(browserStackLocalZipFile) .execute().await(); log.info("extracting zip file: " + browserStackLocalZipFile + " to " + browserStackLocalDirectory); Spacelift.task(browserStackLocalZipFile, UnzipTool.class) .toDir(browserStackLocalDirectory.toFile()) .execute().await(); log.info("marking binary file: " + browserStackLocalFile + " as executable"); try { browserStackLocalFile.toFile().setExecutable(true); } catch (SecurityException se) { log.severe("The downloaded BrowserStackLocal binary: " + browserStackLocalFile + " could not be set as executable. This may cause additional problems."); } }
Spacelift.task(toExtract, UnzipTool.class).toDir(targetDir).execute().await(); } else if (filePath.endsWith(".tar.gz")) { Spacelift.task(toExtract, UntarTool.class).gzip(true).toDir(targetDir).execute().await();
Spacelift.task(toExtract, UnzipTool.class).toDir(targetDir).execute().await(); } else if (filePath.endsWith(".tar.gz")) { Spacelift.task(toExtract, UntarTool.class).gzip(true).toDir(targetDir).execute().await();
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)); }