public GemSpecification createSpecification(final MavenArtifact artifact) {
    final GemSpecification result = new GemSpecification();

    // this is fix
    result.setPlatform(this.PLATFORM_JAVA);

    // the must ones
    result.setName(
        createGemName(
            artifact.getCoordinates().getGroupId(),
            artifact.getCoordinates().getArtifactId(),
            artifact.getCoordinates().getVersion()));
    result.setVersion(new GemVersion(createGemVersion(artifact.getCoordinates().getVersion())));

    // dependencies
    if (artifact.getPom().getDependencies().size() > 0) {
      for (final Dependency dependency : artifact.getPom().getDependencies()) {
        if (!dependency.isOptional()) {
          result.getDependencies().add(convertDependency(artifact, dependency));
        }
      }
    }

    // and other stuff "nice to have"
    result.setDate(new Date()); // now
    result.setDescription(
        sanitizeStringValue(
            artifact.getPom().getDescription() != null
                ? artifact.getPom().getDescription()
                : artifact.getPom().getName()));
    result.setSummary(sanitizeStringValue(artifact.getPom().getName()));
    result.setHomepage(sanitizeStringValue(artifact.getPom().getUrl()));

    if (artifact.getPom().getLicenses().size() > 0) {
      for (final License license : artifact.getPom().getLicenses()) {
        result
            .getLicenses()
            .add(sanitizeStringValue(license.getName() + " (" + license.getUrl() + ")"));
      }
    }
    if (artifact.getPom().getDevelopers().size() > 0) {
      for (final Developer developer : artifact.getPom().getDevelopers()) {
        result
            .getAuthors()
            .add(sanitizeStringValue(developer.getName() + " (" + developer.getEmail() + ")"));
      }
    }

    // by default, we pack into lib/ inside gem (where is the jar and the
    // stub ruby)
    result.getRequire_paths().add("lib");
    return result;
  }
  /**
   * Adds information about references licenses.
   *
   * @param pomDescriptor The descriptor for the current POM.
   * @param model The Maven Model.
   * @param store The database.
   */
  private void addLicenses(MavenPomDescriptor pomDescriptor, Model model, Store store) {
    List<License> licenses = model.getLicenses();
    for (License license : licenses) {
      MavenLicenseDescriptor licenseDescriptor = store.create(MavenLicenseDescriptor.class);
      licenseDescriptor.setUrl(license.getUrl());
      licenseDescriptor.setComments(license.getComments());
      licenseDescriptor.setName(license.getName());
      licenseDescriptor.setDistribution(license.getDistribution());

      pomDescriptor.getLicenses().add(licenseDescriptor);
    }
  }
Пример #3
0
  private String createDefaultLicenseText() {
    String toRet = "License terms:\n";

    List licenses = project.getLicenses();
    if (licenses != null && licenses.size() > 0) {
      Iterator lic = licenses.iterator();
      while (lic.hasNext()) {
        License ll = (License) lic.next();

        if (ll.getName() != null) {
          toRet = toRet + ll.getName() + " - ";
        }
        if (ll.getUrl() != null) {
          toRet = toRet + ll.getUrl();
        }
        if (lic.hasNext()) {
          toRet = toRet + ",\n";
        }
      }
    } else {
      toRet = toRet + "Unknown";
    }
    return toRet;
  }