ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional Rpm.java
Date Tue, 10 Apr 2001 04:29:08 GMT
donaldp     01/04/09 21:29:07

  Modified:    docs/manual optionaltasklist.html
               src/main/org/apache/tools/ant/taskdefs defaults.properties
  Added:       docs/manual/OptionalTasks rpm.html
               src/main/org/apache/tools/ant/taskdefs/optional Rpm.java
  Log:
  Added in basic RPM task
  
  Submitted By: Josh Lucas <josh@stonecottage.com>
  
  Revision  Changes    Path
  1.10      +1 -0      jakarta-ant/docs/manual/optionaltasklist.html
  
  Index: optionaltasklist.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/optionaltasklist.html,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- optionaltasklist.html	2001/03/25 19:19:39	1.9
  +++ optionaltasklist.html	2001/04/10 04:29:05	1.10
  @@ -32,6 +32,7 @@
   <a href="OptionalTasks/propertyfile.html">PropertyFile</a><br>
   <a href="OptionalTasks/pvcstask.html">Pvcs</a><br>
   <a href="OptionalTasks/renameextensions.html"><i>RenameExtensions</i></a><br>
  +<a href="OptionalTasks/rpm.html">Rpm</a><br>
   <a href="OptionalTasks/script.html">Script</a><br>
   <a href="OptionalTasks/sound.html">Sound</a><br>
   <a href="OptionalTasks/starteam.html">Starteam</a><br>
  
  
  
  1.1                  jakarta-ant/docs/manual/OptionalTasks/rpm.html
  
  Index: rpm.html
  ===================================================================
  <html>
  
  <head>
  <title>Rpm Task</title>
  </head>
  
  <body>
  
  <h2><a name="rpm">Rpm</a></h2>
  <h3>Description</h3>
  <p>
    A basic task for invoking the rpm executable.
  </p>
  
  <h3>Parameters</h3>
  <table border="1" cellpadding="2" cellspacing="0">
    <tr>
      <td valign="top"><b>Attribute</b></td>
      <td valign="top"><b>Description</b></td>
      <td align="center" valign="top"><b>Required</b></td>
    </tr>
    <tr>
      <td valign="top">specFile</td>
      <td valign="top">The name of the spec File to be used.</td>
      <td valign="top" align="center">Yes</td>
    </tr>
    <tr>
      <td valign="top">topDir</td>
      <td valign="top">
        this is the directory which will have the expected
        subdirectories, SPECS, SOURCES, BUILD, SRPMS.  If this isn't specified,
        the baseDir value is used
      </td>
      <td valign="top" align="center">No</td>
    </tr>
    <tr>
      <td valign="top">cleanBuildDir</td>
      <td valign="top">his will remove the generated files in the BUILD
  directory.</td>
      <td align="center" valign="top">No</td>
    </tr>
    <tr>
      <td valign="top">removeSpec</td>
      <td valign="top">this will remove the spec file from SPECS</td>
      <td align="center" valign="top">No</td>
    </tr>
    <tr>
      <td valign="top">command</td>
      <td valign="top">very similar idea to the cvs task.  the default is "-bb"</td>
      <td align="center" valign="top">No</td>
    </tr>
    <tr>
      <td valign="top">output/error</td>
      <td valign="top">where standard output and error go</td>
      <td align="center" valign="top">No</td>
    </tr>
  </table>
  <hr>
  
  <p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  Reserved.</p>
  
  </body>
  </html>
  
  
  
  
  1.69      +1 -0      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/defaults.properties
  
  Index: defaults.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/defaults.properties,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- defaults.properties	2001/04/07 03:51:31	1.68
  +++ defaults.properties	2001/04/10 04:29:06	1.69
  @@ -95,6 +95,7 @@
   vsslabel=org.apache.tools.ant.taskdefs.optional.vss.MSVSSLABEL
   vsshistory=org.apache.tools.ant.taskdefs.optional.vss.MSVSSHISTORY
   blgenclient=org.apache.tools.ant.taskdefs.optional.ejb.BorlandGenerateClient
  +rpm=org.apache.tools.ant.taskdefs.optional.Rpm
   
   # deprecated ant tasks (kept for back compatibility)
   javadoc2=org.apache.tools.ant.taskdefs.Javadoc
  
  
  
  1.1                  jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java
  
  Index: Rpm.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.tools.ant.taskdefs.optional;
  
  import java.io.*;
  import org.apache.tools.ant.*;
  import org.apache.tools.ant.taskdefs.*;
  import org.apache.tools.ant.types.Commandline;
  
  /**
   *
   *  @author lucas@collab.net
   */
  public class Rpm extends Task {
      
      /**
       * the spec file
       */
      private String specFile;
  
      /**
       * the rpm top dir
       */
      private File topDir;
  
      /**
       * the rpm command to use
       */
      private String command = "-bb";
  
      /**
       * clean BUILD directory
       */
      private boolean cleanBuildDir = false;
  
      /**
       * remove spec file
       */
      private boolean removeSpec = false;
  
      /**
       * remove sources
       */
      private boolean removeSource = false;
  
      /**
       * the file to direct standard output from the command
       */
      private File output;
  
      /**
       * the file to direct standard error from the command
       */
      private File error;
  
      public void execute() throws BuildException {
          
          Commandline toExecute = new Commandline();
  
          toExecute.setExecutable("rpm");
          if (topDir != null) {
              toExecute.createArgument().setValue("--define");
              toExecute.createArgument().setValue("_topdir" + topDir);
          }
  
          toExecute.createArgument().setLine(command);
  
          if (cleanBuildDir) {
              toExecute.createArgument().setValue("--clean");
          }
          if (removeSpec) {
              toExecute.createArgument().setValue("--rmspec");
          }
          if (removeSource) {
              toExecute.createArgument().setValue("--rmsource");
          }
  
          toExecute.createArgument().setValue("SPECS/" + specFile);
  
          ExecuteStreamHandler streamhandler = null;
          OutputStream outputstream = null;
          OutputStream errorstream = null;
          if (error == null && output == null) {
              streamhandler = new LogStreamHandler(this, Project.MSG_INFO,
                                                   Project.MSG_WARN);
          }
          else {
              if (output != null) {
                  try {
                      outputstream = new PrintStream(new BufferedOutputStream(new FileOutputStream(output)));
                  } catch (IOException e) {
                      throw new BuildException(e,location);
                  }
              }
              else {
                  outputstream = new LogOutputStream(this,Project.MSG_INFO);
              }
              if (error != null) {
                  try {
                      errorstream = new PrintStream(new BufferedOutputStream(new FileOutputStream(error)));
                  }  catch (IOException e) {
                      throw new BuildException(e,location);
                  }
              }
              else {
                  errorstream = new LogOutputStream(this, Project.MSG_WARN);
              }
              streamhandler = new PumpStreamHandler(outputstream, errorstream);
          }
  
          Execute exe = new Execute(streamhandler, null);
  
          exe.setAntRun(project);
          if (topDir == null) topDir = project.getBaseDir();
          exe.setWorkingDirectory(topDir);
  
          exe.setCommandline(toExecute.getCommandline());
          try {
              exe.execute();
              log("Building the RPM based on the " + specFile + " file");
          } catch (IOException e) {
              throw new BuildException(e, location);
          } finally {
              if (output != null) {
                  try {
                      outputstream.close();
                  } catch (IOException e) {}
              }
              if (error != null) {
                  try {
                      errorstream.close();
                  } catch (IOException e) {}
              }
          }
      }
  
      public void setTopDir(File td) {
          this.topDir = td;
      }
  
      public void setCommand(String c) {
          this.command = c;
      }
  
      public void setSpecFile(String sf) {
          if ( (sf == null) || (sf.trim().equals(""))) {
              throw new BuildException("You must specify a spec file",location);
          }
          this.specFile = sf;
      }
  
      public void setCleanBuildDir(boolean cbd) {
          cleanBuildDir = cbd;
      }
  
      public void setRemoveSpec(boolean rs) {
          removeSpec = rs;
      }
  
      public void setRemoveSource(boolean rs) {
          removeSource = rs;
      }
  
      public void setOutput(File output) {
          this.output = output;
      }
  
      public void setError(File error) {
          this.error = error;
      }
  }
  
  
  

Mime
View raw message