Search in sources :

Example 21 with Container

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

the class ProjectTest method testRepoFilterBuildPathMultiple.

public void testRepoFilterBuildPathMultiple() throws Exception {
    Workspace ws = getWorkspace(IO.getFile("testresources/ws"));
    Project project = ws.getProject("repofilter");
    project.setProperty("-buildpath", "org.apache.felix.configadmin; version=latest; repo=\"Rel*,Repo\"");
    ArrayList<Container> buildpath = new ArrayList<Container>(project.getBuildpath());
    assertEquals(1, buildpath.size());
    // Expect 1.2.0 from Release repo; not 1.8.8 from Repo2
    assertEquals("1.2.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 22 with Container

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

the class ProjectTest method testHashVersionNonMatchingBsn.

public void testHashVersionNonMatchingBsn() throws Exception {
    Workspace ws = getWorkspace(IO.getFile("testresources/ws-versionhash"));
    Project project = ws.getProject("p1");
    assertNotNull(project);
    project.setProperty("-buildpath", "WRONG; version=hash; hash=SHA-256: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 23 with Container

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

the class ProjectTest method testMulti.

/**
	 * Test the multi-key support on runbundles/runpath/testpath and buildpath
	 */
public void testMulti() throws Exception {
    Workspace ws = getWorkspace(IO.getFile("testresources/ws"));
    Project project = ws.getProject("multipath");
    assertNotNull(project);
    List<Container> runbundles = new ArrayList<Container>(project.getRunbundles());
    assertEquals(3, runbundles.size());
    assertEquals("org.apache.felix.configadmin", runbundles.get(0).getBundleSymbolicName());
    assertEquals("org.apache.felix.ipojo", runbundles.get(1).getBundleSymbolicName());
    assertEquals("osgi.core", runbundles.get(2).getBundleSymbolicName());
    List<Container> runpath = new ArrayList<Container>(project.getRunpath());
    assertEquals(3, runpath.size());
    List<Container> buildpath = new ArrayList<Container>(project.getBuildpath());
    assertEquals(3, buildpath.size());
    List<Container> testpath = new ArrayList<Container>(project.getTestpath());
    assertEquals(3, testpath.size());
}
Also used : Project(aQute.bnd.build.Project) Container(aQute.bnd.build.Container) ArrayList(java.util.ArrayList) Workspace(aQute.bnd.build.Workspace)

Example 24 with Container

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

the class ProjectTest method testHashVersion.

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

Example 25 with Container

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

the class Repository method cleanUp.

/**
	 * Remove any unused entries in this repository
	 * 
	 * @throws Exception
	 */
void cleanUp() throws Exception {
    Workspace workspace = registry.getPlugin(Workspace.class);
    Set<Container> set = new HashSet<Container>();
    for (Project project : workspace.getAllProjects()) {
        set.addAll(project.getBuildpath());
        set.addAll(project.getRunbundles());
        set.addAll(project.getRunpath());
        set.addAll(project.getTestpath());
        set.addAll(project.getBootclasspath());
        set.addAll(project.getClasspath());
        //
        // This should be replaced with project.getRunfw()
        //
        String s = project.getProperty(Constants.RUNFW);
        List<Container> bundles = project.getBundles(Strategy.HIGHEST, s, Constants.RUNFW);
        set.addAll(bundles);
        File base = project.getBase();
        for (File sub : base.listFiles()) {
            if (sub.getName().endsWith(".bndrun")) {
                try (Project bndrun = new Project(workspace, base, sub)) {
                    set.addAll(bndrun.getRunbundles());
                    set.addAll(bndrun.getRunpath());
                    set.addAll(bndrun.getTestpath());
                    set.addAll(bndrun.getBootclasspath());
                    set.addAll(bndrun.getClasspath());
                }
            }
        }
    }
    Set<RevisionRef> refs = new HashSet<RevisionRef>(index.getRevisionRefs());
    Set<RevisionRef> keep = new HashSet<RevisionRef>();
    for (Container libOrRev : set) {
        for (Container c : libOrRev.getMembers()) {
            logger.debug("Dependency {}", c);
            if (!Verifier.isVersion(c.getVersion()))
                continue;
            RevisionRef ref = index.getRevisionRef(c.getBundleSymbolicName(), new Version(c.getVersion()));
            if (ref != null)
                refs.remove(ref);
            else {
                // missing!
                logger.debug("Missing {}", c.getBundleSymbolicName());
                Coordinate coord = new Coordinate(c.getBundleSymbolicName());
                Revision rev = getLibrary().getRevisionByCoordinate(coord);
                if (rev != null) {
                    index.addRevision(new RevisionRef(rev));
                } else
                    System.out.printf("not found %s\n", c);
            }
            keep.add(ref);
        }
    }
    for (RevisionRef ref : refs) {
        index.delete(ref.bsn, Index.toVersion(ref));
    }
    index.save();
}
Also used : Project(aQute.bnd.build.Project) Container(aQute.bnd.build.Container) RevisionRef(aQute.service.library.Library.RevisionRef) Revision(aQute.service.library.Library.Revision) Version(aQute.bnd.version.Version) Coordinate(aQute.service.library.Coordinate) File(java.io.File) Workspace(aQute.bnd.build.Workspace) HashSet(java.util.HashSet)

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