private void generateInstallSection(StringBuilder buffer) {
    buffer.append("%install\n");
    buffer.append("# jars\n");
    buffer.append("install -d -m 0755 %{buildroot}%{_javadir}\n");
    buffer.append(
        "install -m 644 target/%{name}-%{version}.jar   %{buildroot}%{_javadir}/%{name}\n\n");

    buffer.append(
        "%add_to_maven_depmap "
            + model.getGroupId()
            + " "
            + model.getArtifactId()
            + " %{version} JPP "
            + model.getArtifactId()
            + "\n\n");

    buffer.append("# poms\n");
    buffer.append("install -d -m 755 %{buildroot}%{_mavenpomdir}\n");
    buffer.append("install -pm 644 pom.xml \\\n");
    buffer.append("    %{buildroot}%{_mavenpomdir}/JPP.%{name}.pom\n\n");

    buffer.append("# javadoc\n");
    buffer.append("install -d -m 0755 %{buildroot}%{_javadocdir}/%{name}\n");
    buffer.append("cp -pr target/site/api*/* %{buildroot}%{_javadocdir}/%{name}/\n");
    buffer.append("rm -rf target/site/api*\n\n");
  }
 private void generateRequires(StringBuilder buffer) {
   for (String dependency : model.getDependencies()) {
     buffer.append("BuildRequires: " + dependency + "\n");
   }
   for (String dependency : model.getDependencies()) {
     buffer.append("Requires: " + dependency + "\n");
   }
 }
 /**
  * Writes the given contents to a file with the given fileName in the specified project.
  *
  * @param projectName The name of the project to put the file into.
  * @throws CoreException Thrown when the project doesn't exist.
  */
 public void writeContent(String projectName) throws CoreException {
   String fileName = model.getPackageName().toLowerCase() + ".spec";
   String contents = generateSpecfile();
   InputStream contentInputStream = new ByteArrayInputStream(contents.getBytes());
   IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
   IResource resource = root.findMember(new Path(projectName));
   if (!resource.exists() || !(resource instanceof IContainer)) {
     throwCoreException("Project \"" + projectName + "\" does not exist.");
   }
   IContainer container = (IContainer) resource;
   final IFile file = container.getFile(new Path(fileName));
   try {
     InputStream stream = contentInputStream;
     if (file.exists()) {
       file.setContents(stream, true, true, null);
     } else {
       file.create(stream, true, null);
     }
     stream.close();
   } catch (IOException e) {
     StubbyLog.logError(e);
   }
   StubbyPlugin.getActiveWorkbenchShell()
       .getDisplay()
       .asyncExec(
           new Runnable() {
             public void run() {
               IWorkbenchPage page =
                   PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
               try {
                 IDE.openEditor(page, file, true);
               } catch (PartInitException e) {
                 StubbyLog.logError(e);
               }
             }
           });
 }
  /**
   * Generates a RPM specfile based on the parsed data from the pom file.
   *
   * @return The generated specfile.
   */
  public String generateSpecfile() {
    StringBuilder buffer = new StringBuilder();
    String packageName = model.getPackageName();
    buffer.append("Name:           " + packageName.toLowerCase() + "\n");
    buffer.append("Version:        " + model.getVersion() + "\n");
    buffer.append("Release:        1%{?dist}" + "\n");
    buffer.append("Summary:        " + model.getSummary() + "\n\n");
    buffer.append("Group:          Development/Libraries\n");
    buffer.append("License:        " + model.getLicense() + "\n");
    buffer.append("URL:            " + model.getURL() + "\n");
    buffer.append("Source0:        #FIXME\n");
    buffer.append("BuildArch: noarch\n\n");
    generateRequires(buffer);
    buffer.append("\n%description\n" + model.getDescription() + "\n\n");
    generateJavadocSubpackage(buffer);
    generatePrepSection(buffer);
    generateBuildSection(buffer);
    generateInstallSection(buffer);
    generatePostPostun(buffer);
    generateFilesSections(buffer);
    generateChangelog(buffer);

    return buffer.toString();
  }