/**
   * @see com.liferay.modulesadmin.portlet.ModulesAdminPortlet#getBundle( BundleContext,
   *     InputStream)
   */
  public Bundle getBundle(BundleContext bundleContext, InputStream inputStream)
      throws PortalException {

    try {
      if (inputStream.markSupported()) {

        // 1 megabyte is more than enough for even the largest manifest
        // file

        inputStream.mark(1024 * 1000);
      }

      JarInputStream jarInputStream = new JarInputStream(inputStream);

      Manifest manifest = jarInputStream.getManifest();

      if (inputStream.markSupported()) {
        inputStream.reset();
      }

      Attributes attributes = manifest.getMainAttributes();

      String bundleSymbolicNameAttributeValue = attributes.getValue(Constants.BUNDLE_SYMBOLICNAME);

      Parameters parameters = OSGiHeader.parseHeader(bundleSymbolicNameAttributeValue);

      Set<String> bundleSymbolicNameSet = parameters.keySet();

      Iterator<String> bundleSymbolicNameIterator = bundleSymbolicNameSet.iterator();

      String bundleSymbolicName = bundleSymbolicNameIterator.next();

      String bundleVersionAttributeValue = attributes.getValue(Constants.BUNDLE_VERSION);

      Version bundleVersion = Version.parseVersion(bundleVersionAttributeValue);

      for (Bundle bundle : bundleContext.getBundles()) {
        Version curBundleVersion = Version.parseVersion(String.valueOf(bundle.getVersion()));

        if (bundleSymbolicName.equals(bundle.getSymbolicName())
            && bundleVersion.equals(curBundleVersion)) {

          return bundle;
        }
      }

      return null;
    } catch (IOException ioe) {
      throw new PortalException(ioe);
    }
  }
Ejemplo n.º 2
0
  /**
   * Test if we can select
   *
   * @throws Exception
   */
  public void testSelect() throws Exception {
    Jar bjara = getContractExporter("atest", "2.5", "${exports}");
    Jar bjarb = getContractExporter("btest", "2.5", "${exports}");

    Builder a = newBuilder();
    a.setTrace(true);

    a.addClasspath(bjara); // 1x
    a.addClasspath(bjarb); // 2x
    a.setProperty(Constants.CONTRACT, "atest;alpha=1");
    a.setImportPackage("org.osgi.service.cm,*");
    a.setProperty("Export-Package", "test.refer");
    Jar ajar = a.build();
    assertTrue(a.check());
    ajar.getManifest().write(System.out);

    Domain domain = Domain.domain(ajar.getManifest());
    Parameters p = domain.getRequireCapability();
    p.remove("osgi.ee");
    assertNotNull(p);
    assertEquals(1, p.size());
    Attrs attrs = p.get("osgi.contract");
    String alpha = attrs.get("alpha");
    assertEquals("1", alpha);
    assertEquals("(&(osgi.contract=atest)(version=2.5.0))", attrs.get("filter:"));
  }
Ejemplo n.º 3
0
  /** @throws Exception */
  File[] getBundleClasspathFiles() throws Exception {

    if (this.bundleClasspathExpansion != null) return bundleClasspathExpansion;

    File file = getFile();

    Manifest m = getManifest();
    String bundleClassPath;
    if (m == null
        || (bundleClassPath = m.getMainAttributes().getValue(Constants.BUNDLE_CLASSPATH)) == null) {
      this.bundleClasspathExpansion = new File[] {file};
    } else {

      File bundleClasspathDirectory =
          IO.getFile(file.getParentFile(), "." + file.getName() + "-bcp");
      Parameters header = new Parameters(bundleClassPath);
      this.bundleClasspathExpansion = new File[header.size()];
      bundleClasspathDirectory.mkdir();

      int n = 0;
      Jar jar = null;
      try {
        for (Map.Entry<String, Attrs> entry : header.entrySet()) {
          if (".".equals(entry.getKey())) {
            this.bundleClasspathExpansion[n] = file;
          } else {
            File member = new File(bundleClasspathDirectory, n + "-" + toName(entry.getKey()));
            if (!isCurrent(file, member)) {

              if (jar == null) {
                jar = new Jar(file);
              }

              Resource resource = jar.getResource(entry.getKey());
              if (resource == null) {
                warning += "Invalid bcp entry: " + entry.getKey() + "\n";
              } else {
                IO.copy(resource.openInputStream(), member);
                member.setLastModified(file.lastModified());
              }
            }
            this.bundleClasspathExpansion[n] = member;
          }
          n++;
        }
      } finally {
        if (jar != null) jar.close();
      }
    }

    return this.bundleClasspathExpansion;
  }
Ejemplo n.º 4
0
  /** Test default package versions. */
  public static void testDefaultPackageVersion() throws Exception {
    Builder a = new Builder();
    a.addClasspath(new File("bin"));
    a.setProperty("Bundle-Version", "1.2.3");
    a.setProperty("Export-Package", "test.refer");
    Jar jar = a.build();

    Manifest m = jar.getManifest();
    Parameters exports =
        Processor.parseHeader(m.getMainAttributes().getValue(Constants.EXPORT_PACKAGE), null);
    Map<String, String> attrs = exports.get("test.refer");
    assertNotNull(attrs);
    assertEquals("1.2.3", attrs.get("version"));
  }
  /**
   * Called when a change in the IDE is detected. We will then upate from the project and then
   * update the remote framework.
   */
  @Override
  public void update() throws Exception {
    updateFromProject();

    Parameters runremote = new Parameters(getProject().getProperty(Constants.RUNREMOTE));

    for (RunSessionImpl session : sessions)
      try {
        Attrs attrs = runremote.get(session.getName());
        RunRemoteDTO dto = Converter.cnv(RunRemoteDTO.class, attrs);
        session.update(dto);
      } catch (Exception e) {
        getProject().exception(e, "Failed to update session %s", session.getName());
      }
  }
  /** We parse the -runremote and create sessions for each one of them */
  @Override
  public void prepare() throws Exception {
    if (prepared) return;

    prepared = true;

    updateFromProject();

    Map<String, Object> properties = new HashMap<String, Object>(getRunProperties());

    calculatedProperties(properties);

    Collection<String> embeddedActivators = getActivators();
    if (embeddedActivators != null && !embeddedActivators.isEmpty()) {
      properties.put("biz.aQute.remote.embedded", Strings.join(embeddedActivators));
    }

    for (Entry<String, Attrs> entry : runremote.entrySet()) {
      RunRemoteDTO dto = converter.convert(RunRemoteDTO.class, entry.getValue());
      dto.name = entry.getKey();

      Map<String, Object> sessionProperties = new HashMap<String, Object>(properties);
      sessionProperties.putAll(entry.getValue());
      sessionProperties.put("session.name", dto.name);

      if (dto.jmx != null) {
        tryJMXDeploy(dto.jmx, "biz.aQute.remote.agent");
      }

      RunSessionImpl session = new RunSessionImpl(this, dto, properties);
      sessions.add(session);
    }
  }
Ejemplo n.º 7
0
  /**
   * Tests if the implementation of the EventHandler (which is marked as a ConsumerType) causes the
   * import of the api package to use the consumer version policy.
   */
  public static void testConsumerType() throws Exception {
    Builder a = new Builder();
    a.addClasspath(new File("bin"));
    a.setPrivatePackage("test.versionpolicy.uses");
    a.setExportPackage("test.versionpolicy.api");
    a.setProperty("build", "123");
    Jar jar = a.build();
    assertTrue(a.check());
    Manifest m = jar.getManifest();
    m.write(System.err);
    Domain d = Domain.domain(m);

    Parameters parameters = d.getImportPackage();
    Attrs attrs = parameters.get("test.versionpolicy.api");
    assertNotNull(attrs);
    assertEquals("[1.2,2)", attrs.get("version"));
  }
Ejemplo n.º 8
0
 public static List<Capability> getCapabilitiesFrom(Parameters rr) throws Exception {
   List<Capability> capabilities = new ArrayList<>();
   for (Entry<String, Attrs> e : rr.entrySet()) {
     capabilities.add(
         getCapabilityFrom(Processor.removeDuplicateMarker(e.getKey()), e.getValue()));
   }
   return capabilities;
 }
Ejemplo n.º 9
0
  /**
   * Test if the implementation of "AnnotatedProviderInterface", which is annotated with OSGi
   * R6 @ProviderType, causes import of the api package to use the provider version policy
   */
  public static void testProviderTypeR6() throws Exception {
    Builder b = new Builder();
    b.addClasspath(new File("bin"));
    b.setPrivatePackage("test.versionpolicy.implemented.osgi");
    b.setProperty("build", "123");

    Jar jar = b.build();
    assertTrue(b.check());
    Manifest m = jar.getManifest();
    m.write(System.err);

    Domain d = Domain.domain(m);
    Parameters params = d.getImportPackage();
    Attrs attrs = params.get("test.version.annotations.osgi");
    assertNotNull(attrs);
    assertEquals("[1.2,1.3)", attrs.get("version"));
  }
Ejemplo n.º 10
0
 public static List<Requirement> getRequirementsFrom(Parameters rr) throws Exception {
   List<Requirement> requirements = new ArrayList<Requirement>();
   for (Entry<String, Attrs> e : rr.entrySet()) {
     requirements.add(
         getRequirementFrom(Processor.removeDuplicateMarker(e.getKey()), e.getValue()));
   }
   return requirements;
 }
Ejemplo n.º 11
0
  /**
   * Make sure we do not add a contract if not used
   *
   * @throws Exception
   */
  public void testUnused() throws Exception {
    Jar bjara = getContractExporter("atest", "2.5", "${exports}");

    Builder a = newBuilder();
    a.setTrace(true);
    a.addClasspath(bjara);

    a.setProperty(Constants.CONTRACT, "*");
    a.setImportPackage("test.packageinfo,*");
    a.setProperty("Export-Package", "test.refer");
    Jar ajar = a.build();
    assertTrue(a.check());

    Domain domain = Domain.domain(ajar.getManifest());
    Parameters p = domain.getRequireCapability();
    p.remove("osgi.ee");
    assertEquals(0, p.size());
  }
Ejemplo n.º 12
0
  /**
   * Test the warnings that we have no no version
   *
   * @throws Exception
   */
  public void testWarningVersion() throws Exception {
    Jar bjara = getContractExporter("abc", null, "${exports}");

    Builder a = newBuilder();
    a.setTrace(true);
    a.addClasspath(bjara);

    a.setProperty(Constants.CONTRACT, "*");
    a.setImportPackage("test.packageinfo,*");
    a.setProperty("Export-Package", "test.refer");
    Jar ajar = a.build();
    assertTrue(
        a.check(
            "Contract \\[name=abc;version=0.0.0;from=biz.aQute.bndlib.tests] does not declare a version"));

    Domain domain = Domain.domain(ajar.getManifest());
    Parameters p = domain.getRequireCapability();
    p.remove("osgi.ee");
    assertEquals(0, p.size());
  }
Ejemplo n.º 13
0
  /**
   * Tests if the implementation of the EventAdmin (which is marked as a ProviderType) causes the
   * import of the api package to use the provider version policy.
   */
  public static void testProviderType() throws Exception {
    Builder a = new Builder();
    a.addClasspath(new File("bin"));
    a.setPrivatePackage("test.versionpolicy.implemented");
    a.setExportPackage("test.versionpolicy.api");
    a.setImportPackage("test.versionpolicy.api"); // what changed so this is
    // not automatically
    // added?
    a.setProperty("build", "123");
    Jar jar = a.build();
    assertTrue(a.check());
    Manifest m = jar.getManifest();
    m.write(System.err);
    Domain d = Domain.domain(m);

    Parameters parameters = d.getImportPackage();
    Attrs attrs = parameters.get("test.versionpolicy.api");
    assertNotNull(attrs);
    assertEquals("[1.2,1.3)", attrs.get("version"));
  }
Ejemplo n.º 14
0
  private boolean _hasLazyActivationPolicy(Bundle bundle) {
    Dictionary<String, String> headers = bundle.getHeaders();

    String fragmentHost = headers.get(Constants.FRAGMENT_HOST);

    if (fragmentHost != null) {
      return false;
    }

    String activationPolicy = headers.get(Constants.BUNDLE_ACTIVATIONPOLICY);

    if (activationPolicy == null) {
      return false;
    }

    Parameters parameters = OSGiHeader.parseHeader(activationPolicy);

    if (parameters.containsKey(Constants.ACTIVATION_LAZY)) {
      return true;
    }

    return false;
  }
Ejemplo n.º 15
0
  /** Check implementation version policy. Uses the package test.versionpolicy.(uses|implemented) */
  static void assertPolicy(String pack, String type) throws Exception {
    Builder a = new Builder();
    a.addClasspath(new File("bin"));
    a.setProperty("Export-Package", "test.versionpolicy.api");
    Jar jar = a.build();

    Builder b = new Builder();
    b.addClasspath(jar);
    b.addClasspath(new File("bin"));

    b.setProperty("-versionpolicy-impl", "IMPL");
    b.setProperty("-versionpolicy-uses", "USES");
    b.setProperty("Private-Package", pack);
    b.build();
    Manifest m = b.getJar().getManifest();
    m.write(System.err);
    Map<String, String> map = b.getImports().getByFQN("test.versionpolicy.api");
    assertNotNull(map);
    // String s = map.get(Constants.IMPLEMENTED_DIRECTIVE);
    // assertEquals("true", s);
    Parameters mp = Processor.parseHeader(m.getMainAttributes().getValue("Import-Package"), null);
    assertEquals(type, mp.get("test.versionpolicy.api").get("version"));
  }
Ejemplo n.º 16
0
  public void testSimple() throws Exception {
    Jar bjar = getContractExporter("test", "2.5", "${exports}");

    Builder a = newBuilder();
    a.setTrace(true);
    a.addClasspath(bjar);
    a.setProperty(Constants.CONTRACT, "*");
    a.setImportPackage("org.osgi.service.cm,*");
    a.setProperty("Export-Package", "test.refer");
    Jar ajar = a.build();
    assertTrue(a.check());
    Domain domain = Domain.domain(ajar.getManifest());
    Parameters rc = domain.getRequireCapability();
    rc.remove("osgi.ee");
    System.out.println(rc);
    assertEquals(1, rc.size());

    Packages ps = a.getImports();
    assertTrue(ps.containsFQN("org.osgi.service.cm"));
    Attrs attrs = ps.getByFQN("org.osgi.service.cm");
    assertNotNull(attrs);
    assertNull(attrs.getVersion());
  }
Ejemplo n.º 17
0
  public static void testCapability() throws Exception {

    Parameters h =
        OSGiHeader.parseHeader(
            "test; version.list:List < Version > = \"1.0, 1.1, 1.2\"; effective:=\"resolve\"; test =\"aName\";version : Version=\"1.0\"; long :Long=\"100\"; "
                + "double: Double=\"1.001\"; string:String =\"aString\";   "
                + "long.list : List <Long >=\"1, 2, 3, 4\";double.list: List< Double>= \"1.001, 1.002, 1.003\"; "
                + "string.list :List<String >= \"aString,bString,cString\"");

    assertEquals(Attrs.Type.VERSION, h.get("test").getType("version"));
    assertEquals(Attrs.Type.LONG, h.get("test").getType("long"));
    assertEquals(Attrs.Type.DOUBLE, h.get("test").getType("double"));
    assertEquals(Attrs.Type.STRING, h.get("test").getType("string"));
    assertEquals(Attrs.Type.STRING, h.get("test").getType("test"));
    assertEquals(Attrs.Type.LONGS, h.get("test").getType("long.list"));
    assertEquals(Attrs.Type.DOUBLES, h.get("test").getType("double.list"));
    assertEquals(Attrs.Type.STRINGS, h.get("test").getType("string.list"));
    assertEquals(Attrs.Type.VERSIONS, h.get("test").getType("version.list"));
  }
Ejemplo n.º 18
0
  public CommandData parseCommandData(ArtifactData artifact) throws Exception {
    File source = new File(artifact.file);
    if (!source.isFile()) throw new FileNotFoundException();

    CommandData data = new CommandData();
    data.sha = artifact.sha;
    data.jpmRepoDir = repoDir.getCanonicalPath();
    JarFile jar = new JarFile(source);
    try {
      reporter.trace("Parsing %s", source);
      Manifest m = jar.getManifest();
      Attributes main = m.getMainAttributes();
      data.name = data.bsn = main.getValue("Bundle-SymbolicName");
      String version = main.getValue("Bundle-Version");
      if (version == null) data.version = Version.LOWEST;
      else data.version = new Version(version);

      data.main = main.getValue("Main-Class");
      data.description = main.getValue("Bundle-Description");
      data.title = main.getValue("JPM-Name");

      reporter.trace("name " + data.name + " " + data.main + " " + data.title);
      DependencyCollector path = new DependencyCollector(this);
      path.add(artifact);
      DependencyCollector bundles = new DependencyCollector(this);
      if (main.getValue("JPM-Classpath") != null) {
        Parameters requires = OSGiHeader.parseHeader(main.getValue("JPM-Classpath"));

        for (Map.Entry<String, Attrs> e : requires.entrySet()) {
          path.add(e.getKey(), e.getValue().get("name")); // coordinate
        }
      } else if (!artifact.local) { // No JPM-Classpath, falling back to
        // server's revision
        // Iterable<RevisionRef> closure =
        // library.getClosure(artifact.sha,
        // false);
        // System.out.println("getting closure " + artifact.url + " " +
        // Strings.join("\n",closure));

        // if (closure != null) {
        // for (RevisionRef ref : closure) {
        // path.add(Hex.toHexString(ref.revision));
        // }
        // }
      }

      if (main.getValue("JPM-Runbundles") != null) {
        Parameters jpmrunbundles = OSGiHeader.parseHeader(main.getValue("JPM-Runbundles"));

        for (Map.Entry<String, Attrs> e : jpmrunbundles.entrySet()) {
          bundles.add(e.getKey(), e.getValue().get("name"));
        }
      }

      reporter.trace("collect digests runpath");
      data.dependencies.addAll(path.getDigests());
      reporter.trace("collect digests bundles");
      data.runbundles.addAll(bundles.getDigests());

      Parameters command = OSGiHeader.parseHeader(main.getValue("JPM-Command"));
      if (command.size() > 1) reporter.error("Only one command can be specified");

      for (Map.Entry<String, Attrs> e : command.entrySet()) {
        data.name = e.getKey();

        Attrs attrs = e.getValue();

        if (attrs.containsKey("jvmargs")) data.jvmArgs = attrs.get("jvmargs");

        if (attrs.containsKey("title")) data.title = attrs.get("title");

        if (data.title != null) data.title = data.name;
      }
      return data;
    } finally {
      jar.close();
    }
  }
Ejemplo n.º 19
0
  private void _processURL(StringBundler sb, URL url, String[] ignoredFragments) {

    Manifest manifest = null;

    try {
      manifest = new Manifest(url.openStream());
    } catch (IOException ioe) {
      _log.error(ioe, ioe);

      return;
    }

    Attributes attributes = manifest.getMainAttributes();

    String bundleSymbolicName = attributes.getValue(Constants.BUNDLE_SYMBOLICNAME);

    if (Validator.isNull(bundleSymbolicName)) {
      String urlString = url.toString();

      if (urlString.contains(PropsValues.LIFERAY_LIB_PORTAL_DIR)) {
        manifest = _calculateManifest(url, manifest);

        attributes = manifest.getMainAttributes();

        bundleSymbolicName =
            attributes.getValue(new Attributes.Name(Constants.BUNDLE_SYMBOLICNAME));

        if (Validator.isNull(bundleSymbolicName)) {
          return;
        }
      } else {
        return;
      }
    }

    String rootBundleSymbolicName = bundleSymbolicName;

    int index = rootBundleSymbolicName.indexOf(StringPool.SEMICOLON);

    if (index != -1) {
      rootBundleSymbolicName = rootBundleSymbolicName.substring(0, index);
    }

    for (String ignoredFragment : ignoredFragments) {
      String ignoredFramentPrefix = ignoredFragment.substring(0, ignoredFragment.length() - 1);

      if (rootBundleSymbolicName.equals(ignoredFragment)
          || (ignoredFragment.endsWith(StringPool.STAR)
              && rootBundleSymbolicName.startsWith(ignoredFramentPrefix))) {

        return;
      }
    }

    String exportPackage = GetterUtil.getString(attributes.getValue(Constants.EXPORT_PACKAGE));

    Parameters parameters = OSGiHeader.parseHeader(exportPackage);

    for (Map.Entry<String, Attrs> entry : parameters.entrySet()) {
      String key = entry.getKey();

      List<URL> urls = _extraPackageMap.get(key);

      if (urls == null) {
        urls = new ArrayList<URL>();

        _extraPackageMap.put(key, urls);
      }

      urls.add(url);

      sb.append(key);

      Attrs value = entry.getValue();

      if (value.containsKey("version")) {
        sb.append(";version=\"");
        sb.append(value.get("version"));
        sb.append("\"");
      }

      sb.append(StringPool.COMMA);
    }
  }
Ejemplo n.º 20
0
  /**
   * Create a standalone executable. All entries on the runpath are rolled out into the JAR and the
   * runbundles are copied to a directory in the jar. The launcher will see that it starts in
   * embedded mode and will automatically detect that it should load the bundles from inside. This
   * is drive by the launcher.embedded flag.
   *
   * @throws Exception
   */
  @Override
  public Jar executable() throws Exception {

    // TODO use constants in the future
    Parameters packageHeader = OSGiHeader.parseHeader(project.getProperty("-package"));
    boolean useShas = packageHeader.containsKey("jpm");
    project.trace("Useshas %s %s", useShas, packageHeader);

    Jar jar = new Jar(project.getName());

    Builder b = new Builder();
    project.addClose(b);

    if (!project.getIncludeResource().isEmpty()) {
      b.setIncludeResource(project.getIncludeResource().toString());
      b.setProperty(Constants.RESOURCEONLY, "true");
      b.build();
      if (b.isOk()) {
        jar.addAll(b.getJar());
      }
      project.getInfo(b);
    }

    List<String> runpath = getRunpath();

    Set<String> runpathShas = new LinkedHashSet<String>();
    Set<String> runbundleShas = new LinkedHashSet<String>();
    List<String> classpath = new ArrayList<String>();

    for (String path : runpath) {
      project.trace("embedding runpath %s", path);
      File file = new File(path);
      if (file.isFile()) {
        if (useShas) {
          String sha = SHA1.digest(file).asHex();
          runpathShas.add(sha + ";name=\"" + file.getName() + "\"");
        } else {
          String newPath = "jar/" + file.getName();
          jar.putResource(newPath, new FileResource(file));
          classpath.add(newPath);
        }
      }
    }

    // Copy the bundles to the JAR

    List<String> runbundles = (List<String>) getRunBundles();
    List<String> actualPaths = new ArrayList<String>();

    for (String path : runbundles) {
      project.trace("embedding run bundles %s", path);
      File file = new File(path);
      if (!file.isFile()) project.error("Invalid entry in -runbundles %s", file);
      else {
        if (useShas) {
          String sha = SHA1.digest(file).asHex();
          runbundleShas.add(sha + ";name=\"" + file.getName() + "\"");
          actualPaths.add("${JPMREPO}/" + sha);
        } else {
          String newPath = "jar/" + file.getName();
          jar.putResource(newPath, new FileResource(file));
          actualPaths.add(newPath);
        }
      }
    }

    LauncherConstants lc = getConstants(actualPaths, true);
    lc.embedded = !useShas;
    lc.storageDir = null; // cannot use local info

    final Properties p = lc.getProperties(new UTF8Properties());

    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    p.store(bout, "");
    jar.putResource(
        LauncherConstants.DEFAULT_LAUNCHER_PROPERTIES,
        new EmbeddedResource(bout.toByteArray(), 0L));

    Manifest m = new Manifest();
    Attributes main = m.getMainAttributes();

    for (Entry<Object, Object> e : project.getFlattenedProperties().entrySet()) {
      String key = (String) e.getKey();
      if (key.length() > 0 && Character.isUpperCase(key.charAt(0)))
        main.putValue(key, (String) e.getValue());
    }

    Instructions instructions = new Instructions(project.getProperty(Constants.REMOVEHEADERS));
    Collection<Object> result = instructions.select(main.keySet(), false);
    main.keySet().removeAll(result);

    if (useShas) {
      project.trace("Use JPM launcher");
      m.getMainAttributes().putValue("Main-Class", JPM_LAUNCHER_FQN);
      m.getMainAttributes().putValue("JPM-Classpath", Processor.join(runpathShas));
      m.getMainAttributes().putValue("JPM-Runbundles", Processor.join(runbundleShas));
      URLResource jpmLauncher = new URLResource(this.getClass().getResource("/" + JPM_LAUNCHER));
      jar.putResource(JPM_LAUNCHER, jpmLauncher);
      doStart(jar, JPM_LAUNCHER_FQN);
    } else {
      project.trace("Use Embedded launcher");
      m.getMainAttributes().putValue("Main-Class", EMBEDDED_LAUNCHER_FQN);
      m.getMainAttributes().putValue(EmbeddedLauncher.EMBEDDED_RUNPATH, Processor.join(classpath));
      URLResource embeddedLauncher =
          new URLResource(this.getClass().getResource("/" + EMBEDDED_LAUNCHER));
      jar.putResource(EMBEDDED_LAUNCHER, embeddedLauncher);
      doStart(jar, EMBEDDED_LAUNCHER_FQN);
    }
    if (project.getProperty(Constants.DIGESTS) != null)
      jar.setDigestAlgorithms(project.getProperty(Constants.DIGESTS).trim().split("\\s*,\\s*"));
    else jar.setDigestAlgorithms(new String[] {"SHA-1", "MD-5"});
    jar.setManifest(m);
    return jar;
  }