peterreilly    2003/10/16 10:04:01

  Modified:    src/main/org/apache/tools/ant/taskdefs ImportTask.java
               docs/manual/CoreTasks import.html
  Log:
  add an optional attribute to import
  note this is differnet from a failonerror attribute in
  that it only checks for the existance of the
  imported file, other errors in the imported
  file would cause the build to fail
  
  Revision  Changes    Path
  1.17      +20 -5     
ant/src/main/org/apache/tools/ant/taskdefs/ImportTask.java
  
  Index: ImportTask.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/ImportTask.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ImportTask.java   19 Sep 2003 09:36:22 -0000      1.16
  +++ ImportTask.java   16 Oct 2003 17:04:01 -0000      1.17
  @@ -64,8 +64,6 @@
   import java.util.Vector;
   
   /**
  - * <i>EXPERIMENTAL:</i> This task is experimental and may be under continual
  - * change till Ant1.6 ships; it may even be omitted from the product.
    * <p>
    * Task to import another build file into the current project.
    * <p>
  @@ -96,8 +94,19 @@
    */
   public class ImportTask extends Task {
       private String file;
  +    private boolean optional;
   
       /**
  +     * sets the optional attribute
  +     *
  +     * @param optional if true ignore files that are not present,
  +     *                 default is false
  +     */
  +    public void setOptional(boolean optional) {
  +        this.optional = true;
  +    }
  +    
  +    /**
        * the name of the file to import. How relative paths are resolved is 
still
        * in flux: use absolute paths for safety.
        * @param file the name of the file
  @@ -151,9 +160,15 @@
           }
   
           if (!importedFile.exists()) {
  -                throw new BuildException(
  -                    "Cannot find " + file + " imported from "
  -                    + buildFile.getAbsolutePath());
  +            String message =
  +                "Cannot find " + file + " imported from "
  +                + buildFile.getAbsolutePath();
  +            if (optional) {
  +                getProject().log(message, Project.MSG_VERBOSE);
  +                return;
  +            } else {
  +                throw new BuildException(message);
  +            }
           }
   
           importedFile = new File(getPath(importedFile));
  
  
  
  1.7       +9 -0      ant/docs/manual/CoreTasks/import.html
  
  Index: import.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/CoreTasks/import.html,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- import.html       19 Sep 2003 09:43:43 -0000      1.6
  +++ import.html       16 Oct 2003 17:04:01 -0000      1.7
  @@ -83,6 +83,15 @@
         </td>
         <td valign="top" align="center">Yes</td>
       </tr>
  +    <tr>
  +      <td valign="top">optional<br>
  +      </td>
  +      <td valign="top">
  +        if true, do not issue stop the build if the file does not exist,
  +        default is false.<br>
  +      </td>
  +      <td valign="top" align="center">No</td>
  +    </tr>
     </tbody>
   </table>
   <h3><br>
  
  
  

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

Reply via email to