ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Patch.java
Date Fri, 26 Apr 2002 11:39:34 GMT
bodewig     02/04/26 04:39:34

  Modified:    .        WHATSNEW
               docs/manual/CoreTasks patch.html
               src/main/org/apache/tools/ant/taskdefs Patch.java
  Log:
  New dir attribute for <patch>
  
  Submitted by:	Thanou Thirakul <thanou@intelliware.ca>
  
  Revision  Changes    Path
  1.259     +3 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.258
  retrieving revision 1.259
  diff -u -r1.258 -r1.259
  --- WHATSNEW	24 Apr 2002 03:09:06 -0000	1.258
  +++ WHATSNEW	26 Apr 2002 11:39:33 -0000	1.259
  @@ -342,6 +342,9 @@
   
     For more details see docs/manual/inputhandler.html.
   
  +* <patch> has a new attribute that selects the directory in which to
  +  run the command.
  +
   Changes from Ant 1.4 to Ant 1.4.1
   ===========================================
   
  
  
  
  1.6       +6 -1      jakarta-ant/docs/manual/CoreTasks/patch.html
  
  Index: patch.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/patch.html,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- patch.html	3 Feb 2002 22:00:42 -0000	1.5
  +++ patch.html	26 Apr 2002 11:39:34 -0000	1.6
  @@ -55,6 +55,11 @@
         slashes from filenames.</td>
       <td align="center" valign="top">No</td>
     </tr>
  +  <tr>
  +    <td valign="top">dir</td> 
  +    <td valign="top">The directory in which to run the patch command.</td>
  +    <td align="center" valign="top">No, default is the project's basedir.</td>
  +  </tr>
   </table>
   <h3>Examples</h3>
   <pre>  &lt;patch patchfile=&quot;module.1.0-1.1.patch&quot;/&gt;</pre>
  @@ -69,7 +74,7 @@
   </pre> 
   the leading <i>a/</i> will be stripped.
   <hr>
  -<p align="center">Copyright &copy; 2001 Apache Software Foundation. All rights
  +<p align="center">Copyright &copy; 2001-2002 Apache Software Foundation. All
rights
   Reserved.</p>
   
   </body>
  
  
  
  1.15      +26 -2     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Patch.java
  
  Index: Patch.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Patch.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Patch.java	15 Apr 2002 12:11:47 -0000	1.14
  +++ Patch.java	26 Apr 2002 11:39:34 -0000	1.15
  @@ -73,6 +73,7 @@
   public class Patch extends Task {
   
       private File originalFile;
  +    private File directory;
       private boolean havePatchfile = false;
       private Commandline cmd = new Commandline();
   
  @@ -145,12 +146,21 @@
           }
       }
   
  +    /**
  +     * The directory to run the patch command in, defaults to the
  +     * project's base directory.
  +     *
  +     * @since Ant 1.5
  +     */
  +    public void setDir(File directory) throws BuildException {
  +        this.directory = directory;
  +    }
  +
       public void execute() throws BuildException {
           if (!havePatchfile) {
               throw new BuildException("patchfile argument is required", 
                                        location);
           } 
  -        
           Commandline toExecute = (Commandline) cmd.clone();
           toExecute.setExecutable("patch");
   
  @@ -161,7 +171,21 @@
           Execute exe = new Execute(new LogStreamHandler(this, Project.MSG_INFO,
                                                          Project.MSG_WARN), 
                                     null);
  -        exe.setCommandline(toExecute.getCommandline());
  +
  +        if (directory != null) {
  +            if (directory.exists() && directory.isDirectory()) {
  +                exe.setWorkingDirectory(directory);
  +            } else if (!directory.isDirectory()) {
  +                throw new BuildException(directory + " is not a directory.",
  +                                         location);
  +            } else {
  +                throw new BuildException("directory " + directory
  +                                         + " doesn\'t exist", location);
  +            }
  +        } else {
  +            exe.setWorkingDirectory(getProject().getBaseDir());
  +        }
  +
           try {
               exe.execute();
           } catch (IOException e) {
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message