git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270172 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -15,14 +15,10 @@ public abstract class Task | |||||
| { | { | ||||
| protected Target target; | protected Target target; | ||||
| protected String description; | protected String description; | ||||
| protected Location location = Location.UNKNOWN_LOCATION; | |||||
| protected String taskName; | protected String taskName; | ||||
| protected String taskType; | protected String taskType; | ||||
| private boolean invalid; | |||||
| protected RuntimeConfigurable wrapper; | protected RuntimeConfigurable wrapper; | ||||
| private UnknownElement replacement; | |||||
| /** | /** | ||||
| * Sets a description of the current action. It will be usefull in | * Sets a description of the current action. It will be usefull in | ||||
| * commenting what we are doing. | * commenting what we are doing. | ||||
| @@ -34,16 +30,6 @@ public abstract class Task | |||||
| description = desc; | description = desc; | ||||
| } | } | ||||
| /** | |||||
| * Sets the file location where this task was defined. | |||||
| * | |||||
| * @param location The new Location value | |||||
| */ | |||||
| public void setLocation( Location location ) | |||||
| { | |||||
| this.location = location; | |||||
| } | |||||
| /** | /** | ||||
| * Sets the target object of this task. | * Sets the target object of this task. | ||||
| * | * | ||||
| @@ -69,16 +55,6 @@ public abstract class Task | |||||
| return description; | return description; | ||||
| } | } | ||||
| /** | |||||
| * Returns the file location where this task was defined. | |||||
| * | |||||
| * @return The Location value | |||||
| */ | |||||
| public Location getLocation() | |||||
| { | |||||
| return location; | |||||
| } | |||||
| /** | /** | ||||
| * Get the Target to which this task belongs | * Get the Target to which this task belongs | ||||
| * | * | ||||
| @@ -119,39 +95,22 @@ public abstract class Task | |||||
| public final void perform() | public final void perform() | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| if( !invalid ) | |||||
| try | |||||
| { | |||||
| project.fireTaskStarted( this ); | |||||
| maybeConfigure(); | |||||
| execute(); | |||||
| project.fireTaskFinished( this, null ); | |||||
| } | |||||
| catch( TaskException te ) | |||||
| { | { | ||||
| try | |||||
| { | |||||
| project.fireTaskStarted( this ); | |||||
| maybeConfigure(); | |||||
| execute(); | |||||
| project.fireTaskFinished( this, null ); | |||||
| } | |||||
| catch( TaskException te ) | |||||
| { | |||||
| if( te instanceof BuildException ) | |||||
| { | |||||
| BuildException be = (BuildException)te; | |||||
| if( be.getLocation() == Location.UNKNOWN_LOCATION ) | |||||
| { | |||||
| be.setLocation( getLocation() ); | |||||
| } | |||||
| } | |||||
| project.fireTaskFinished( this, te ); | |||||
| throw te; | |||||
| } | |||||
| catch( RuntimeException re ) | |||||
| { | |||||
| project.fireTaskFinished( this, re ); | |||||
| throw re; | |||||
| } | |||||
| project.fireTaskFinished( this, te ); | |||||
| throw te; | |||||
| } | } | ||||
| else | |||||
| catch( RuntimeException re ) | |||||
| { | { | ||||
| UnknownElement ue = getReplacement(); | |||||
| Task task = ue.getTask(); | |||||
| task.perform(); | |||||
| project.fireTaskFinished( this, re ); | |||||
| throw re; | |||||
| } | } | ||||
| } | } | ||||
| @@ -208,16 +167,9 @@ public abstract class Task | |||||
| public void maybeConfigure() | public void maybeConfigure() | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| if( !invalid ) | |||||
| if( wrapper != null ) | |||||
| { | { | ||||
| if( wrapper != null ) | |||||
| { | |||||
| wrapper.maybeConfigure( project ); | |||||
| } | |||||
| } | |||||
| else | |||||
| { | |||||
| getReplacement(); | |||||
| wrapper.maybeConfigure( project ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -245,37 +197,5 @@ public abstract class Task | |||||
| { | { | ||||
| this.taskType = type; | this.taskType = type; | ||||
| } | } | ||||
| /** | |||||
| * Mark this task as invalid. | |||||
| */ | |||||
| final void markInvalid() | |||||
| { | |||||
| invalid = true; | |||||
| } | |||||
| /** | |||||
| * Create an UnknownElement that can be used to replace this task. | |||||
| * | |||||
| * @return The Replacement value | |||||
| */ | |||||
| private UnknownElement getReplacement() | |||||
| throws TaskException | |||||
| { | |||||
| if( replacement == null ) | |||||
| { | |||||
| replacement = new UnknownElement( taskType ); | |||||
| replacement.setProject( project ); | |||||
| replacement.setTaskType( taskType ); | |||||
| replacement.setTaskName( taskName ); | |||||
| replacement.setLocation( location ); | |||||
| replacement.setOwningTarget( target ); | |||||
| replacement.setRuntimeConfigurableWrapper( wrapper ); | |||||
| wrapper.setProxy( replacement ); | |||||
| target.replaceChild( this, replacement ); | |||||
| replacement.maybeConfigure(); | |||||
| } | |||||
| return replacement; | |||||
| } | |||||
| } | } | ||||
| @@ -15,14 +15,10 @@ public abstract class Task | |||||
| { | { | ||||
| protected Target target; | protected Target target; | ||||
| protected String description; | protected String description; | ||||
| protected Location location = Location.UNKNOWN_LOCATION; | |||||
| protected String taskName; | protected String taskName; | ||||
| protected String taskType; | protected String taskType; | ||||
| private boolean invalid; | |||||
| protected RuntimeConfigurable wrapper; | protected RuntimeConfigurable wrapper; | ||||
| private UnknownElement replacement; | |||||
| /** | /** | ||||
| * Sets a description of the current action. It will be usefull in | * Sets a description of the current action. It will be usefull in | ||||
| * commenting what we are doing. | * commenting what we are doing. | ||||
| @@ -34,16 +30,6 @@ public abstract class Task | |||||
| description = desc; | description = desc; | ||||
| } | } | ||||
| /** | |||||
| * Sets the file location where this task was defined. | |||||
| * | |||||
| * @param location The new Location value | |||||
| */ | |||||
| public void setLocation( Location location ) | |||||
| { | |||||
| this.location = location; | |||||
| } | |||||
| /** | /** | ||||
| * Sets the target object of this task. | * Sets the target object of this task. | ||||
| * | * | ||||
| @@ -69,16 +55,6 @@ public abstract class Task | |||||
| return description; | return description; | ||||
| } | } | ||||
| /** | |||||
| * Returns the file location where this task was defined. | |||||
| * | |||||
| * @return The Location value | |||||
| */ | |||||
| public Location getLocation() | |||||
| { | |||||
| return location; | |||||
| } | |||||
| /** | /** | ||||
| * Get the Target to which this task belongs | * Get the Target to which this task belongs | ||||
| * | * | ||||
| @@ -119,39 +95,22 @@ public abstract class Task | |||||
| public final void perform() | public final void perform() | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| if( !invalid ) | |||||
| try | |||||
| { | |||||
| project.fireTaskStarted( this ); | |||||
| maybeConfigure(); | |||||
| execute(); | |||||
| project.fireTaskFinished( this, null ); | |||||
| } | |||||
| catch( TaskException te ) | |||||
| { | { | ||||
| try | |||||
| { | |||||
| project.fireTaskStarted( this ); | |||||
| maybeConfigure(); | |||||
| execute(); | |||||
| project.fireTaskFinished( this, null ); | |||||
| } | |||||
| catch( TaskException te ) | |||||
| { | |||||
| if( te instanceof BuildException ) | |||||
| { | |||||
| BuildException be = (BuildException)te; | |||||
| if( be.getLocation() == Location.UNKNOWN_LOCATION ) | |||||
| { | |||||
| be.setLocation( getLocation() ); | |||||
| } | |||||
| } | |||||
| project.fireTaskFinished( this, te ); | |||||
| throw te; | |||||
| } | |||||
| catch( RuntimeException re ) | |||||
| { | |||||
| project.fireTaskFinished( this, re ); | |||||
| throw re; | |||||
| } | |||||
| project.fireTaskFinished( this, te ); | |||||
| throw te; | |||||
| } | } | ||||
| else | |||||
| catch( RuntimeException re ) | |||||
| { | { | ||||
| UnknownElement ue = getReplacement(); | |||||
| Task task = ue.getTask(); | |||||
| task.perform(); | |||||
| project.fireTaskFinished( this, re ); | |||||
| throw re; | |||||
| } | } | ||||
| } | } | ||||
| @@ -208,16 +167,9 @@ public abstract class Task | |||||
| public void maybeConfigure() | public void maybeConfigure() | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| if( !invalid ) | |||||
| if( wrapper != null ) | |||||
| { | { | ||||
| if( wrapper != null ) | |||||
| { | |||||
| wrapper.maybeConfigure( project ); | |||||
| } | |||||
| } | |||||
| else | |||||
| { | |||||
| getReplacement(); | |||||
| wrapper.maybeConfigure( project ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -245,37 +197,5 @@ public abstract class Task | |||||
| { | { | ||||
| this.taskType = type; | this.taskType = type; | ||||
| } | } | ||||
| /** | |||||
| * Mark this task as invalid. | |||||
| */ | |||||
| final void markInvalid() | |||||
| { | |||||
| invalid = true; | |||||
| } | |||||
| /** | |||||
| * Create an UnknownElement that can be used to replace this task. | |||||
| * | |||||
| * @return The Replacement value | |||||
| */ | |||||
| private UnknownElement getReplacement() | |||||
| throws TaskException | |||||
| { | |||||
| if( replacement == null ) | |||||
| { | |||||
| replacement = new UnknownElement( taskType ); | |||||
| replacement.setProject( project ); | |||||
| replacement.setTaskType( taskType ); | |||||
| replacement.setTaskName( taskName ); | |||||
| replacement.setLocation( location ); | |||||
| replacement.setOwningTarget( target ); | |||||
| replacement.setRuntimeConfigurableWrapper( wrapper ); | |||||
| wrapper.setProxy( replacement ); | |||||
| target.replaceChild( this, replacement ); | |||||
| replacement.maybeConfigure(); | |||||
| } | |||||
| return replacement; | |||||
| } | |||||
| } | } | ||||