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.model.ModelElement; | ||||
import org.apache.ant.common.util.DemuxOutputReceiver; | import org.apache.ant.common.util.DemuxOutputReceiver; | ||||
import org.apache.ant.common.event.MessageLevel; | 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 | * 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) { | public void threadOutput(String line, boolean isError) { | ||||
Task task = (Task) threadTasks.get(Thread.currentThread()); | 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 */ | /** The Frame this service instance is working for */ | ||||
private Frame frame; | private Frame frame; | ||||
/** A map of subbuild keys to the frame of the subbuild. */ | /** A map of subbuild keys to the frame of the subbuild. */ | ||||
private Map subBuilds = new HashMap(); | 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 { | private Frame getSubbuildFrame(Object key) throws ExecutionException { | ||||
Frame subFrame = (Frame) subBuilds.get(key); | Frame subFrame = (Frame) subBuilds.get(key); | ||||
@@ -173,7 +167,22 @@ public class CoreExecService implements ExecService { | |||||
} | } | ||||
return subFrame; | 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 | * Run a build which have been previously setup | ||||
* | * | ||||
@@ -190,7 +190,7 @@ public class Frame implements DemuxOutputReceiver { | |||||
this.project = project; | this.project = project; | ||||
referencedFrames = new HashMap(); | referencedFrames = new HashMap(); | ||||
for (Iterator i = project.getReferencedProjectNames(); i.hasNext(); ) { | |||||
for (Iterator i = project.getReferencedProjectNames(); i.hasNext();) { | |||||
String referenceName = (String) i.next(); | String referenceName = (String) i.next(); | ||||
Project referencedProject | Project referencedProject | ||||
= project.getReferencedProject(referenceName); | = project.getReferencedProject(referenceName); | ||||
@@ -540,7 +540,7 @@ public class Frame implements DemuxOutputReceiver { | |||||
* @exception ExecutionException if the frame cannot be created. | * @exception ExecutionException if the frame cannot be created. | ||||
*/ | */ | ||||
protected void addProperties(Map properties) throws ExecutionException { | 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(); | String name = (String) i.next(); | ||||
Object value = properties.get(name); | Object value = properties.get(name); | ||||
@@ -562,7 +562,7 @@ public class Frame implements DemuxOutputReceiver { | |||||
= new Frame(standardLibs, initConfig, config); | = new Frame(standardLibs, initConfig, config); | ||||
newFrame.setProject(project); | newFrame.setProject(project); | ||||
for (Iterator j = eventSupport.getListeners(); j.hasNext(); ) { | |||||
for (Iterator j = eventSupport.getListeners(); j.hasNext();) { | |||||
BuildListener listener = (BuildListener) j.next(); | BuildListener listener = (BuildListener) j.next(); | ||||
newFrame.addBuildListener(listener); | newFrame.addBuildListener(listener); | ||||
@@ -588,7 +588,7 @@ public class Frame implements DemuxOutputReceiver { | |||||
* @param listener the listener to be added to the frame | * @param listener the listener to be added to the frame | ||||
*/ | */ | ||||
protected void addBuildListener(BuildListener listener) { | protected void addBuildListener(BuildListener listener) { | ||||
for (Iterator i = getReferencedFrames(); i.hasNext(); ) { | |||||
for (Iterator i = getReferencedFrames(); i.hasNext();) { | |||||
Frame referencedFrame = (Frame) i.next(); | Frame referencedFrame = (Frame) i.next(); | ||||
referencedFrame.addBuildListener(listener); | referencedFrame.addBuildListener(listener); | ||||
@@ -603,7 +603,7 @@ public class Frame implements DemuxOutputReceiver { | |||||
* @param listener the listener to be removed | * @param listener the listener to be removed | ||||
*/ | */ | ||||
protected void removeBuildListener(BuildListener listener) { | protected void removeBuildListener(BuildListener listener) { | ||||
for (Iterator i = getReferencedFrames(); i.hasNext(); ) { | |||||
for (Iterator i = getReferencedFrames(); i.hasNext();) { | |||||
Frame subFrame = (Frame) i.next(); | Frame subFrame = (Frame) i.next(); | ||||
subFrame.removeBuildListener(listener); | subFrame.removeBuildListener(listener); | ||||
@@ -632,7 +632,7 @@ public class Frame implements DemuxOutputReceiver { | |||||
executeTarget(defaultTarget); | executeTarget(defaultTarget); | ||||
} | } | ||||
} else { | } else { | ||||
for (Iterator i = targets.iterator(); i.hasNext(); ) { | |||||
for (Iterator i = targets.iterator(); i.hasNext();) { | |||||
String targetName = (String) i.next(); | String targetName = (String) i.next(); | ||||
log("Executing target: " + targetName, MessageLevel.MSG_DEBUG); | 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. | // firstly build a list of fully qualified target names to execute. | ||||
List dependencyOrder = project.getTargetDependencies(targetName); | List dependencyOrder = project.getTargetDependencies(targetName); | ||||
for (Iterator i = dependencyOrder.iterator(); i.hasNext(); ) { | |||||
for (Iterator i = dependencyOrder.iterator(); i.hasNext();) { | |||||
String fullTargetName = (String) i.next(); | String fullTargetName = (String) i.next(); | ||||
Frame frame = getContainingFrame(fullTargetName); | Frame frame = getContainingFrame(fullTargetName); | ||||
String localTargetName = getNameInFrame(fullTargetName); | String localTargetName = getNameInFrame(fullTargetName); | ||||
@@ -773,7 +773,7 @@ public class Frame implements DemuxOutputReceiver { | |||||
* failed | * failed | ||||
*/ | */ | ||||
protected void initialize() throws ExecutionException { | protected void initialize() throws ExecutionException { | ||||
for (Iterator i = getReferencedFrames(); i.hasNext(); ) { | |||||
for (Iterator i = getReferencedFrames(); i.hasNext();) { | |||||
Frame referencedFrame = (Frame) i.next(); | Frame referencedFrame = (Frame) i.next(); | ||||
referencedFrame.initialize(); | referencedFrame.initialize(); | ||||
@@ -816,7 +816,7 @@ public class Frame implements DemuxOutputReceiver { | |||||
} | } | ||||
setDataValue(MagicProperties.BASEDIR, baseDir.getAbsolutePath(), true); | setDataValue(MagicProperties.BASEDIR, baseDir.getAbsolutePath(), true); | ||||
for (Iterator i = getReferencedFrames(); i.hasNext(); ) { | |||||
for (Iterator i = getReferencedFrames(); i.hasNext();) { | |||||
Frame refFrame = (Frame) i.next(); | Frame refFrame = (Frame) i.next(); | ||||
refFrame.determineBaseDirs(); | refFrame.determineBaseDirs(); | ||||
@@ -53,7 +53,6 @@ | |||||
*/ | */ | ||||
package org.apache.ant.antlib.system; | package org.apache.ant.antlib.system; | ||||
import java.io.File; | import java.io.File; | ||||
import org.apache.ant.common.service.ExecService; | |||||
import org.apache.ant.common.util.ExecutionException; | import org.apache.ant.common.util.ExecutionException; | ||||
import org.apache.ant.common.service.MagicProperties; | import org.apache.ant.common.service.MagicProperties; | ||||
import org.apache.ant.common.util.FileUtils; | import org.apache.ant.common.util.FileUtils; | ||||
@@ -325,11 +325,13 @@ public abstract class AntBase extends AbstractTask { | |||||
* System.err, directly or indirectly. | * System.err, directly or indirectly. | ||||
* | * | ||||
* @param line The line of error info produce by the task | * @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) { | if (subbuildKey == null) { | ||||
super.handleSystemErr(line); | super.handleSystemErr(line); | ||||
} else { | } else { | ||||
execService.handleBuildOutput(subbuildKey, line, true); | |||||
} | } | ||||
} | } | ||||
@@ -341,11 +343,13 @@ public abstract class AntBase extends AbstractTask { | |||||
* or indirectly. | * or indirectly. | ||||
* | * | ||||
* @param line The line of content produce by the task | * @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) { | if (subbuildKey == null) { | ||||
super.handleSystemOut(line); | super.handleSystemOut(line); | ||||
} else { | } else { | ||||
execService.handleBuildOutput(subbuildKey, line, false); | |||||
} | } | ||||
} | } | ||||
@@ -52,7 +52,6 @@ | |||||
* <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
*/ | */ | ||||
package org.apache.ant.antlib.system; | 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.util.ExecutionException; | ||||
import org.apache.ant.common.service.MagicProperties; | import org.apache.ant.common.service.MagicProperties; | ||||
@@ -53,6 +53,7 @@ | |||||
*/ | */ | ||||
package org.apache.ant.common.antlib; | package org.apache.ant.common.antlib; | ||||
import org.apache.ant.common.event.MessageLevel; | import org.apache.ant.common.event.MessageLevel; | ||||
import org.apache.ant.common.util.ExecutionException; | |||||
/** | /** | ||||
* Abstract implementation of the Task interface | * Abstract implementation of the Task interface | ||||
@@ -89,8 +90,9 @@ public abstract class AbstractTask extends AbstractComponent implements Task { | |||||
* directly or indirectly. | * directly or indirectly. | ||||
* | * | ||||
* @param line The line of content produce by the task | * @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 | // default behaviout is to log at INFO level | ||||
log(line, MessageLevel.MSG_INFO); | log(line, MessageLevel.MSG_INFO); | ||||
} | } | ||||
@@ -102,8 +104,9 @@ public abstract class AbstractTask extends AbstractComponent implements Task { | |||||
* System.err, directly or indirectly. | * System.err, directly or indirectly. | ||||
* | * | ||||
* @param line The line of error info produce by the task | * @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 | // default behaviout is to log at WARN level | ||||
log(line, MessageLevel.MSG_WARN); | log(line, MessageLevel.MSG_WARN); | ||||
} | } | ||||
@@ -89,8 +89,9 @@ public interface Task extends ExecutionComponent { | |||||
* directly or indirectly. | * directly or indirectly. | ||||
* | * | ||||
* @param line The line of content produce by the task | * @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 | * 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. | * System.err, directly or indirectly. | ||||
* | * | ||||
* @param line The line of error info produce by the task | * @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 | * @param properties the initiali properties to be used in the build | ||||
* @exception ExecutionException if the subbuild cannot be setup | * @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) | Object setupBuild(Map properties) | ||||
throws ExecutionException; | throws ExecutionException; | ||||
@@ -136,6 +137,8 @@ public interface ExecService { | |||||
* @param subbuildKey the core's key for managing the subbuild. | * @param subbuildKey the core's key for managing the subbuild. | ||||
* @param line the content produce by the current thread. | * @param line the content produce by the current thread. | ||||
* @param isErr true if this content is from the thread's error stream. | * @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) | void handleBuildOutput(Object subbuildKey, String line, boolean isErr) | ||||
throws ExecutionException; | throws ExecutionException; | ||||