use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class LauncherTest method create.
private File create(String bsn, Version v) throws Exception {
String name = bsn + "-" + v;
Builder b = new Builder();
b.setBundleSymbolicName(bsn);
b.setBundleVersion(v);
b.setProperty("Random", random++ + "");
b.setProperty("-resourceonly", true + "");
b.setIncludeResource("foo;literal='foo'");
Jar jar = b.build();
assertTrue(b.check());
File file = IO.getFile(tmp, name + ".jar");
file.getParentFile().mkdirs();
jar.updateModified(System.currentTimeMillis(), "Force it to now");
jar.write(file);
b.close();
return file;
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class RemoteTest method create.
private File create(String bsn, Version v) throws Exception {
String name = bsn + "-" + v;
Builder b = new Builder();
b.setBundleSymbolicName(bsn);
b.setBundleVersion(v);
b.setProperty("Random", random++ + "");
b.setProperty("-resourceonly", true + "");
b.setIncludeResource("foo;literal='foo'");
Jar jar = b.build();
assertTrue(b.check());
File file = IO.getFile(tmp, name + ".jar");
file.getParentFile().mkdirs();
jar.updateModified(System.currentTimeMillis(), "Force it to now");
jar.write(file);
b.close();
return file;
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class AgentTest method create.
/**
* Launches against main
*/
private File create(String bsn, Version v) throws Exception {
String name = bsn + "-" + v;
Builder b = new Builder();
b.setBundleSymbolicName(bsn);
b.setBundleVersion(v);
b.setProperty("Random", random++ + "");
b.setProperty("-resourceonly", true + "");
b.setIncludeResource("foo;literal='foo'");
Jar jar = b.build();
assertTrue(b.check());
File file = IO.getFile(tmp, name + ".jar");
file.getParentFile().mkdirs();
jar.updateModified(System.currentTimeMillis(), "Force it to now");
jar.write(file);
b.close();
return file;
}
use of aQute.bnd.osgi.Builder in project bndtools by bndtools.
the class BundleVersionErrorHandler method generateMarkerData.
@Override
public List<MarkerData> generateMarkerData(IProject project, Project model, Location location) throws Exception {
List<MarkerData> result = new LinkedList<MarkerData>();
IFile bndFile = null;
LineLocation loc = null;
BundleInfo info = (BundleInfo) location.details;
for (Builder builder : model.getSubBuilders()) {
if (builder.getBsn().equals(info.bsn)) {
File propsFile = builder.getPropertiesFile();
// Try to find in the sub-bundle file
if (propsFile != null) {
bndFile = project.getWorkspace().getRoot().getFileForLocation(new Path(propsFile.getAbsolutePath()));
if (bndFile != null) {
loc = findBundleVersionHeader(bndFile);
}
}
if (loc == null) {
// Not found in sub-bundle file, try bnd.bnd
bndFile = project.getFile(Project.BNDFILE);
loc = findBundleVersionHeader(bndFile);
}
if (loc != null) {
Map<String, Object> attribs = new HashMap<String, Object>();
attribs.put(IMarker.MESSAGE, location.message);
attribs.put(IMarker.LINE_NUMBER, loc.lineNum);
attribs.put(IMarker.CHAR_START, loc.start);
attribs.put(IMarker.CHAR_END, loc.end);
String qualifier = null;
String currentVersion = builder.getUnprocessedProperty(Constants.BUNDLE_VERSION, "");
if (currentVersion != null) {
Matcher m = VERSION_ACCEPTING_MACRO.matcher(currentVersion);
if (m.matches()) {
qualifier = m.group(4);
}
}
attribs.put(PROP_SUGGESTED_VERSION, info.suggestedVersion.toString() + (qualifier != null ? '.' + qualifier : ""));
result.add(new MarkerData(bndFile, attribs, true, BndtoolsConstants.MARKER_JAVA_BASELINE));
}
}
}
return result;
}
use of aQute.bnd.osgi.Builder in project bnd by bndtools.
the class Profiles method _create.
public void _create(CreateOptions options) throws Exception {
Builder b = new Builder();
bnd.addClose(b);
b.setBase(bnd.getBase());
if (options.properties() != null) {
for (String propertyFile : options.properties()) {
File pf = bnd.getFile(propertyFile);
b.addProperties(pf);
}
}
if (options.bsn() != null)
b.setProperty(Constants.BUNDLE_SYMBOLICNAME, options.bsn());
if (options.version() != null)
b.setProperty(Constants.BUNDLE_VERSION, options.version().toString());
Instructions match = options.match();
Parameters packages = new Parameters();
Parameters capabilities = new Parameters();
Collection<String> paths = new ArrayList<String>(new Parameters(b.getProperty("-paths"), bnd).keySet());
if (paths.isEmpty())
paths = options._arguments();
logger.debug("input {}", paths);
ResourceBuilder pb = new ResourceBuilder();
for (String root : paths) {
File f = bnd.getFile(root);
if (!f.exists()) {
error("could not find %s", f);
} else {
Glob g = options.extension();
if (g == null)
g = new Glob("*.jar");
Collection<File> files = IO.tree(f, "*.jar");
logger.debug("will profile {}", files);
for (File file : files) {
Domain domain = Domain.domain(file);
if (domain == null) {
error("Not a bundle because no manifest %s", file);
continue;
}
String bsn = domain.getBundleSymbolicName().getKey();
if (bsn == null) {
error("Not a bundle because no manifest %s", file);
continue;
}
if (match != null) {
Instruction instr = match.finder(bsn);
if (instr == null || instr.isNegated()) {
logger.debug("skipped {} because of non matching bsn {}", file, bsn);
continue;
}
}
Parameters eps = domain.getExportPackage();
Parameters pcs = domain.getProvideCapability();
logger.debug("parse {}:\ncaps: {}\npac: {}\n", file, pcs, eps);
packages.mergeWith(eps, false);
capabilities.mergeWith(pcs, false);
}
}
}
b.setProperty(Constants.PROVIDE_CAPABILITY, capabilities.toString());
b.setProperty(Constants.EXPORT_PACKAGE, packages.toString());
logger.debug("Found {} packages and {} capabilities", packages.size(), capabilities.size());
Jar jar = b.build();
File f = b.getOutputFile(options.output());
logger.debug("Saving as {}", f);
jar.write(f);
}
Aggregations