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());
}
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());
}
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());
}
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"));
}
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();
}
Aggregations