Esempio n. 1
0
  /**
   * Take a container list and flatten it (e.g. expand any libraries).
   *
   * @param containers The containers to flatten, can be null
   * @param list of containers guaranteed to contain no libraries
   */
  public static void flatten(Collection<Container> containers, List<Container> list)
      throws Exception {
    if (containers == null) return;

    for (Container container : containers) {
      flatten(container, list);
    }
  }
  /** 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;
  }
Esempio n. 3
0
 /**
  * Take a container list and flatten it (e.g. expand any libraries).
  *
  * @param containers The containers to flatten, can be null
  * @return a list of containers guaranteed to contain no libraries
  */
 public static List<Container> flatten(Collection<Container> containers) throws Exception {
   List<Container> list = new ArrayList<Container>();
   flatten(containers, list);
   return list;
 }
Esempio n. 4
0
 /**
  * Flatten a container in the output list. (e.g. expand any libraries).
  *
  * @param container the container to flatten
  * @param list the result list
  */
 public static void flatten(Container container, List<Container> list) throws Exception {
   if (container.getType() == TYPE.LIBRARY) {
     flatten(container.getMembers(), list);
   } else list.add(container);
 }