public ManifestContents create(
      String manifestTemplatePath,
      String manifestTemplate,
      String bundleSymbolicName,
      String defaultBundleSymbolicName,
      String bundleVersion,
      String defaultBundleVersion) {
    ManifestContents template;
    if (StringUtils.hasText(manifestTemplate)) {
      template = BundleManifestUtils.getManifest(new StringReader(manifestTemplate));
    } else if (StringUtils.hasText(manifestTemplatePath)) {
      template = BundleManifestUtils.getManifest(new File(manifestTemplatePath));
    } else {
      template = new SimpleManifestContents();
    }

    Map<String, String> attributes = template.getMainAttributes();
    if (StringUtils.hasText(bundleSymbolicName)) {
      attributes.put(BUNDLE_SYMBOLIC_NAME, bundleSymbolicName);
    } else if (!StringUtils.hasText(attributes.get(BUNDLE_SYMBOLIC_NAME))) {
      attributes.put(BUNDLE_SYMBOLIC_NAME, defaultBundleSymbolicName);
    }

    if (StringUtils.hasText(bundleVersion)) {
      attributes.put(BUNDLE_VERSION, bundleVersion);
    } else if (!StringUtils.hasText(attributes.get(BUNDLE_VERSION))) {
      attributes.put(BUNDLE_VERSION, defaultBundleVersion);
    }

    return template;
  }
Beispiel #2
0
  public final void execute() throws MojoExecutionException {
    if (!this.enabled) {
      getLog().info("Ignored project with enabled = false");
      return;
    }

    if (IGNORED_PACKAGINGS.contains(this.packaging)) {
      getLog().info(String.format("Ignored project with type = '%s'", this.packaging));
      return;
    }

    this.configuration.addProperties(createCommonProperties());

    List<String> warnings = getBundlorExecutor().execute();

    if (warnings.size() > 0) {
      getLog().warn("Bundlor Warnings:");
      for (String warning : warnings) {
        getLog().warn("    " + warning);
      }

      if (this.failOnWarnings) {
        String message;
        if (StringUtils.hasText(this.configuration.getManifestTemplatePath())) {
          message =
              String.format(
                  "Bundlor returned warnings.  Please fix manifest template at '%s' and try again.",
                  this.configuration.getManifestTemplatePath());
        } else {
          message =
              "Bundlor returned warnings.  Please fix inline manifest template and try again.";
        }

        throw new MojoExecutionException(message);
      }
    }
  }