Search in sources :

Example 1 with Container

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;
}
Also used : Attrs(aQute.bnd.header.Attrs) FileResource(aQute.bnd.osgi.FileResource) EmbeddedActivator(aQute.remote.embedded.activator.EmbeddedActivator) Analyzer(aQute.bnd.osgi.Analyzer) Manifest(java.util.jar.Manifest) URLResource(aQute.bnd.osgi.URLResource) Container(aQute.bnd.build.Container) Jar(aQute.bnd.osgi.Jar) File(java.io.File)

Example 2 with Container

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"));
}
Also used : Project(aQute.bnd.build.Project) Container(aQute.bnd.build.Container) ArrayList(java.util.ArrayList) Workspace(aQute.bnd.build.Workspace)

Example 3 with Container

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());
}
Also used : Project(aQute.bnd.build.Project) Container(aQute.bnd.build.Container) Workspace(aQute.bnd.build.Workspace)

Example 4 with Container

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());
}
Also used : Project(aQute.bnd.build.Project) Container(aQute.bnd.build.Container) Workspace(aQute.bnd.build.Workspace)

Example 5 with Container

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());
}
Also used : Project(aQute.bnd.build.Project) Container(aQute.bnd.build.Container) Workspace(aQute.bnd.build.Workspace)

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