use of aQute.lib.utf8properties.UTF8Properties in project bnd by bndtools.
the class Project method _ide.
public String _ide(String[] args) throws IOException {
if (args.length < 2) {
error("The ${ide;<>} macro needs an argument");
return null;
}
if (ide == null) {
ide = new UTF8Properties();
File file = getFile(".settings/org.eclipse.jdt.core.prefs");
if (!file.isFile()) {
error("The ${ide;<>} macro requires a .settings/org.eclipse.jdt.core.prefs file in the project");
return null;
}
try (InputStream in = IO.stream(file)) {
ide.load(in);
}
}
String deflt = args.length > 2 ? args[2] : null;
if ("javac.target".equals(args[1])) {
return ide.getProperty("org.eclipse.jdt.core.compiler.codegen.targetPlatform", deflt);
}
if ("javac.source".equals(args[1])) {
return ide.getProperty("org.eclipse.jdt.core.compiler.source", deflt);
}
return null;
}
use of aQute.lib.utf8properties.UTF8Properties in project bnd by bndtools.
the class BndEditModel method getProperties.
/**
* Return a processor for this model. This processor is based on the parent
* project or the bndrun file. It will contain the properties of the project
* file and the changes from the model.
*
* @return a processor that reflects the actual project or bndrun file setup
*/
public Processor getProperties() throws Exception {
Processor parent = null;
if (isProjectFile() && project != null)
parent = project;
else if (getBndResource() != null) {
parent = Workspace.getRun(getBndResource());
if (parent == null) {
parent = new Processor();
parent.setProperties(getBndResource(), getBndResource().getParentFile());
}
}
Processor result;
if (parent == null)
result = new Processor();
else
result = new Processor(parent);
StringBuilder sb = new StringBuilder();
for (Entry<String, String> e : changesToSave.entrySet()) {
sb.append(e.getKey()).append(": ").append(e.getValue()).append("\n\n");
}
UTF8Properties p = new UTF8Properties();
p.load(new StringReader(sb.toString()));
result.getProperties().putAll(properties);
result.getProperties().putAll(p);
return result;
}
use of aQute.lib.utf8properties.UTF8Properties 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