use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class Analyzer method doNamesection.
/**
* Parse the namesection as instructions and then match them against the
* current set of resources For example:
*
* <pre>
* -namesection: *;baz=true,
* abc/def/bar/X.class=3
* </pre>
*
* The raw value of {@link Constants#NAMESECTION} is used but the values of
* the attributes are replaced where @ is set to the resource name. This
* allows macro to operate on the resource
*/
private void doNamesection(Jar dot, Manifest manifest) {
Parameters namesection = parseHeader(getProperties().getProperty(NAMESECTION));
Instructions instructions = new Instructions(namesection);
Set<String> resources = new HashSet<String>(dot.getResources().keySet());
//
for (Map.Entry<Instruction, Attrs> instr : instructions.entrySet()) {
boolean matched = false;
for (Iterator<String> i = resources.iterator(); i.hasNext(); ) {
String path = i.next();
if (instr.getKey().matches(path)) {
// Instruction matches the resource
matched = true;
if (!instr.getKey().isNegated()) {
// Positive match, add the attributes
Attributes attrs = manifest.getAttributes(path);
if (attrs == null) {
attrs = new Attributes();
manifest.getEntries().put(path, attrs);
}
for (Map.Entry<String, String> property : instr.getValue().entrySet()) {
setProperty("@", path);
try {
String processed = getReplacer().process(property.getValue());
attrs.putValue(property.getKey(), processed);
} finally {
unsetProperty("@");
}
}
}
i.remove();
}
}
if (!matched && resources.size() > 0)
warning("The instruction %s in %s did not match any resources", instr.getKey(), NAMESECTION);
}
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class AnnotationHeaders method doLicense.
/*
* Bundle-License header
*/
private void doLicense(Annotation a) throws Exception {
BundleLicense annotation = a.getAnnotation(BundleLicense.class);
Parameters p = new Parameters();
p.put(annotation.name(), getAttributes(a, "name"));
add(Constants.BUNDLE_LICENSE, p.toString());
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class Builder method doDiff.
/**
* Diff this bundle to another bundle for the given packages.
*
* @throws Exception
*/
public void doDiff(@SuppressWarnings("unused") Jar dot) throws Exception {
Parameters diffs = parseHeader(getProperty("-diff"));
if (diffs.isEmpty())
return;
logger.debug("diff {}", diffs);
if (tree == null)
tree = differ.tree(this);
for (Entry<String, Attrs> entry : diffs.entrySet()) {
String path = entry.getKey();
File file = getFile(path);
if (!file.isFile()) {
error("Diffing against %s that is not a file", file).header("-diff").context(path);
continue;
}
boolean full = entry.getValue().get("--full") != null;
boolean warning = entry.getValue().get("--warning") != null;
Tree other = differ.tree(file);
Diff api = tree.diff(other).get("<api>");
Instructions instructions = new Instructions(entry.getValue().get("--pack"));
logger.debug("diff against {} --full={} --pack={} --warning={}", file, full, instructions);
for (Diff p : api.getChildren()) {
String pname = p.getName();
if (p.getType() == Type.PACKAGE && instructions.matches(pname)) {
if (p.getDelta() != Delta.UNCHANGED) {
if (!full)
if (warning)
warning("Differ %s", p).header("-diff").context(path);
else
error("Differ %s", p).header("-diff").context(path);
else {
if (warning)
warning("Diff found a difference in %s for packages %s", file, instructions).header("-diff").context(path);
else
error("Diff found a difference in %s for packages %s", file, instructions).header("-diff").context(path);
show(p, "", warning);
}
}
}
}
}
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class Builder method doWab.
/**
* Turn this normal bundle in a web and add any resources.
*
* @throws Exception
*/
private Jar doWab(Jar dot) throws Exception {
String wab = getProperty(WAB);
String wablib = getProperty(WABLIB);
if (wab == null && wablib == null)
return dot;
logger.debug("wab {} {}", wab, wablib);
setBundleClasspath(append("WEB-INF/classes", getProperty(BUNDLE_CLASSPATH)));
Set<String> paths = new HashSet<String>(dot.getResources().keySet());
for (String path : paths) {
if (path.indexOf('/') > 0 && !Character.isUpperCase(path.charAt(0))) {
logger.debug("wab: moving: {}", path);
dot.rename(path, "WEB-INF/classes/" + path);
}
}
Parameters clauses = parseHeader(getProperty(WABLIB));
for (String key : clauses.keySet()) {
File f = getFile(key);
addWabLib(dot, f);
}
doIncludeResource(dot, wab);
return dot;
}
use of aQute.bnd.header.Parameters in project bnd by bndtools.
the class Builder method doIncludeResource.
private void doIncludeResource(Jar jar, String includes) throws Exception {
Parameters clauses = parseHeader(includes);
doIncludeResource(jar, clauses);
}
Aggregations