bodewig     2002/09/26 01:13:58

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional Cab.java
  Log:
  Make <cab> use the not deprecated methods of ExecTask.
  
  PR: 12468
  Submitted by: Jesse Stockall <jesse at cryptocard.com>
  
  Revision  Changes    Path
  1.22      +25 -33    
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java
  
  Index: Cab.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- Cab.java  25 Jul 2002 15:21:11 -0000      1.21
  +++ Cab.java  26 Sep 2002 08:13:58 -0000      1.22
  @@ -79,6 +79,7 @@
    * Create a CAB archive.
    *
    * @author Roger Vaughn <a href="mailto:[EMAIL PROTECTED]">[EMAIL 
PROTECTED]</a>
  + * @author Jesse Stockall
    */
   
   public class Cab extends MatchingTask {
  @@ -143,13 +144,13 @@
        */
       protected void checkConfiguration() throws BuildException {
           if (baseDir == null) {
  -            throw new BuildException("basedir attribute must be set!");
  +            throw new BuildException("basedir attribute must be set!", 
getLocation());
           }
           if (!baseDir.exists()) {
  -            throw new BuildException("basedir does not exist!");
  +            throw new BuildException("basedir does not exist!", 
getLocation());
           }
           if (cabFile == null) {
  -            throw new BuildException("cabfile attribute must be set!");
  +            throw new BuildException("cabfile attribute must be set!" , 
getLocation());
           }
       }
   
  @@ -183,31 +184,6 @@
       }
   
       /**
  -     * Create the cabarc command line to use.
  -     */
  -    protected Commandline createCommand(File listFile) {
  -        Commandline command = new Commandline();
  -        command.setExecutable("cabarc");
  -        command.createArgument().setValue("-r");
  -        command.createArgument().setValue("-p");
  -
  -        if (!doCompress) {
  -            command.createArgument().setValue("-m");
  -            command.createArgument().setValue("none");
  -        }
  -
  -        if (cmdOptions != null) {
  -            command.createArgument().setLine(cmdOptions);
  -        }
  -
  -        command.createArgument().setValue("n");
  -        command.createArgument().setFile(cabFile);
  -        command.createArgument().setValue("@" + listFile.getAbsolutePath());
  -
  -        return command;
  -    }
  -
  -    /**
        * Creates a list file.  This temporary file contains a list of all files
        * to be included in the cab, one file per line.
        */
  @@ -286,7 +262,7 @@
               sb.append("\n").append(cabFile.getAbsolutePath()).append("\n");
   
               try {
  -                Process p = Execute.launch(getProject(), 
  +                Process p = Execute.launch(getProject(),
                                              new String[] {"listcab"}, null,
                                              baseDir, true);
                   OutputStream out = p.getOutputStream();
  @@ -301,7 +277,7 @@
                   LogOutputStream errLog = new LogOutputStream(this, 
Project.MSG_ERR);
                   StreamPumper    outPump = new 
StreamPumper(p.getInputStream(), outLog);
                   StreamPumper    errPump = new 
StreamPumper(p.getErrorStream(), errLog);
  -                
  +
                   // Pump streams asynchronously
                   (new Thread(outPump)).start();
                   (new Thread(errPump)).start();
  @@ -327,7 +303,7 @@
                   }
               } catch (IOException ex) {
                   String msg = "Problem creating " + cabFile + " " + 
ex.getMessage();
  -                throw new BuildException(msg);
  +                throw new BuildException(msg, getLocation());
               }
           } else {
               try {
  @@ -344,7 +320,23 @@
                       exec.setOutput(outFile);
                   }
   
  -                exec.setCommand(createCommand(listFile));
  +                exec.setExecutable("cabarc");
  +                exec.createArg().setValue("-r");
  +                exec.createArg().setValue("-p");
  +
  +                if (!doCompress) {
  +                    exec.createArg().setValue("-m");
  +                    exec.createArg().setValue("none");
  +                }
  +
  +                if (cmdOptions != null) {
  +                    exec.createArg().setLine(cmdOptions);
  +                }
  +
  +                exec.createArg().setValue("n");
  +                exec.createArg().setFile(cabFile);
  +                exec.createArg().setValue("@" + listFile.getAbsolutePath());
  +
                   exec.execute();
   
                   if (outFile != null) {
  @@ -354,7 +346,7 @@
                   listFile.delete();
               } catch (IOException ioe) {
                   String msg = "Problem creating " + cabFile + " " + 
ioe.getMessage();
  -                throw new BuildException(msg);
  +                throw new BuildException(msg, getLocation());
               }
           }
       }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to