aboutsummaryrefslogtreecommitdiffstats
path: root/taskdefs/src
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-06-02 11:46:31 +0000
committeracolyer <acolyer>2005-06-02 11:46:31 +0000
commit27c6150906667e299a6952bc4dda642aad00578d (patch)
tree4ccbc1e238ba018c51d1fa45d3bcceb2ebac9c90 /taskdefs/src
parentbedcb3ea08173f4b4ed837822e917e8dba6837d9 (diff)
downloadaspectj-27c6150906667e299a6952bc4dda642aad00578d.tar.gz
aspectj-27c6150906667e299a6952bc4dda642aad00578d.zip
Andrew Huff's patch for the -log option
Diffstat (limited to 'taskdefs/src')
-rw-r--r--taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java49
1 files changed, 9 insertions, 40 deletions
diff --git a/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java b/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java
index 60fba4b89..0427f9c1f 100644
--- a/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java
+++ b/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java
@@ -25,7 +25,6 @@ import org.apache.tools.ant.types.*;
import org.aspectj.bridge.*;
import org.aspectj.tools.ajc.Main;
import org.aspectj.tools.ajc.Main.MessagePrinter;
-import org.aspectj.tools.ajc.Main.LogModeMessagePrinter;
import org.aspectj.util.*;
@@ -292,8 +291,6 @@ public class AjcTask extends MatchingTask {
// ---------------------------- state and Ant interface thereto
private boolean verbose;
private boolean listFileArgs;
- private boolean loggingMode;
- private File logFile;
private boolean failonerror;
private boolean fork;
private String maxMem;
@@ -407,8 +404,6 @@ public class AjcTask extends MatchingTask {
verbose = false;
xweaveDir = null;
xdoneSignal = null;
- loggingMode = false;
- logFile = null;
}
protected void ignore(String ignored) {
@@ -546,9 +541,7 @@ public class AjcTask extends MatchingTask {
}
public void setLog(File file) {
- //cmd.addFlagged("-log", file.getAbsolutePath());
- this.loggingMode = true;
- this.logFile = file;
+ cmd.addFlagged("-log", file.getAbsolutePath());
}
public void setProceedOnError(boolean proceedOnError) {
@@ -1166,7 +1159,6 @@ public class AjcTask extends MatchingTask {
*
*/
protected void executeInSameVM(String[] args) {
- PrintStream logStream = null;
if (null != maxMem) {
log("maxMem ignored unless forked: " + maxMem, Project.MSG_WARN);
}
@@ -1175,26 +1167,7 @@ public class AjcTask extends MatchingTask {
if (null == holder) {
MessageHandler mhandler = new MessageHandler(true);
final IMessageHandler delegate;
- if (!loggingMode){
delegate = verbose ? MessagePrinter.VERBOSE: MessagePrinter.TERSE;
- }
- else{
- String logFileName = logFile.toString();
- try {
- logFile.createNewFile();
- FileOutputStream fos = new FileOutputStream(logFileName, true);
- logStream = new PrintStream(fos,true);
- delegate = new LogModeMessagePrinter(verbose, logStream);
- Date now = new Date();
- logStream.println("Log started: " + now.toString());
- } catch (IOException e){
- if (logStream != null) {
- logStream.close();
- logStream = null;
- }
- throw new BuildException("Logfile couldn't be written to: ",e);
- }
- }
mhandler.setInterceptor(delegate);
if (!verbose) {
mhandler.ignore(IMessage.INFO);
@@ -1218,14 +1191,7 @@ public class AjcTask extends MatchingTask {
}
main = newmain;
}
- try {
- main.runMain(args, false);
- } finally {
- main = null;
- if (logStream != null) {
- logStream.close();
- }
- }
+ main.runMain(args, false);
if (failonerror) {
int errs = holder.numMessages(IMessage.ERROR, false);
errs -= numPreviousErrors;
@@ -1376,10 +1342,12 @@ public class AjcTask extends MatchingTask {
* @return
*/
protected int execInOtherVM(String[] args) {
- try {
+ try {
+
Project project = getProject();
- LogStreamHandler handler = new LogStreamHandler(this,
- Project.MSG_INFO, Project.MSG_WARN);
+ PumpStreamHandler handler = new LogStreamHandler(this,
+ Project.MSG_INFO, Project.MSG_WARN);
+
// replace above two lines with what follows as an aid to debugging when running the unit tests....
// LogStreamHandler handler = new LogStreamHandler(this,
// Project.MSG_INFO, Project.MSG_WARN) {
@@ -1402,7 +1370,8 @@ public class AjcTask extends MatchingTask {
// super.stop();
// }
// };
- Execute exe = new Execute(handler);
+
+ Execute exe = new Execute(handler);
exe.setAntRun(project);
exe.setWorkingDirectory(project.getBaseDir());
exe.setCommandline(args);