Search in sources :

Example 41 with TypeRef

use of aQute.bnd.osgi.Descriptors.TypeRef in project bnd by bndtools.

the class Builder method addSources.

/**
	 * @throws IOException
	 */
private void addSources(Jar dot) throws Exception {
    if (!hasSources())
        return;
    Set<PackageRef> packages = Create.set();
    for (TypeRef typeRef : getClassspace().keySet()) {
        PackageRef packageRef = typeRef.getPackageRef();
        String sourcePath = typeRef.getSourcePath();
        String packagePath = packageRef.getPath();
        boolean found = false;
        String[] fixed = { "packageinfo", "package.html", "module-info.java", "package-info.java" };
        for (File root : getSourcePath()) {
            File f = getFile(root, sourcePath);
            if (f.exists()) {
                found = true;
                if (!packages.contains(packageRef)) {
                    packages.add(packageRef);
                    for (int j = 0; j < fixed.length; j++) {
                        for (File sp : getSourcePath()) {
                            File bdir = getFile(sp, packagePath);
                            File ff = getFile(bdir, fixed[j]);
                            if (ff.isFile()) {
                                String name = "OSGI-OPT/src/" + packagePath + "/" + fixed[j];
                                dot.putResource(name, new FileResource(ff));
                                break;
                            }
                        }
                    }
                }
                if (packageRef.isDefaultPackage())
                    logger.debug("Package reference is default package");
                dot.putResource("OSGI-OPT/src/" + sourcePath, new FileResource(f));
            }
        }
        if (getSourcePath().isEmpty())
            warning("Including sources but " + SOURCEPATH + " does not contain any source directories ");
    // TODO copy from the jars where they came from
    }
}
Also used : TypeRef(aQute.bnd.osgi.Descriptors.TypeRef) PackageRef(aQute.bnd.osgi.Descriptors.PackageRef) File(java.io.File)

Example 42 with TypeRef

use of aQute.bnd.osgi.Descriptors.TypeRef in project bnd by bndtools.

the class Clazz method doExceptions.

void doExceptions(DataInput in, int access_flags) throws IOException {
    int exception_count = in.readUnsignedShort();
    for (int i = 0; i < exception_count; i++) {
        int index = in.readUnsignedShort();
        ClassConstant cc = (ClassConstant) pool[index];
        TypeRef clazz = analyzer.getTypeRef(cc.getName());
        referTo(clazz, access_flags);
    }
}
Also used : TypeRef(aQute.bnd.osgi.Descriptors.TypeRef)

Aggregations

TypeRef (aQute.bnd.osgi.Descriptors.TypeRef)42 Clazz (aQute.bnd.osgi.Clazz)12 PackageRef (aQute.bnd.osgi.Descriptors.PackageRef)7 HashMap (java.util.HashMap)6 LinkedHashMap (java.util.LinkedHashMap)6 Map (java.util.Map)6 Analyzer (aQute.bnd.osgi.Analyzer)5 ClassDataCollector (aQute.bnd.osgi.ClassDataCollector)5 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)5 Matcher (java.util.regex.Matcher)5 DeclarativeServicesAnnotationError (aQute.bnd.component.error.DeclarativeServicesAnnotationError)4 Attrs (aQute.bnd.header.Attrs)4 Annotation (aQute.bnd.osgi.Annotation)4 MultiMap (aQute.lib.collections.MultiMap)4 MethodDef (aQute.bnd.osgi.Clazz.MethodDef)3 Instructions (aQute.bnd.osgi.Instructions)3 Resource (aQute.bnd.osgi.Resource)3 Tag (aQute.lib.tag.Tag)3