git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272313 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -63,6 +63,7 @@ import org.apache.ant.common.event.BuildListener; | |||
| import org.apache.ant.common.model.ModelElement; | |||
| import org.apache.ant.common.util.DemuxOutputReceiver; | |||
| import org.apache.ant.common.event.MessageLevel; | |||
| import org.apache.ant.common.util.ExecutionException; | |||
| /** | |||
| * BuildEventSupport is used by classes which which to send build events to | |||
| @@ -230,16 +231,20 @@ public class BuildEventSupport implements DemuxOutputReceiver { | |||
| */ | |||
| public void threadOutput(String line, boolean isError) { | |||
| Task task = (Task) threadTasks.get(Thread.currentThread()); | |||
| if (task == null) { | |||
| fireMessageLogged(this, line, | |||
| isError ? MessageLevel.MSG_ERR : MessageLevel.MSG_INFO); | |||
| } else { | |||
| if (isError) { | |||
| task.handleSystemErr(line); | |||
| } else { | |||
| task.handleSystemOut(line); | |||
| if (task != null) { | |||
| try { | |||
| if (isError) { | |||
| task.handleSystemErr(line); | |||
| } else { | |||
| task.handleSystemOut(line); | |||
| } | |||
| return; | |||
| } catch (ExecutionException e) { | |||
| // ignore just log normally | |||
| } | |||
| } | |||
| fireMessageLogged(this, line, | |||
| isError ? MessageLevel.MSG_ERR : MessageLevel.MSG_INFO); | |||
| } | |||
| } | |||
| @@ -77,7 +77,7 @@ public class CoreExecService implements ExecService { | |||
| /** The Frame this service instance is working for */ | |||
| private Frame frame; | |||
| /** A map of subbuild keys to the frame of the subbuild. */ | |||
| private Map subBuilds = new HashMap(); | |||
| @@ -152,18 +152,12 @@ public class CoreExecService implements ExecService { | |||
| /** | |||
| * Handle subbuild output. | |||
| * Gets the Frame for a subbuild based on the key | |||
| * | |||
| * @param subbuildKey the core's key for managing the subbuild. | |||
| * @param line the content produce by the current thread. | |||
| * @param isErr true if this content is from the thread's error stream. | |||
| * @param key Description of the Parameter | |||
| * @return the subbuild's Frame | |||
| * @exception ExecutionException if the build cannot be found. | |||
| */ | |||
| public void handleBuildOutput(Object subbuildKey, String line, | |||
| boolean isErr) throws ExecutionException { | |||
| getSubbuildFrame(subbuildKey).threadOutput(line, isErr); | |||
| } | |||
| private Frame getSubbuildFrame(Object key) throws ExecutionException { | |||
| Frame subFrame = (Frame) subBuilds.get(key); | |||
| @@ -173,7 +167,22 @@ public class CoreExecService implements ExecService { | |||
| } | |||
| return subFrame; | |||
| } | |||
| /** | |||
| * Handle subbuild output. | |||
| * | |||
| * @param subbuildKey the core's key for managing the subbuild. | |||
| * @param line the content produce by the current thread. | |||
| * @param isErr true if this content is from the thread's error stream. | |||
| * @exception ExecutionException if the subbuild cannot be found. | |||
| */ | |||
| public void handleBuildOutput(Object subbuildKey, String line, | |||
| boolean isErr) throws ExecutionException { | |||
| getSubbuildFrame(subbuildKey).threadOutput(line, isErr); | |||
| } | |||
| /** | |||
| * Run a build which have been previously setup | |||
| * | |||
| @@ -190,7 +190,7 @@ public class Frame implements DemuxOutputReceiver { | |||
| this.project = project; | |||
| referencedFrames = new HashMap(); | |||
| for (Iterator i = project.getReferencedProjectNames(); i.hasNext(); ) { | |||
| for (Iterator i = project.getReferencedProjectNames(); i.hasNext();) { | |||
| String referenceName = (String) i.next(); | |||
| Project referencedProject | |||
| = project.getReferencedProject(referenceName); | |||
| @@ -540,7 +540,7 @@ public class Frame implements DemuxOutputReceiver { | |||
| * @exception ExecutionException if the frame cannot be created. | |||
| */ | |||
| protected void addProperties(Map properties) throws ExecutionException { | |||
| for (Iterator i = properties.keySet().iterator(); i.hasNext(); ) { | |||
| for (Iterator i = properties.keySet().iterator(); i.hasNext();) { | |||
| String name = (String) i.next(); | |||
| Object value = properties.get(name); | |||
| @@ -562,7 +562,7 @@ public class Frame implements DemuxOutputReceiver { | |||
| = new Frame(standardLibs, initConfig, config); | |||
| newFrame.setProject(project); | |||
| for (Iterator j = eventSupport.getListeners(); j.hasNext(); ) { | |||
| for (Iterator j = eventSupport.getListeners(); j.hasNext();) { | |||
| BuildListener listener = (BuildListener) j.next(); | |||
| newFrame.addBuildListener(listener); | |||
| @@ -588,7 +588,7 @@ public class Frame implements DemuxOutputReceiver { | |||
| * @param listener the listener to be added to the frame | |||
| */ | |||
| protected void addBuildListener(BuildListener listener) { | |||
| for (Iterator i = getReferencedFrames(); i.hasNext(); ) { | |||
| for (Iterator i = getReferencedFrames(); i.hasNext();) { | |||
| Frame referencedFrame = (Frame) i.next(); | |||
| referencedFrame.addBuildListener(listener); | |||
| @@ -603,7 +603,7 @@ public class Frame implements DemuxOutputReceiver { | |||
| * @param listener the listener to be removed | |||
| */ | |||
| protected void removeBuildListener(BuildListener listener) { | |||
| for (Iterator i = getReferencedFrames(); i.hasNext(); ) { | |||
| for (Iterator i = getReferencedFrames(); i.hasNext();) { | |||
| Frame subFrame = (Frame) i.next(); | |||
| subFrame.removeBuildListener(listener); | |||
| @@ -632,7 +632,7 @@ public class Frame implements DemuxOutputReceiver { | |||
| executeTarget(defaultTarget); | |||
| } | |||
| } else { | |||
| for (Iterator i = targets.iterator(); i.hasNext(); ) { | |||
| for (Iterator i = targets.iterator(); i.hasNext();) { | |||
| String targetName = (String) i.next(); | |||
| log("Executing target: " + targetName, MessageLevel.MSG_DEBUG); | |||
| @@ -657,7 +657,7 @@ public class Frame implements DemuxOutputReceiver { | |||
| // firstly build a list of fully qualified target names to execute. | |||
| List dependencyOrder = project.getTargetDependencies(targetName); | |||
| for (Iterator i = dependencyOrder.iterator(); i.hasNext(); ) { | |||
| for (Iterator i = dependencyOrder.iterator(); i.hasNext();) { | |||
| String fullTargetName = (String) i.next(); | |||
| Frame frame = getContainingFrame(fullTargetName); | |||
| String localTargetName = getNameInFrame(fullTargetName); | |||
| @@ -773,7 +773,7 @@ public class Frame implements DemuxOutputReceiver { | |||
| * failed | |||
| */ | |||
| protected void initialize() throws ExecutionException { | |||
| for (Iterator i = getReferencedFrames(); i.hasNext(); ) { | |||
| for (Iterator i = getReferencedFrames(); i.hasNext();) { | |||
| Frame referencedFrame = (Frame) i.next(); | |||
| referencedFrame.initialize(); | |||
| @@ -816,7 +816,7 @@ public class Frame implements DemuxOutputReceiver { | |||
| } | |||
| setDataValue(MagicProperties.BASEDIR, baseDir.getAbsolutePath(), true); | |||
| for (Iterator i = getReferencedFrames(); i.hasNext(); ) { | |||
| for (Iterator i = getReferencedFrames(); i.hasNext();) { | |||
| Frame refFrame = (Frame) i.next(); | |||
| refFrame.determineBaseDirs(); | |||
| @@ -53,7 +53,6 @@ | |||
| */ | |||
| package org.apache.ant.antlib.system; | |||
| import java.io.File; | |||
| import org.apache.ant.common.service.ExecService; | |||
| import org.apache.ant.common.util.ExecutionException; | |||
| import org.apache.ant.common.service.MagicProperties; | |||
| import org.apache.ant.common.util.FileUtils; | |||
| @@ -325,11 +325,13 @@ public abstract class AntBase extends AbstractTask { | |||
| * System.err, directly or indirectly. | |||
| * | |||
| * @param line The line of error info produce by the task | |||
| * @exception ExecutionException if the output cannot be handled. | |||
| */ | |||
| public void handleSystemErr(String line) { | |||
| public void handleSystemErr(String line) throws ExecutionException { | |||
| if (subbuildKey == null) { | |||
| super.handleSystemErr(line); | |||
| } else { | |||
| execService.handleBuildOutput(subbuildKey, line, true); | |||
| } | |||
| } | |||
| @@ -341,11 +343,13 @@ public abstract class AntBase extends AbstractTask { | |||
| * or indirectly. | |||
| * | |||
| * @param line The line of content produce by the task | |||
| * @exception ExecutionException if the output cannot be handled. | |||
| */ | |||
| public void handleSystemOut(String line) { | |||
| public void handleSystemOut(String line) throws ExecutionException { | |||
| if (subbuildKey == null) { | |||
| super.handleSystemOut(line); | |||
| } else { | |||
| execService.handleBuildOutput(subbuildKey, line, false); | |||
| } | |||
| } | |||
| @@ -52,7 +52,6 @@ | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.ant.antlib.system; | |||
| import org.apache.ant.common.service.ExecService; | |||
| import org.apache.ant.common.util.ExecutionException; | |||
| import org.apache.ant.common.service.MagicProperties; | |||
| @@ -53,6 +53,7 @@ | |||
| */ | |||
| package org.apache.ant.common.antlib; | |||
| import org.apache.ant.common.event.MessageLevel; | |||
| import org.apache.ant.common.util.ExecutionException; | |||
| /** | |||
| * Abstract implementation of the Task interface | |||
| @@ -89,8 +90,9 @@ public abstract class AbstractTask extends AbstractComponent implements Task { | |||
| * directly or indirectly. | |||
| * | |||
| * @param line The line of content produce by the task | |||
| * @exception ExecutionException if the output cannot be handled. | |||
| */ | |||
| public void handleSystemOut(String line) { | |||
| public void handleSystemOut(String line) throws ExecutionException { | |||
| // default behaviout is to log at INFO level | |||
| log(line, MessageLevel.MSG_INFO); | |||
| } | |||
| @@ -102,8 +104,9 @@ public abstract class AbstractTask extends AbstractComponent implements Task { | |||
| * System.err, directly or indirectly. | |||
| * | |||
| * @param line The line of error info produce by the task | |||
| * @exception ExecutionException if the output cannot be handled. | |||
| */ | |||
| public void handleSystemErr(String line) { | |||
| public void handleSystemErr(String line) throws ExecutionException { | |||
| // default behaviout is to log at WARN level | |||
| log(line, MessageLevel.MSG_WARN); | |||
| } | |||
| @@ -89,8 +89,9 @@ public interface Task extends ExecutionComponent { | |||
| * directly or indirectly. | |||
| * | |||
| * @param line The line of content produce by the task | |||
| * @exception ExecutionException if the output cannot be handled. | |||
| */ | |||
| void handleSystemOut(String line); | |||
| void handleSystemOut(String line) throws ExecutionException; | |||
| /** | |||
| * Handle error information produced by the task. When a task prints to | |||
| @@ -99,7 +100,8 @@ public interface Task extends ExecutionComponent { | |||
| * System.err, directly or indirectly. | |||
| * | |||
| * @param line The line of error info produce by the task | |||
| * @exception ExecutionException if the output cannot be handled. | |||
| */ | |||
| void handleSystemErr(String line); | |||
| void handleSystemErr(String line) throws ExecutionException; | |||
| } | |||
| @@ -93,6 +93,7 @@ public interface ExecService { | |||
| * | |||
| * @param properties the initiali properties to be used in the build | |||
| * @exception ExecutionException if the subbuild cannot be setup | |||
| * @return a key to the build allowing it to be executed and managed | |||
| */ | |||
| Object setupBuild(Map properties) | |||
| throws ExecutionException; | |||
| @@ -136,6 +137,8 @@ public interface ExecService { | |||
| * @param subbuildKey the core's key for managing the subbuild. | |||
| * @param line the content produce by the current thread. | |||
| * @param isErr true if this content is from the thread's error stream. | |||
| * | |||
| * @exception ExecutionException if the subbuild cannot be found. | |||
| */ | |||
| void handleBuildOutput(Object subbuildKey, String line, boolean isErr) | |||
| throws ExecutionException; | |||