summaryrefslogtreecommitdiffstats
path: root/taskdefs
diff options
context:
space:
mode:
authorwisberg <wisberg>2006-06-13 19:45:44 +0000
committerwisberg <wisberg>2006-06-13 19:45:44 +0000
commit008efca98bdfe5cda6c32ec75575facf7da2c687 (patch)
tree7fdd65eacff28a6d84c85afbfd5817cef1b0269f /taskdefs
parentf58b5d89371ed4454e65dbbca54032db4039151a (diff)
downloadaspectj-008efca98bdfe5cda6c32ec75575facf7da2c687.tar.gz
aspectj-008efca98bdfe5cda6c32ec75575facf7da2c687.zip
Fix 136707 new logCommand option emits command line to INFO
Diffstat (limited to 'taskdefs')
-rw-r--r--taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java14
-rw-r--r--taskdefs/testsrc/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java85
2 files changed, 79 insertions, 20 deletions
diff --git a/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java b/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java
index 19c4e6127..62034beb8 100644
--- a/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java
+++ b/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java
@@ -402,6 +402,9 @@ public class AjcTask extends MatchingTask {
/** true if -XincrementalFile (i.e, setTagFile)*/
private boolean inIncrementalFileMode;
+ /** log command in non-verbose mode */
+ private boolean logCommand;
+
/** used when forking */
private CommandlineJava javaCmd = new CommandlineJava();
@@ -447,6 +450,7 @@ public class AjcTask extends MatchingTask {
verbose = false;
xweaveDir = null;
xdoneSignal = null;
+ logCommand = false;
javaCmd = new CommandlineJava();
}
@@ -495,6 +499,10 @@ public class AjcTask extends MatchingTask {
inIncrementalMode = incremental;
}
+ public void setLogCommand(boolean logCommand) {
+ this.logCommand = logCommand;
+ }
+
public void setHelp(boolean help) {
cmd.addFlag("-help", help);
}
@@ -1063,7 +1071,11 @@ public class AjcTask extends MatchingTask {
verifyOptions();
try {
String[] args = makeCommand();
- logVerbose("ajc " + Arrays.asList(args));
+ if (logCommand) {
+ log("ajc " + Arrays.asList(args));
+ } else {
+ logVerbose("ajc " + Arrays.asList(args));
+ }
if (!fork) {
executeInSameVM(args);
} else { // when forking, Adapter handles failonerror
diff --git a/taskdefs/testsrc/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java b/taskdefs/testsrc/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java
index da24f8e03..c0667abb3 100644
--- a/taskdefs/testsrc/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java
+++ b/taskdefs/testsrc/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java
@@ -22,13 +22,16 @@ import java.io.FileFilter;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintStream;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import junit.framework.TestCase;
+import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.Location;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Path;
@@ -715,25 +718,48 @@ public class AjcTaskTest extends TestCase {
runTest(task, NO_EXCEPTION, MessageHolderChecker.ONE_ERROR_ONE_ABORT);
}
- public void testDefaultFileComplete() {
- AjcTask task = getTask("default.lst");
- task.setDebugLevel("none");
- task.setDeprecation(true);
- task.setFailonerror(false);
- task.setNoExit(true); // ok to override Ant?
- task.setNoImportError(true);
- task.setNowarn(true);
- task.setXTerminateAfterCompilation(true);
- task.setPreserveAllLocals(true);
- task.setProceedOnError(true);
- task.setReferenceInfo(true);
- task.setSource("1.3");
- task.setTarget("1.1");
- task.setTime(true);
- task.setVerbose(true);
- task.setXlint("info");
- runTest(task, NO_EXCEPTION, MessageHolderChecker.INFOS);
- }
+ public void testDefaultFileComplete() {
+ AjcTask task = getTask("default.lst");
+ defaultSettings(task);
+ runTest(task, NO_EXCEPTION, MessageHolderChecker.INFOS);
+ }
+ private void defaultSettings(AjcTask task) {
+ task.setDebugLevel("none");
+ task.setDeprecation(true);
+ task.setFailonerror(false);
+ task.setNoExit(true); // ok to override Ant?
+ task.setNoImportError(true);
+ task.setNowarn(true);
+ task.setXTerminateAfterCompilation(true);
+ task.setPreserveAllLocals(true);
+ task.setProceedOnError(true);
+ task.setReferenceInfo(true);
+ task.setSource("1.3");
+ task.setTarget("1.1");
+ task.setTime(true);
+ task.setVerbose(true);
+ task.setXlint("info");
+ }
+
+ public void testLogCommand() {
+ final String DEFAULT = "default.lst";
+ AjcTask task = getTask(DEFAULT);
+ defaultSettings(task);
+ task.setVerbose(false);
+ task.setLogCommand(true);
+ LogListener listener = new LogListener(Project.MSG_INFO);
+ task.getProject().addBuildListener(listener);
+ runTest(task, NO_EXCEPTION, MessageHolderChecker.INFOS);
+ String[] results = listener.getResults();
+ boolean matched = false;
+ for (int i = 0; !matched && (i < results.length); i++) {
+ String s = results[i];
+ matched = (null != s) && (-1 != s.indexOf(DEFAULT));
+ }
+ if (!matched) {
+ fail(DEFAULT + " not found in " + Arrays.asList(results));
+ }
+ }
public void testXOptions() {
String[] xopts = new String[] {
@@ -937,6 +963,27 @@ public class AjcTaskTest extends TestCase {
}
}
}
+ private static class LogListener implements BuildListener {
+ private final ArrayList results = new ArrayList();
+ private final int priority;
+ private LogListener(int priority) {
+ this.priority = priority;
+ }
+ public void buildFinished(BuildEvent event) {}
+ public void buildStarted(BuildEvent event) {}
+ public void messageLogged(BuildEvent event) {
+ if (priority == event.getPriority()) {
+ results.add(event.getMessage());
+ }
+ }
+ public void targetFinished(BuildEvent event) {}
+ public void targetStarted(BuildEvent event) {}
+ public void taskFinished(BuildEvent event) {}
+ public void taskStarted(BuildEvent event) {}
+ String[] getResults() {
+ return (String[]) results.toArray(new String[0]);
+ }
+ }
}
class SnoopingCommandEditor implements ICommandEditor {
private static final String[] NONE = new String[0];