ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution ExecutionManager.java Frame.java
Date Mon, 08 Apr 2002 16:01:27 GMT
conor       02/04/08 09:01:25

  Modified:    proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution
                        ExecutionManager.java Frame.java
  Log:
  Correct mutant build error
  
  Revision  Changes    Path
  1.15      +5 -1      jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionManager.java
  
  Index: ExecutionManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionManager.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -w -u -r1.14 -r1.15
  --- ExecutionManager.java	7 Apr 2002 14:38:06 -0000	1.14
  +++ ExecutionManager.java	8 Apr 2002 16:01:24 -0000	1.15
  @@ -222,7 +222,11 @@
        * @param isErr true if this content is from the thread's error stream.
        */
       public void threadOutput(String line, boolean isErr) {
  +        if (mainFrame == null) {
           eventSupport.threadOutput(line, isErr);
  +        } else {
  +            mainFrame.threadOutput(line, isErr);
  +        }
       }
   }
   
  
  
  
  1.14      +213 -125  jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java
  
  Index: Frame.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -w -u -r1.13 -r1.14
  --- Frame.java	7 Apr 2002 14:38:06 -0000	1.13
  +++ Frame.java	8 Apr 2002 16:01:24 -0000	1.14
  @@ -87,7 +87,7 @@
    * @author Conor MacNeill
    * @created 14 January 2002
    */
  -public class Frame {
  +public class Frame implements DemuxOutputReceiver {
       /** the base dir of the project */
       private File baseDir;
   
  @@ -98,20 +98,20 @@
       private Map referencedFrames = new HashMap();
   
       /**
  -     * The context of this execution. This contains all data object's
  -     * created by tasks that have been executed
  +     * The context of this execution. This contains all data object's created
  +     * by tasks that have been executed
        */
       private Map dataValues = new HashMap();
   
       /**
  -     * Ant's initialization configuration with information on the location
  -     * of Ant and its libraries.
  +     * Ant's initialization configuration with information on the location of
  +     * Ant and its libraries.
        */
       private InitConfig initConfig;
   
       /**
  -     * These are the standard libraries from which taskdefs, typedefs, etc
  -     * may be imported.
  +     * These are the standard libraries from which taskdefs, typedefs, etc may
  +     * be imported.
        */
       private Map standardLibs;
   
  @@ -147,12 +147,14 @@
       /** The core's execution Service  */
       private CoreExecService execService;
   
  +
       /**
        * Create an Execution Frame for the given project
        *
  -     * @param standardLibs The libraries of tasks and types available to
  -     *      this frame
  -     * @param config the user config to use for this execution of Ant
  +     * @param standardLibs            The libraries of tasks and types
  +     *      available to this frame
  +     * @param config                  the user config to use for this
  +     *      execution of Ant
        * @param initConfig Ant's initialisation config
        * @exception ExecutionException if a component of the library cannot be
        *      imported
  @@ -164,18 +166,22 @@
           this.initConfig = initConfig;
       }
   
  +
       /**
        * Replace ${} style constructions in the given value with the string
        * value of the corresponding data values in the frame
        *
  -     * @param value the string to be scanned for property references.
  -     * @return the string with all property references replaced
  +     * @param value                   the string to be scanned for property
  +     *      references.
  +     * @return                        the string with all property references
  +     *      replaced
        * @exception ExecutionException if any of the properties do not exist
        */
       public String replacePropertyRefs(String value) throws ExecutionException {
           return dataService.replacePropertyRefs(value);
       }
   
  +
       /**
        * Sets the Project of the Frame
        *
  @@ -192,6 +198,7 @@
               Project referencedProject
                    = project.getReferencedProject(referenceName);
               Frame referencedFrame = createFrame(referencedProject);
  +
               referencedFrames.put(referenceName, referencedFrame);
           }
   
  @@ -200,6 +207,7 @@
           setMagicProperties();
       }
   
  +
       /**
        * get the name of the project associated with this frame.
        *
  @@ -212,6 +220,7 @@
           return null;
       }
       
  +
       /**
        * Set a value in this frame or any of its imported frames.
        *
  @@ -223,6 +232,7 @@
       protected void setDataValue(String name, Object value, boolean mutable)
            throws ExecutionException {
           Frame frame = getContainingFrame(name);
  +
           if (frame == null) {
               throw new ExecutionException("There is no project corresponding "
                    + "to the name \"" + name + "\"");
  @@ -239,11 +249,12 @@
           }
       }
   
  +
       /**
        * Set the initial properties to be used when the frame starts execution
        *
  -     * @param properties a Map of named properties which may in fact be any
  -     *      object
  +     * @param properties              a Map of named properties which may in
  +     *      fact be any object
        * @exception ExecutionException if the properties cannot be set
        */
       protected void setInitialProperties(Map properties)
  @@ -256,6 +267,7 @@
           addProperties(System.getProperties());
       }
   
  +
       /**
        * Set the values of various magic properties
        *
  @@ -264,8 +276,10 @@
       protected void setMagicProperties() throws ExecutionException {
           URL antHomeURL = initConfig.getAntHome();
           String antHomeString = null;
  +
           if (antHomeURL.getProtocol().equals("file")) {
               File antHome = new File(antHomeURL.getFile());
  +
               antHomeString = antHome.getAbsolutePath();
           } else {
               antHomeString = antHomeURL.toString();
  @@ -273,13 +287,14 @@
           setDataValue(MagicProperties.ANT_HOME, antHomeString, true);
       }
   
  +
       /**
        * Get a definition from a referenced frame
        *
  -     * @param definitionName the name of the definition relative to this
  -     *      frame
  -     * @return the appropriate import info object from the referenced
  -     *      frame's imports
  +     * @param definitionName          the name of the definition relative to
  +     *      this frame
  +     * @return                        the appropriate import info object from
  +     *      the referenced frame's imports
        * @exception ExecutionException if the referenced definition cannot be
        *      found
        */
  @@ -287,6 +302,7 @@
            throws ExecutionException {
           Frame containingFrame = getContainingFrame(definitionName);
           String localName = getNameInFrame(definitionName);
  +
           if (containingFrame == null) {
               throw new ExecutionException("There is no project corresponding "
                    + "to the name \"" + definitionName + "\"");
  @@ -298,6 +314,7 @@
           }
       }
   
  +
       /**
        * Gets the project model this frame is working with
        *
  @@ -319,14 +336,17 @@
       protected Map getAllProperties() {
           Map allProperties = new HashMap(dataValues);
           Iterator i = referencedFrames.keySet().iterator();
  +
           while (i.hasNext()) {
               String refName = (String) i.next();
               Frame refFrame = getReferencedFrame(refName);
               Map refProperties = refFrame.getAllProperties();
               Iterator j = refProperties.keySet().iterator();
  +
               while (j.hasNext()) {
                   String name = (String) j.next();
                   Object value = refProperties.get(name);
  +
                   allProperties.put(refName + Project.REF_DELIMITER + name,
                       value);
               }
  @@ -335,6 +355,7 @@
           return allProperties;
       }
   
  +
       /**
        * Get the Ant initialization configuration for this frame.
        *
  @@ -354,18 +375,21 @@
           return config;
       }
   
  +
       /**
        * Get the core's implementation of the given service interface.
        *
        * @param serviceInterfaceClass the service interface for which an
        *      implementation is require
  -     * @return the core's implementation of the service interface
  +     * @return                        the core's implementation of the service
  +     *      interface
        * @exception ExecutionException if the core does not provide an
        *      implementatin of the requested interface
        */
       protected Object getCoreService(Class serviceInterfaceClass)
            throws ExecutionException {
           Object service = services.get(serviceInterfaceClass);
  +
           if (service == null) {
               throw new ExecutionException("No service of interface class "
                    + serviceInterfaceClass);
  @@ -373,6 +397,7 @@
           return service;
       }
   
  +
       /**
        * Get the EventSupport instance for this frame. This tracks the build
        * listeners on this frame
  @@ -383,6 +408,7 @@
           return eventSupport;
       }
   
  +
       /**
        * Gets the baseDir of the Frame
        *
  @@ -392,17 +418,19 @@
           return baseDir;
       }
   
  +
       /**
        * Get a referenced frame by its reference name
        *
        * @param referenceName the name under which the frame was imported.
  -     * @return the Frame asscociated with the given reference name or null
  -     *      if there is no such project.
  +     * @return               the Frame asscociated with the given reference
  +     *      name or null if there is no such project.
        */
       protected Frame getReferencedFrame(String referenceName) {
           return (Frame) referencedFrames.get(referenceName);
       }
   
  +
       /**
        * Get the frames representing referenced projects.
        *
  @@ -412,6 +440,7 @@
           return referencedFrames.values().iterator();
       }
   
  +
       /**
        * Get the name of an object in its frame
        *
  @@ -420,22 +449,26 @@
        */
       protected String getNameInFrame(String fullname) {
           int index = fullname.lastIndexOf(Project.REF_DELIMITER);
  +
           if (index == -1) {
               return fullname;
           }
           return fullname.substring(index + Project.REF_DELIMITER.length());
       }
   
  +
       /**
        * Get a value from this frame or any imported frame
        *
  -     * @param name the name of the data value - may contain reference
  -     *      delimiters
  -     * @return the data value fetched from the appropriate frame
  +     * @param name                    the name of the data value - may contain
  +     *      reference delimiters
  +     * @return                        the data value fetched from the
  +     *      appropriate frame
        * @exception ExecutionException if the value is not defined
        */
       protected Object getDataValue(String name) throws ExecutionException {
           Frame frame = getContainingFrame(name);
  +
           if (frame == null) {
               throw new ExecutionException("There is no project corresponding "
                    + "to the name \"" + name + "\"");
  @@ -447,17 +480,19 @@
           }
       }
   
  +
       /**
        * Indicate if a data value has been set
        *
  -     * @param name the name of the data value - may contain reference
  -     *      delimiters
  +     * @param name                    the name of the data value - may contain
  +     *      reference delimiters
        * @return true if the value exists
        * @exception ExecutionException if the containing frame for the value
        *      does not exist
        */
       protected boolean isDataValueSet(String name) throws ExecutionException {
           Frame frame = getContainingFrame(name);
  +
           if (frame == null) {
               throw new ExecutionException("There is no project corresponding "
                    + "to the name \"" + name + "\"");
  @@ -475,11 +510,12 @@
        * where the name is relative to this frame
        *
        * @param elementName The name of the element
  -     * @return the execution frame for the project that contains the given
  -     *      target
  +     * @return             the execution frame for the project that contains
  +     *      the given target
        */
       protected Frame getContainingFrame(String elementName) {
           int index = elementName.lastIndexOf(Project.REF_DELIMITER);
  +
           if (index == -1) {
               return this;
           }
  @@ -488,8 +524,10 @@
           String relativeName = elementName.substring(0, index);
           StringTokenizer tokenizer
                = new StringTokenizer(relativeName, Project.REF_DELIMITER);
  +
           while (tokenizer.hasMoreTokens()) {
               String refName = tokenizer.nextToken();
  +
               currentFrame = currentFrame.getReferencedFrame(refName);
               if (currentFrame == null) {
                   return null;
  @@ -499,25 +537,29 @@
           return currentFrame;
       }
   
  +
       /**
        * Add a collection of properties to this frame
        *
  -     * @param properties the collection of property values, indexed by their
  -     *      names
  +     * @param properties              the collection of property values,
  +     *      indexed by their names
        * @exception ExecutionException if the frame cannot be created.
        */
       protected void addProperties(Map properties) throws ExecutionException {
           for (Iterator i = properties.keySet().iterator(); i.hasNext();) {
               String name = (String) i.next();
               Object value = properties.get(name);
  +
               setDataValue(name, value, false);
           }
       }
   
  +
       /**
        * Create a new frame for a given project
        *
  -     * @param project the project model the frame will deal with
  +     * @param project                 the project model the frame will deal
  +     *      with
        * @return an Frame ready to build the project
        * @exception ExecutionException if the frame cannot be created.
        */
  @@ -525,14 +567,17 @@
            throws ExecutionException {
           Frame newFrame
                = new Frame(standardLibs, initConfig, config);
  +
           newFrame.setProject(project);
           for (Iterator j = eventSupport.getListeners(); j.hasNext();) {
               BuildListener listener = (BuildListener) j.next();
  +
               newFrame.addBuildListener(listener);
           }
           return newFrame;
       }
   
  +
       /**
        * Log a message as a build event
        *
  @@ -543,6 +588,7 @@
           eventSupport.fireMessageLogged(project, message, level);
       }
   
  +
       /**
        * Add a build listener to this execution frame
        *
  @@ -551,11 +597,13 @@
       protected void addBuildListener(BuildListener listener) {
           for (Iterator i = getReferencedFrames(); i.hasNext();) {
               Frame referencedFrame = (Frame) i.next();
  +
               referencedFrame.addBuildListener(listener);
           }
           eventSupport.addBuildListener(listener);
       }
   
  +
       /**
        * Remove a build listener from the execution
        *
  @@ -564,15 +612,18 @@
       protected void removeBuildListener(BuildListener listener) {
           for (Iterator i = getReferencedFrames(); i.hasNext();) {
               Frame subFrame = (Frame) i.next();
  +
               subFrame.removeBuildListener(listener);
           }
           eventSupport.removeBuildListener(listener);
       }
   
  +
       /**
        * Run the given list of targets
        *
  -     * @param targets a list of target names which are to be evaluated
  +     * @param targets                 a list of target names which are to be
  +     *      evaluated
        * @exception ExecutionException if there is a problem in the build
        */
       protected void runBuild(List targets) throws ExecutionException {
  @@ -582,6 +633,7 @@
           if (targets.isEmpty()) {
               // we just execute the default target if any
               String defaultTarget = project.getDefaultTarget();
  +
               if (defaultTarget != null) {
                   log("Executing default target: " + defaultTarget,
                       MessageLevel.MSG_DEBUG);
  @@ -590,17 +642,19 @@
           } else {
               for (Iterator i = targets.iterator(); i.hasNext();) {
                   String targetName = (String) i.next();
  +
                   log("Executing target: " + targetName, MessageLevel.MSG_DEBUG);
                   executeTarget(targetName);
               }
           }
       }
   
  +
       /**
        * Execute the tasks of a target in this frame with the given name
        *
  -     * @param targetName the name of the target whose tasks will be
  -     *      evaluated
  +     * @param targetName              the name of the target whose tasks will
  +     *      be evaluated
        * @exception ExecutionException if there is a problem executing the
        *      tasks of the target
        */
  @@ -611,10 +665,12 @@
           try {
               // firstly build a list of fully qualified target names to execute.
               List dependencyOrder = project.getTargetDependencies(targetName);
  +
               for (Iterator i = dependencyOrder.iterator(); i.hasNext();) {
                   String fullTargetName = (String) i.next();
                   Frame frame = getContainingFrame(fullTargetName);
                   String localTargetName = getNameInFrame(fullTargetName);
  +
                   frame.executeTargetTasks(localTargetName);
               }
           } catch (ConfigException e) {
  @@ -622,6 +678,7 @@
           }
       }
   
  +
       /**
        * Run the tasks returned by the given iterator
        *
  @@ -633,14 +690,17 @@
            throws ExecutionException {
           while (taskIterator.hasNext()) {
               BuildElement model = (BuildElement) taskIterator.next();
  +
               // what sort of element is this.
               try {
                   Object component = componentManager.createComponent(model);
  +
                   if (component instanceof Task) {
                       execService.executeTask((Task) component);
                   } else {
                       String typeId
                            = model.getAspectValue(Constants.ANT_ASPECT, "id");
  +
                       if (typeId != null) {
                           setDataValue(typeId, component, true);
                       }
  @@ -648,24 +708,27 @@
               } catch (AntException te) {
                   ExecutionException e
                        = new ExecutionException(te, te.getLocation());
  +
                   e.setLocation(model.getLocation(), false);
                   throw e;
               } catch (RuntimeException e) {
                   ExecutionException ee =
                       new ExecutionException(e.getClass().getName() + ": "
                        + e.getMessage(), e, model.getLocation());
  +
                   throw ee;
               }
           }
   
       }
   
  +
       /**
        * Execute the given target's tasks. The target must be local to this
        * frame's project
        *
  -     * @param targetName the name of the target within this frame that is to
  -     *      be executed.
  +     * @param targetName              the name of the target within this frame
  +     *      that is to be executed.
        * @exception ExecutionException if there is a problem executing tasks
        */
       protected void executeTargetTasks(String targetName)
  @@ -692,6 +755,7 @@
   
           try {
               Iterator taskIterator = target.getTasks();
  +
               eventSupport.fireTargetStarted(target);
               executeTasks(taskIterator);
           } catch (ExecutionException e) {
  @@ -702,6 +766,7 @@
               ExecutionException ee =
                   new ExecutionException(e.getClass().getName() + ": "
                    + e.getMessage(), e, target.getLocation());
  +
               failureCause = ee;
               throw ee;
           } finally {
  @@ -719,12 +784,16 @@
       protected void initialize() throws ExecutionException {
           for (Iterator i = getReferencedFrames(); i.hasNext();) {
               Frame referencedFrame = (Frame) i.next();
  +
               referencedFrame.initialize();
           }
  +
           Iterator taskIterator = project.getTasks();
  +
           executeTasks(taskIterator);
       }
   
  +
       /**
        * Determine the base directory for each frame in the frame hierarchy
        *
  @@ -737,14 +806,17 @@
                    = new File(getDataValue(MagicProperties.BASEDIR).toString());
           } else {
               URL projectURL = project.getSourceURL();
  +
               if (projectURL.getProtocol().equals("file")) {
                   File projectFile = new File(projectURL.getFile());
                   File projectFileParent = projectFile.getParentFile();
                   String base = project.getBase();
  +
                   if (base == null) {
                       baseDir = projectFileParent;
                   } else {
                       FileUtils fileUtils = FileUtils.newFileUtils();
  +
                       baseDir = fileUtils.resolveFile(projectFileParent, base);
                   }
               } else {
  @@ -755,10 +827,12 @@
   
           for (Iterator i = getReferencedFrames(); i.hasNext();) {
               Frame refFrame = (Frame) i.next();
  +
               refFrame.determineBaseDirs();
           }
       }
   
  +
       /**
        * Configure the services that the frame makes available to its library
        * components
  @@ -778,5 +852,19 @@
           services.put(EventService.class, new CoreEventService(this));
           services.put(ExecService.class, execService);
       }
  +
  +
  +    /**
  +     * Handle the content from a single thread. This method will be called by
  +     * the thread producing the content. The content is broken up into
  +     * separate lines
  +     *
  +     * @param line   the content produce by the current thread.
  +     * @param isErr  true if this content is from the thread's error stream.
  +     */
  +    public void threadOutput(String line, boolean isErr) {
  +        eventSupport.threadOutput(line, isErr);
   }
  +}
  +
   
  
  
  

--
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