use of aQute.bnd.build.Container in project bnd by bndtools.
the class RemoteProjectLauncherPlugin method executable.
/**
* Created a JAR that is a bundle and that contains its dependencies
*/
@Override
public Jar executable() throws Exception {
Collection<String> bsns = getProject().getBsns();
if (bsns.size() != 1)
throw new IllegalArgumentException("Can only handle a single bsn for a run configuration " + bsns);
String bsn = bsns.iterator().next();
Jar jar = new Jar(bsn);
String path = "aQute/remote/embedded/activator/EmbeddedActivator.class";
URLResource resource = new URLResource(getClass().getClassLoader().getResource(path));
jar.putResource("aQute/remote/embedded/activator/EmbeddedActivator.class", resource);
Collection<Container> rb = getProject().getRunbundles();
rb = Container.flatten(rb);
Attrs attrs = new Attrs();
for (Container c : rb) {
if (c.getError() != null) {
getProject().error("invalid runbundle %s", c);
} else {
File f = c.getFile();
String tbsn = c.getBundleSymbolicName();
String version = c.getVersion();
if (version == null || !Version.isVersion(version))
getProject().warning("The version of embedded bundle %s does not have a proper version", c);
jar.putResource("jar/" + c.getBundleSymbolicName() + ".jar", new FileResource(f));
attrs.put(tbsn, version);
}
}
Analyzer a = new Analyzer(getProject());
a.setJar(jar);
a.setBundleActivator(EmbeddedActivator.class.getName());
a.setProperty("Bnd-Embedded", attrs.toString().replace(';', ','));
Manifest manifest = a.calcManifest();
jar.setManifest(manifest);
getProject().getInfo(a);
return jar;
}
use of aQute.bnd.build.Container in project bnd by bndtools.
the class ProjectTest method testHashVersionWithAlgorithm.
public void testHashVersionWithAlgorithm() 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-256: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 ProjectTest method testRunBundlesContainsSelf.
/**
* Test bnd.bnd of project `foo`: `-runbundles: foo;version=latest`
*/
public void testRunBundlesContainsSelf() throws Exception {
Workspace ws = getWorkspace(IO.getFile("testresources/ws"));
Project top = ws.getProject("p1");
top.setDelayRunDependencies(false);
top.setProperty("-runbundles", "p1;version=latest");
top.setChanged();
top.isStale();
Collection<Container> runbundles = top.getRunbundles();
assertTrue(top.check("Circular dependency"));
assertNotNull(runbundles);
assertEquals(0, runbundles.size());
}
use of aQute.bnd.build.Container in project bnd by bndtools.
the class ProjectTest method testSameBsnRunBundles.
/**
* Test 2 equal bsns but diff. versions
*/
public void testSameBsnRunBundles() throws Exception {
Workspace ws = getWorkspace(IO.getFile("testresources/ws"));
Project top = ws.getProject("p1");
top.setProperty("-runbundles", "org.apache.felix.configadmin;version='[1.0.1,1.0.1]',org.apache.felix.configadmin;version='[1.1.0,1.1.0]'");
Collection<Container> runbundles = top.getRunbundles();
assertTrue(top.check());
assertNotNull(runbundles);
assertEquals(2, runbundles.size());
}
use of aQute.bnd.build.Container in project bnd by bndtools.
the class ProjectTest method testMultipleRepos.
/**
* Check multiple repos
*
* @throws Exception
*/
public void testMultipleRepos() throws Exception {
Workspace ws = getWorkspace(IO.getFile("testresources/ws"));
Project project = ws.getProject("p1");
project.setPedantic(true);
System.err.println(project.getBundle("org.apache.felix.configadmin", "1.1.0", Strategy.EXACT, null));
System.err.println(project.getBundle("org.apache.felix.configadmin", "1.1.0", Strategy.HIGHEST, null));
System.err.println(project.getBundle("org.apache.felix.configadmin", "1.1.0", Strategy.LOWEST, null));
List<Container> bundles = project.getBundles(Strategy.LOWEST, "org.apache.felix.configadmin;version=1.1.0,org.apache.felix.configadmin;version=1.1.0", "test");
assertTrue(project.check("Multiple bundles with the same final URL", "Duplicate name"));
assertEquals(1, bundles.size());
}
Aggregations