Search in sources :

Example 6 with Container

use of aQute.bnd.build.Container in project bnd by bndtools.

the class ProjectTest method testRepoFilterBuildPath.

public void testRepoFilterBuildPath() throws Exception {
    Workspace ws = getWorkspace(IO.getFile("testresources/ws"));
    Project project = ws.getProject("repofilter");
    assertNotNull(project);
    project.setProperty("-buildpath", "p3; version='[1,2)'; repo=Relea*");
    ArrayList<Container> buildpath = new ArrayList<Container>(project.getBuildpath());
    assertEquals(1, buildpath.size());
    // Without repos filter we would get lowest version, i.e. 1.0.0 from the
    // repo named "Repo".
    assertEquals("1.1.0", buildpath.get(0).getVersion());
}
Also used : Project(aQute.bnd.build.Project) Container(aQute.bnd.build.Container) ArrayList(java.util.ArrayList) Workspace(aQute.bnd.build.Workspace)

Example 7 with Container

use of aQute.bnd.build.Container in project bnd by bndtools.

the class ProjectTest method testWildcardBuildPath.

public void testWildcardBuildPath() throws Exception {
    Workspace ws = getWorkspace(IO.getFile("testresources/ws"));
    Project project = ws.getProject("repofilter");
    assertNotNull(project);
    project.setProperty("-buildpath", "lib*");
    ArrayList<Container> buildpath = new ArrayList<Container>(project.getBuildpath());
    for (int i = 1; i < buildpath.size(); i++) {
        Container c = buildpath.get(i);
        assertEquals(Container.TYPE.REPO, c.getType());
    }
}
Also used : Project(aQute.bnd.build.Project) Container(aQute.bnd.build.Container) ArrayList(java.util.ArrayList) Workspace(aQute.bnd.build.Workspace)

Example 8 with Container

use of aQute.bnd.build.Container in project bnd by bndtools.

the class ProjectTest method testHashVersionWithAlgorithmNotFound.

public void testHashVersionWithAlgorithmNotFound() throws Exception {
    Workspace ws = getWorkspace(IO.getFile("testresources/ws-versionhash"));
    Project project = ws.getProject("p1");
    assertNotNull(project);
    project.setProperty("-buildpath", "tmp; version=hash; hash=SHA-1:7fe83bfd5999fa4ef9cec40282d5d67dd0ff3303bac6b8c7b0e8be80a821441c");
    ArrayList<Container> buildpath = new ArrayList<Container>(project.getBuildpath());
    assertEquals(0, buildpath.size());
}
Also used : Project(aQute.bnd.build.Project) Container(aQute.bnd.build.Container) ArrayList(java.util.ArrayList) Workspace(aQute.bnd.build.Workspace)

Example 9 with Container

use of aQute.bnd.build.Container in project bnd by bndtools.

the class bnd method _deliverables.

@Description("Show all deliverables from this workspace. with their current version and path.")
public void _deliverables(deliverableOptions options) throws Exception {
    Project project = getProject(options.project());
    if (project == null) {
        messages.NoProject();
        return;
    }
    Collection<Project> projects;
    if (options.limit())
        projects = Arrays.asList(project);
    else
        projects = project.getWorkspace().getAllProjects();
    List<Container> containers = new ArrayList<Container>();
    for (Project p : projects) {
        containers.addAll(p.getDeliverables());
    }
    for (Container c : containers) {
        Version v = new Version(c.getVersion());
        err.printf("%-40s %8s  %s\n", c.getBundleSymbolicName(), v.getWithoutQualifier(), c.getFile());
    }
    getInfo(project);
}
Also used : Project(aQute.bnd.build.Project) Container(aQute.bnd.build.Container) Version(aQute.bnd.version.Version) ArrayList(java.util.ArrayList) Description(aQute.lib.getopt.Description)

Example 10 with Container

use of aQute.bnd.build.Container in project bnd by bndtools.

the class bnd method _find.

public void _find(FindOptions options) throws Exception {
    List<File> files = new ArrayList<File>();
    List<String> args = options._arguments();
    if (args.size() == 0) {
        Project p = getProject();
        if (p == null) {
            error("This is not a project directory and you have specified no jar files ...");
            return;
        }
        File output = p.getOutput();
        if (output.exists()) {
            files.add(output);
        }
        for (Container c : p.getBuildpath()) {
            files.add(c.getFile());
        }
    } else {
        for (String f : args) {
            File file = getFile(f);
            files.add(file);
        }
    }
    for (File f : files) {
        logger.debug("find {}", f);
        try (Jar jar = new Jar(f)) {
            Manifest m = jar.getManifest();
            if (m != null) {
                Domain domain = Domain.domain(m);
                if (options.exports() != null) {
                    Parameters ep = domain.getExportPackage();
                    for (Glob g : options.exports()) {
                        for (Entry<String, Attrs> exp : ep.entrySet()) {
                            if (g.matcher(exp.getKey()).matches()) {
                                String v = exp.getValue().get(VERSION_ATTRIBUTE);
                                if (v == null)
                                    v = "0";
                                out.printf(">%s: %s-%s%n", f.getPath(), exp.getKey(), v);
                            }
                        }
                    }
                }
                if (options.imports() != null) {
                    Parameters ip = domain.getImportPackage();
                    for (Glob g : options.imports()) {
                        for (Entry<String, Attrs> imp : ip.entrySet()) {
                            if (g.matcher(imp.getKey()).matches()) {
                                String v = imp.getValue().get(VERSION_ATTRIBUTE);
                                if (v == null)
                                    v = "0";
                                out.printf("<%s: %s-%s%n", f.getPath(), imp.getKey(), v);
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : Parameters(aQute.bnd.header.Parameters) ArrayList(java.util.ArrayList) Attrs(aQute.bnd.header.Attrs) Manifest(java.util.jar.Manifest) PomFromManifest(aQute.bnd.maven.PomFromManifest) Project(aQute.bnd.build.Project) Container(aQute.bnd.build.Container) Glob(aQute.libg.glob.Glob) Jar(aQute.bnd.osgi.Jar) Domain(aQute.bnd.osgi.Domain) File(java.io.File)

Aggregations

Container (aQute.bnd.build.Container)28 Project (aQute.bnd.build.Project)19 Workspace (aQute.bnd.build.Workspace)16 ArrayList (java.util.ArrayList)14 File (java.io.File)8 Attrs (aQute.bnd.header.Attrs)5 Jar (aQute.bnd.osgi.Jar)5 Manifest (java.util.jar.Manifest)5 Run (aQute.bnd.build.Run)3 Domain (aQute.bnd.osgi.Domain)3 EmbeddedResource (aQute.bnd.osgi.EmbeddedResource)3 FileResource (aQute.bnd.osgi.FileResource)3 Parameters (aQute.bnd.header.Parameters)2 Builder (aQute.bnd.osgi.Builder)2 JarResource (aQute.bnd.osgi.JarResource)2 Resource (aQute.bnd.osgi.Resource)2 ResourceBuilder (aQute.bnd.osgi.resource.ResourceBuilder)2 Version (aQute.bnd.version.Version)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 List (java.util.List)2