use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class Builder method getExtra.
/**
* Answer extra packages. In this case we implement conditional package. Any
*/
@Override
protected Jar getExtra() throws Exception {
Parameters conditionals = getMergedParameters(CONDITIONAL_PACKAGE);
conditionals.putAll(getMergedParameters(CONDITIONALPACKAGE));
if (conditionals.isEmpty())
return null;
logger.debug("do Conditional Package {}", conditionals);
Instructions instructions = new Instructions(conditionals);
Collection<PackageRef> referred = instructions.select(getReferred().keySet(), false);
referred.removeAll(getContained().keySet());
if (referred.isEmpty()) {
logger.debug("no additional conditional packages to add");
return null;
}
Jar jar = new Jar("conditional-import");
addClose(jar);
for (PackageRef pref : referred) {
for (Jar cpe : getClasspath()) {
Map<String, Resource> map = cpe.getDirectories().get(pref.getPath());
if (map != null) {
copy(jar, cpe, pref.getPath(), false);
break;
}
}
}
if (jar.getDirectories().size() == 0) {
logger.debug("extra dirs {}", jar.getDirectories());
return null;
}
return jar;
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class Builder method doDigests.
/**
* Check if we need to calculate any checksums.
*
* @param dot
* @throws Exception
*/
private void doDigests(Jar dot) throws Exception {
Parameters ps = OSGiHeader.parseHeader(getProperty(DIGESTS));
if (ps.isEmpty())
return;
logger.debug("digests {}", ps);
String[] digests = ps.keySet().toArray(new String[0]);
dot.setDigestAlgorithms(digests);
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class AnnotationHeaders method doProvideCapability.
/*
* Provide-Capability header
*/
private void doProvideCapability(Annotation a) throws Exception {
ProvideCapability annotation = a.getAnnotation(ProvideCapability.class);
Parameters p = new Parameters();
Attrs attrs = getAttributes(a, "ns");
directivesAndVersion(attrs, "uses", "mandatory", "effective");
p.put(annotation.ns(), attrs);
String value = attrs.remove("name");
if (value != null)
attrs.put(annotation.ns(), value);
value = attrs.remove("value");
String s = p.toString();
if (value != null)
s += ";" + annotation.value();
add(Constants.PROVIDE_CAPABILITY, s);
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class Builder method builds.
/**
* Build Multiple jars. If the -sub command is set, we filter the file with
* the given patterns.
*
* @throws Exception
*/
public Jar[] builds() throws Exception {
begin();
// Are we acting as a conduit for another JAR?
String conduit = getProperty(CONDUIT);
if (conduit != null) {
Parameters map = parseHeader(conduit);
Jar[] result = new Jar[map.size()];
int n = 0;
for (String file : map.keySet()) {
Jar c = new Jar(getFile(file));
addClose(c);
String name = map.get(file).get("name");
if (name != null)
c.setName(name);
result[n++] = c;
}
return result;
}
List<Jar> result = new ArrayList<Jar>();
List<Builder> builders;
builders = getSubBuilders();
for (Builder builder : builders) {
try {
startBuild(builder);
Jar jar = builder.build();
jar.setName(builder.getBsn());
result.add(jar);
doneBuild(builder);
} catch (Exception e) {
builder.exception(e, "Exception Building %s", builder.getBsn());
}
if (builder != this)
getInfo(builder, builder.getBsn() + ": ");
}
return result.toArray(new Jar[0]);
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class Builder method isInScope.
/**
* Check if the given resource is in scope of this bundle. That is, it
* checks if the Include-Resource includes this resource or if it is a class
* file it is on the class path and the Export-Package or Private-Package
* include this resource.
*/
public boolean isInScope(Collection<File> resources) throws Exception {
Parameters clauses = parseHeader(mergeProperties(Constants.EXPORT_PACKAGE));
clauses.putAll(parseHeader(mergeProperties(Constants.PRIVATE_PACKAGE)));
clauses.putAll(parseHeader(mergeProperties(Constants.PRIVATEPACKAGE)));
if (isTrue(getProperty(Constants.UNDERTEST))) {
clauses.putAll(parseHeader(mergeProperties(Constants.TESTPACKAGES, "test;presence:=optional")));
}
Collection<String> ir = getIncludedResourcePrefixes();
Instructions instructions = new Instructions(clauses);
for (File r : resources) {
String cpEntry = getClasspathEntrySuffix(r);
if (cpEntry != null) {
if (// Meaning we actually have a CPE
cpEntry.equals(""))
return true;
String pack = Descriptors.getPackage(cpEntry);
Instruction i = matches(instructions, pack, null, r.getName());
if (i != null)
return !i.isNegated();
}
// Check if this resource starts with one of the I-C header
// paths.
String path = r.getAbsolutePath();
for (String p : ir) {
if (path.startsWith(p))
return true;
}
}
return false;
}
Aggregations