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));
   }
 }
 public void addConfiguredStandardPackage(OSGiPackage osgiPackage) {
   final String name = osgiPackage.getName();
   final String prefix = osgiPackage.getPrefix();
   if (name != null && prefix == null) {
     bpInfo.addProvidedPackage(name);
   } else if (prefix != null && name == null) {
     standardPackagePrefixes.add(prefix);
   } else {
     throw new BuildException(
         "StandardPackage must have exactly one of the name and prefix attributes defined");
   }
 }
  protected void analyzePackageinfo(Resource res) throws BuildException {
    log("Analyze packageinfo file " + res, Project.MSG_VERBOSE);

    bpInfo.setPackageVersion(res);
  }
  private void analyze() {
    if (activator == ACTIVATOR_AUTO || packageAnalysis != PACKAGE_ANALYSIS_NONE) {
      addZipGroups();
      addImplicitFileset();

      for (final FileSet fileset : srcFilesets) {
        for (@SuppressWarnings("unchecked") final Iterator<Resource> fsIt = fileset.iterator();
            fsIt.hasNext(); ) {
          final Resource res = fsIt.next();
          analyze(res);
        }
      }
      // Scan done
      bpInfo.toJavaNames();

      final Set<String> publicPackages = exportPackage.keySet();

      if (packageAnalysis != PACKAGE_ANALYSIS_NONE) {
        for (final String packageName : publicPackages) {
          if (!bpInfo.providesPackage(packageName)) {
            log("Exported package not provided by bundle: " + packageName, Project.MSG_WARN);
          }
          // The Version from the packageinfo-file or null
          final Version piVersion = bpInfo.getProvidedPackageVersion(packageName);
          if (null != piVersion) {
            final String epVersionS = exportPackage.get(packageName);
            if (null == epVersionS) {
              // Use the version form the packageinfo-file
              exportPackage.put(packageName, piVersion.toString());
            } else {
              // Check that the versions match, if not trigger a build error
              try {
                final Version epVersion = Version.parseVersion(epVersionS);
                if (0 != epVersion.compareTo(piVersion)) {
                  final String msg =
                      "Multiple versions found for export of "
                          + "the package '"
                          + packageName
                          + "'. The packageinfo file ("
                          + bpInfo.getProvidedPackageVersionSource(packageName)
                          + ") states '"
                          + piVersion.toString()
                          + "' but the <exportpackage> element says '"
                          + epVersion.toString()
                          + "'.";
                  log(msg, Project.MSG_ERR);
                  throw new BuildException(msg);
                }
              } catch (final IllegalArgumentException iae) {
                final String msg =
                    "Invalid version '"
                        + epVersionS
                        + "' in <exportpackage name=\""
                        + packageName
                        + "\" ...>: "
                        + iae.getMessage();
                log(msg, Project.MSG_ERR);
                throw new BuildException(msg, iae);
              }
            }
          }
        }
      }

      final SortedSet<String> privatePackages = bpInfo.getProvidedPackages();
      privatePackages.removeAll(publicPackages);

      final SortedSet<String> referencedPackages = bpInfo.getReferencedPackages();
      referencedPackages.removeAll(privatePackages);
      for (final Object element : referencedPackages) {
        final String packageName = (String) element;
        if (!isStandardPackage(packageName) && !importPackage.containsKey(packageName)) {
          if (packageAnalysis == PACKAGE_ANALYSIS_AUTO) {
            final String version = exportPackage.get(packageName);
            try {
              importPackage.put(packageName, toImportRange(version));
            } catch (final IllegalArgumentException iae) {
              final String msg =
                  "Invalid version value, '"
                      + version
                      + "' for exported package \""
                      + packageName
                      + "\" can not derive version range for auto-import. "
                      + iae.getMessage();
              log(msg, Project.MSG_ERR);
              throw new BuildException(msg, iae);
            }
          } else if (packageAnalysis == PACKAGE_ANALYSIS_WARN) {
            log(
                "Referenced package not found in bundle or imports: " + packageName,
                Project.MSG_WARN);
          }
        }
      }
    }
  }