use of aQute.lib.io.ByteBufferOutputStream in project bndtools by bndtools.
the class GenerateLauncherJarRunnable method run.
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
Entry<String, Resource> export = project.export("bnd.executablejar", Collections.emptyMap());
if (export != null) {
try (JarResource r = (JarResource) export.getValue()) {
File destination = new File(path);
Jar jar = r.getJar();
if (folder) {
// Set launch.embedded=false since we expanded to folder
Resource launcherprops = jar.getResource("launcher.properties");
if (launcherprops != null) {
UTF8Properties props = new UTF8Properties();
try (InputStream in = launcherprops.openInputStream()) {
props.load(in);
}
props.put("launch.embedded", Boolean.toString(false));
try (ByteBufferOutputStream bbos = new ByteBufferOutputStream(((int) launcherprops.size()) + 1)) {
props.store(bbos);
launcherprops = new EmbeddedResource(bbos.toByteBuffer(), launcherprops.lastModified());
}
jar.putResource("launcher.properties", launcherprops);
}
jar.writeFolder(destination);
File start = IO.getFile(destination, "start");
if (start.isFile()) {
start.setExecutable(true);
}
} else {
jar.write(destination);
}
}
}
} catch (Exception e) {
throw new InvocationTargetException(e);
}
}
Aggregations