Search in sources :

Example 16 with Parameters

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;
}
Also used : Parameters(aQute.bnd.header.Parameters) PomPropertiesResource(aQute.bnd.maven.PomPropertiesResource) PomResource(aQute.bnd.maven.PomResource) PackageRef(aQute.bnd.osgi.Descriptors.PackageRef)

Example 17 with Parameters

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);
}
Also used : Parameters(aQute.bnd.header.Parameters)

Example 18 with Parameters

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);
}
Also used : Parameters(aQute.bnd.header.Parameters) Attrs(aQute.bnd.header.Attrs) ProvideCapability(aQute.bnd.annotation.headers.ProvideCapability)

Example 19 with Parameters

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]);
}
Also used : Parameters(aQute.bnd.header.Parameters) ArrayList(java.util.ArrayList) ZipException(java.util.zip.ZipException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 20 with Parameters

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;
}
Also used : Parameters(aQute.bnd.header.Parameters) File(java.io.File)

Aggregations

Parameters (aQute.bnd.header.Parameters)167 Attrs (aQute.bnd.header.Attrs)80 File (java.io.File)45 Jar (aQute.bnd.osgi.Jar)44 Manifest (java.util.jar.Manifest)39 Builder (aQute.bnd.osgi.Builder)35 Domain (aQute.bnd.osgi.Domain)24 ArrayList (java.util.ArrayList)23 Map (java.util.Map)19 Attributes (java.util.jar.Attributes)17 IOException (java.io.IOException)15 HashMap (java.util.HashMap)15 Version (aQute.bnd.version.Version)11 HashSet (java.util.HashSet)10 Instructions (aQute.bnd.osgi.Instructions)9 FileNotFoundException (java.io.FileNotFoundException)8 Properties (java.util.Properties)8 Matcher (java.util.regex.Matcher)8 Analyzer (aQute.bnd.osgi.Analyzer)7 PackageRef (aQute.bnd.osgi.Descriptors.PackageRef)7