peterreilly    2003/11/06 07:01:22

  Modified:    src/main/org/apache/tools/ant Tag: ANT_16_BRANCH
                        ProjectHelper.java
               src/main/org/apache/tools/ant/taskdefs Tag: ANT_16_BRANCH
                        Ant.java Definer.java ImportTask.java
                        MacroInstance.java
  Log:
  Sync with HEAD
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.101.2.2 +27 -1     ant/src/main/org/apache/tools/ant/ProjectHelper.java
  
  Index: ProjectHelper.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/ProjectHelper.java,v
  retrieving revision 1.101.2.1
  retrieving revision 1.101.2.2
  diff -u -r1.101.2.1 -r1.101.2.2
  --- ProjectHelper.java        29 Oct 2003 10:21:13 -0000      1.101.2.1
  +++ ProjectHelper.java        6 Nov 2003 15:01:21 -0000       1.101.2.2
  @@ -531,5 +531,31 @@
           }
           return componentName.substring(0, index);
       }
  -//end class
  +
  +    /**
  +     * Add location to build exception.
  +     * @param ex the build exception, if the build exception
  +     *           does not include
  +     * @param newLocation the location of the calling task (may be null)
  +     * @return a new build exception based in the build exception with
  +     *         location set to newLocation. If the original exception
  +     *         did not have a location, just return the build exception
  +     */
  +    public static BuildException addLocationToBuildException(
  +        BuildException ex, Location newLocation) {
  +        if (ex.getLocation() == null || ex.getMessage() == null) {
  +            return ex;
  +        }
  +        String errorMessage
  +            = "Following error occured while executing this line"
  +            + System.getProperty("line.separator")
  +            + ex.getLocation().toString()
  +            + ex.getMessage();
  +        if (newLocation == null) {
  +            return new BuildException(errorMessage);
  +        } else {
  +            return new BuildException(
  +                errorMessage, newLocation);
  +        }
  +    }
   }
  
  
  
  No                   revision
  No                   revision
  1.92.2.2  +10 -2     ant/src/main/org/apache/tools/ant/taskdefs/Ant.java
  
  Index: Ant.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Ant.java,v
  retrieving revision 1.92.2.1
  retrieving revision 1.92.2.2
  diff -u -r1.92.2.1 -r1.92.2.2
  --- Ant.java  10 Oct 2003 13:21:22 -0000      1.92.2.1
  +++ Ant.java  6 Nov 2003 15:01:21 -0000       1.92.2.2
  @@ -378,7 +378,12 @@
                   }
               }
   
  -            ProjectHelper.configureProject(newProject, new File(antFile));
  +            try {
  +                ProjectHelper.configureProject(newProject, new 
File(antFile));
  +            } catch (BuildException ex) {
  +                throw ProjectHelper.addLocationToBuildException(
  +                    ex, getLocation());
  +            }
   
               if (target == null) {
                   target = newProject.getDefaultTarget();
  @@ -413,7 +418,10 @@
                   try {
                       log("Entering " + antFile + "...", Project.MSG_VERBOSE);
                       newProject.executeTarget(target);
  -                } finally {
  +                } catch (BuildException ex) {
  +                    throw ProjectHelper.addLocationToBuildException(
  +                        ex, getLocation());
  +              } finally {
                       log("Exiting " + antFile + ".", Project.MSG_VERBOSE);
                   }
               }
  
  
  
  1.44.2.2  +2 -9      ant/src/main/org/apache/tools/ant/taskdefs/Definer.java
  
  Index: Definer.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Definer.java,v
  retrieving revision 1.44.2.1
  retrieving revision 1.44.2.2
  diff -u -r1.44.2.1 -r1.44.2.2
  --- Definer.java      30 Oct 2003 16:21:32 -0000      1.44.2.1
  +++ Definer.java      6 Nov 2003 15:01:21 -0000       1.44.2.2
  @@ -343,15 +343,8 @@
               antlib.setURI(getURI());
               antlib.perform();
           } catch (BuildException ex) {
  -            Location exLocation = ex.getLocation();
  -            if (exLocation == null) {
  -                throw ex;
  -            }
  -            throw new BuildException(
  -                "Error executing antlib"
  -                + System.getProperty("line.separator")
  -                + exLocation.toString()
  -                + " " + ex.getMessage());
  +            throw ProjectHelper.addLocationToBuildException(
  +                ex, getLocation());
           }
       }
   
  
  
  
  1.16.2.5  +3 -10     
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.2.4
  retrieving revision 1.16.2.5
  diff -u -r1.16.2.4 -r1.16.2.5
  --- ImportTask.java   3 Nov 2003 16:39:34 -0000       1.16.2.4
  +++ ImportTask.java   6 Nov 2003 15:01:21 -0000       1.16.2.5
  @@ -55,7 +55,7 @@
   package org.apache.tools.ant.taskdefs;
   
   import org.apache.tools.ant.BuildException;
  -import org.apache.tools.ant.Location;
  +import org.apache.tools.ant.ProjectHelper;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.ProjectHelper;
   import org.apache.tools.ant.Task;
  @@ -183,15 +183,8 @@
           try {
               helper.parse(getProject(), importedFile);
           } catch (BuildException ex) {
  -            Location exLocation = ex.getLocation();
  -            if (exLocation == null) {
  -                throw ex;
  -            }
  -            throw new BuildException(
  -                "Error executing import file"
  -                + System.getProperty("line.separator")
  -                + exLocation.toString()
  -                + " " + ex.getMessage());
  +            throw ProjectHelper.addLocationToBuildException(
  +                ex, getLocation());
           }
       }
   
  
  
  
  1.5.2.3   +8 -2      
ant/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java
  
  Index: MacroInstance.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java,v
  retrieving revision 1.5.2.2
  retrieving revision 1.5.2.3
  diff -u -r1.5.2.2 -r1.5.2.3
  --- MacroInstance.java        8 Oct 2003 08:46:48 -0000       1.5.2.2
  +++ MacroInstance.java        6 Nov 2003 15:01:21 -0000       1.5.2.3
  @@ -66,10 +66,11 @@
   
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.DynamicConfigurator;
  +import org.apache.tools.ant.ProjectHelper;
  +import org.apache.tools.ant.RuntimeConfigurable;
   import org.apache.tools.ant.Task;
   import org.apache.tools.ant.TaskContainer;
   import org.apache.tools.ant.UnknownElement;
  -import org.apache.tools.ant.RuntimeConfigurable;
   
   /**
    * The class to be placed in the ant type definition.
  @@ -264,6 +265,11 @@
           // need to set the project on unknown element
           UnknownElement c = copy(macroDef.getNestedTask());
           c.init();
  -        c.perform();
  +        try {
  +            c.perform();
  +        } catch (BuildException ex) {
  +            throw ProjectHelper.addLocationToBuildException(
  +                ex, getLocation());
  +        }
       }
   }
  
  
  

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

Reply via email to