use of org.eclipse.tycho.locking.facade.FileLockService in project tycho by eclipse.
the class UpdateSiteAssembler method unpackJar.
private void unpackJar(File location, File outputJar) {
ZipUnArchiver unzip;
FileLockService fileLockService;
try {
unzip = (ZipUnArchiver) session.lookup(ZipUnArchiver.ROLE, "zip");
fileLockService = (FileLockService) session.lookup(FileLockService.class.getName());
} catch (ComponentLookupException e) {
throw new RuntimeException("Could not lookup required component", e);
}
outputJar.mkdirs();
if (!outputJar.isDirectory()) {
throw new RuntimeException("Could not create output directory " + outputJar.getAbsolutePath());
}
unzip.setSourceFile(location);
unzip.setDestDirectory(outputJar);
FileLocker locker = fileLockService.getFileLocker(location);
locker.lock();
try {
unzip.extract();
} catch (ArchiverException e) {
throw new RuntimeException("Could not unpack jar", e);
} finally {
locker.release();
}
}
Aggregations