public static VersionedClause convertRepoBundleVersion(RepositoryBundleVersion bundleVersion) {
   Attrs attribs = new Attrs();
   if (isWorkspaceRepo(bundleVersion.getBundle().getRepo()))
     attribs.put(Constants.VERSION_ATTRIBUTE, VERSION_LATEST);
   else attribs.put(Constants.VERSION_ATTRIBUTE, bundleVersion.getVersion().toString());
   return new VersionedClause(bundleVersion.getBundle().getBsn(), attribs);
 }
 public static VersionedClause convertRepoBundle(RepositoryBundle bundle) {
   Attrs attribs = new Attrs();
   if (isWorkspaceRepo(bundle.getRepo())) {
     attribs.put(Constants.VERSION_ATTRIBUTE, VERSION_LATEST);
   }
   return new VersionedClause(bundle.getBsn(), attribs);
 }
  /** 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;
  }
Beispiel #4
0
  public Attrs toAttrs() {
    Attrs attrs = new Attrs();

    if (attributes != null) {
      for (Entry<String, Object> e : attributes.entrySet()) {
        Object value = e.getValue();

        if (e.getKey().equals("version") || value instanceof Version) value = toBndVersions(value);

        attrs.putTyped(e.getKey(), value);
      }
    }

    if (directives != null)
      for (Entry<String, String> e : directives.entrySet()) {
        attrs.put(e.getKey() + ":", e.getValue());
      }

    return attrs;
  }