Exemplo n.º 1
0
 private void addPackageHeader(String headerName, Map<String, String> packageMap)
     throws ManifestException {
   final Iterator<Entry<String, String>> i = packageMap.entrySet().iterator();
   if (i.hasNext()) {
     final StringBuffer valueBuffer = new StringBuffer();
     while (i.hasNext()) {
       final Entry<String, String> entry = i.next();
       final String name = entry.getKey();
       String version = entry.getValue();
       valueBuffer.append(name);
       if (version != null) {
         version = version.trim();
         if (0 < version.length()) {
           valueBuffer.append(";version=");
           final boolean quotingNeeded = -1 != version.indexOf(',') && '"' != version.charAt(0);
           if (quotingNeeded) {
             valueBuffer.append('"');
           }
           valueBuffer.append(version);
           if (quotingNeeded) {
             valueBuffer.append('"');
           }
         }
       }
       valueBuffer.append(',');
     }
     valueBuffer.setLength(valueBuffer.length() - 1);
     final String value = valueBuffer.toString();
     generatedManifest.addConfiguredAttribute(createAttribute(headerName, value));
     log(headerName + ": " + value, Project.MSG_INFO);
   }
 }
Exemplo n.º 2
0
 private void handleActivator() throws ManifestException {
   if (activator == ACTIVATOR_NONE) {
     log("No BundleActivator set", Project.MSG_DEBUG);
   } else if (activator == ACTIVATOR_AUTO) {
     switch (bpInfo.countProvidedActivatorClasses()) {
       case 0:
         {
           log("No class implementing BundleActivator found", Project.MSG_INFO);
           break;
         }
       case 1:
         {
           activator = bpInfo.getActivatorClass();
           break;
         }
       default:
         {
           log(
               "More than one class implementing BundleActivator found: "
                   + bpInfo.providedActivatorClassesAsString(),
               Project.MSG_WARN);
           break;
         }
     }
   }
   if (activator != ACTIVATOR_NONE && activator != ACTIVATOR_AUTO) {
     log("Bundle-Activator: " + activator, Project.MSG_INFO);
     generatedManifest.addConfiguredAttribute(createAttribute(BUNDLE_ACTIVATOR_KEY, activator));
   }
 }
Exemplo n.º 3
0
 void setManifest(Manifest man, String key, String value) {
   if (!StringUtils.isEmpty(value)) {
     try {
       man.addConfiguredAttribute(new Attribute(key, value));
     } catch (ManifestException e) {
       console.error(e, "Failed to set manifest attribute \"{0}\"!", key);
     }
   }
 }
Exemplo n.º 4
0
  private void handleClassPath() throws ManifestException {
    final StringBuffer value = new StringBuffer();

    boolean rootIncluded = false;
    if (baseDir != null || classes.size() == 0) {
      value.append(".,");
      rootIncluded = true;
    }

    Iterator<ZipFileSet> i = classes.iterator();
    while (i.hasNext()) {
      final ZipFileSet zipFileSet = i.next();
      final String prefix = zipFileSet.getPrefix(getProject());
      if (prefix.length() > 0) {
        value.append(prefix);
        value.append(',');
      } else if (!rootIncluded) {
        value.append(".,");
        rootIncluded = true;
      }
    }

    i = libs.iterator();
    while (i.hasNext()) {
      final ZipFileSet fileset = i.next();
      if (fileset.getSrc(getProject()) == null) {
        final DirectoryScanner ds = fileset.getDirectoryScanner(getProject());
        final String[] files = ds.getIncludedFiles();
        if (files.length != 0) {
          zipgroups.add(fileset);
          final String prefix = fixPrefix(fileset.getPrefix(getProject()));
          for (final String file : files) {
            value.append(prefix.replace('\\', '/'));
            value.append(file.replace('\\', '/'));
            value.append(',');
          }
        }
      }
    }

    if (value.length() > 2) {
      generatedManifest.addConfiguredAttribute(
          createAttribute(BUNDLE_CLASS_PATH_KEY, value.substring(0, value.length() - 1)));
    }
  }