git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1373334 13f79535-47bb-0310-9956-ffa450edef68master
@@ -77,8 +77,10 @@ You can also access environment variables using the | |||||
which instructs Ant to print less | which instructs Ant to print less | ||||
information to the console; | information to the console; | ||||
<nobr><code>-verbose</code></nobr>, which causes Ant to print | <nobr><code>-verbose</code></nobr>, which causes Ant to print | ||||
additional information to the console; and <nobr><code>-debug</code></nobr>, | |||||
which causes Ant to print considerably more additional information. | |||||
additional information to the console; <nobr><code>-debug</code></nobr>, | |||||
which causes Ant to print considerably more additional information; and | |||||
<nobr><code>-silent</code></nobr> which makes Ant print nothing but task | |||||
output and build failures (useful to capture Ant output by scripts). | |||||
</p> | </p> | ||||
<p>It is also possible to specify one or more targets that should be executed. | <p>It is also possible to specify one or more targets that should be executed. | ||||
@@ -104,6 +106,7 @@ Options: | |||||
-diagnostics print information that might be helpful to | -diagnostics print information that might be helpful to | ||||
diagnose or report problems. | diagnose or report problems. | ||||
-quiet, -q be extra quiet | -quiet, -q be extra quiet | ||||
-silent, -S print nothing but task outputs and build failures | |||||
-verbose, -v be extra verbose | -verbose, -v be extra verbose | ||||
-debug, -d print debugging information | -debug, -d print debugging information | ||||
-emacs, -e produce logging information without adornments | -emacs, -e produce logging information without adornments | ||||
@@ -36,6 +36,7 @@ import java.util.Vector; | |||||
import org.apache.tools.ant.input.DefaultInputHandler; | import org.apache.tools.ant.input.DefaultInputHandler; | ||||
import org.apache.tools.ant.input.InputHandler; | import org.apache.tools.ant.input.InputHandler; | ||||
import org.apache.tools.ant.launch.AntMain; | import org.apache.tools.ant.launch.AntMain; | ||||
import org.apache.tools.ant.listener.SilentLogger; | |||||
import org.apache.tools.ant.property.GetProperty; | import org.apache.tools.ant.property.GetProperty; | ||||
import org.apache.tools.ant.property.ResolvePropertyMap; | import org.apache.tools.ant.property.ResolvePropertyMap; | ||||
import org.apache.tools.ant.util.ClasspathUtils; | import org.apache.tools.ant.util.ClasspathUtils; | ||||
@@ -121,6 +122,11 @@ public class Main implements AntMain { | |||||
*/ | */ | ||||
private boolean emacsMode = false; | private boolean emacsMode = false; | ||||
/** | |||||
* Whether or not log output should be reduced to the minimum | |||||
*/ | |||||
private boolean silent = false; | |||||
/** | /** | ||||
* Whether or not this instance has successfully been | * Whether or not this instance has successfully been | ||||
* constructed and is ready to run. | * constructed and is ready to run. | ||||
@@ -336,6 +342,8 @@ public class Main implements AntMain { | |||||
msgOutputLevel = Project.MSG_VERBOSE; | msgOutputLevel = Project.MSG_VERBOSE; | ||||
} else if (arg.equals("-debug") || arg.equals("-d")) { | } else if (arg.equals("-debug") || arg.equals("-d")) { | ||||
msgOutputLevel = Project.MSG_DEBUG; | msgOutputLevel = Project.MSG_DEBUG; | ||||
} else if (arg.equals("-silent") || arg.equals("-S")) { | |||||
silent = true; | |||||
} else if (arg.equals("-noinput")) { | } else if (arg.equals("-noinput")) { | ||||
allowInput = false; | allowInput = false; | ||||
} else if (arg.equals("-logfile") || arg.equals("-l")) { | } else if (arg.equals("-logfile") || arg.equals("-l")) { | ||||
@@ -921,7 +929,11 @@ public class Main implements AntMain { | |||||
*/ | */ | ||||
private BuildLogger createLogger() { | private BuildLogger createLogger() { | ||||
BuildLogger logger = null; | BuildLogger logger = null; | ||||
if (loggerClassname != null) { | |||||
if (silent) { | |||||
logger = new SilentLogger(); | |||||
msgOutputLevel = Project.MSG_WARN; | |||||
emacsMode = true; | |||||
} else if (loggerClassname != null) { | |||||
try { | try { | ||||
logger = (BuildLogger) ClasspathUtils.newInstance( | logger = (BuildLogger) ClasspathUtils.newInstance( | ||||
loggerClassname, Main.class.getClassLoader(), | loggerClassname, Main.class.getClassLoader(), | ||||
@@ -958,6 +970,7 @@ public class Main implements AntMain { | |||||
msg.append(" -diagnostics print information that might be helpful to" + lSep); | msg.append(" -diagnostics print information that might be helpful to" + lSep); | ||||
msg.append(" diagnose or report problems." + lSep); | msg.append(" diagnose or report problems." + lSep); | ||||
msg.append(" -quiet, -q be extra quiet" + lSep); | msg.append(" -quiet, -q be extra quiet" + lSep); | ||||
msg.append(" -silent, -S print nothing but task outputs and build failures" + lSep); | |||||
msg.append(" -verbose, -v be extra verbose" + lSep); | msg.append(" -verbose, -v be extra verbose" + lSep); | ||||
msg.append(" -debug, -d print debugging information" + lSep); | msg.append(" -debug, -d print debugging information" + lSep); | ||||
msg.append(" -emacs, -e produce logging information without adornments" | msg.append(" -emacs, -e produce logging information without adornments" | ||||
@@ -0,0 +1,56 @@ | |||||
/* | |||||
* Licensed to the Apache Software Foundation (ASF) under one or more | |||||
* contributor license agreements. See the NOTICE file distributed with | |||||
* this work for additional information regarding copyright ownership. | |||||
* The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
* (the "License"); you may not use this file except in compliance with | |||||
* the License. You may obtain a copy of the License at | |||||
* | |||||
* http://www.apache.org/licenses/LICENSE-2.0 | |||||
* | |||||
* Unless required by applicable law or agreed to in writing, software | |||||
* distributed under the License is distributed on an "AS IS" BASIS, | |||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
* See the License for the specific language governing permissions and | |||||
* limitations under the License. | |||||
* | |||||
*/ | |||||
package org.apache.tools.ant.listener; | |||||
import org.apache.tools.ant.BuildEvent; | |||||
import org.apache.tools.ant.DefaultLogger; | |||||
/** | |||||
* A logger which logs nothing but build failure and what task might output | |||||
* | |||||
* @since 1.9.0 | |||||
*/ | |||||
public class SilentLogger extends DefaultLogger { | |||||
public void buildStarted(BuildEvent event) { | |||||
// log nothing | |||||
} | |||||
public void buildFinished(BuildEvent event) { | |||||
if (event.getException() != null) { | |||||
super.buildFinished(event); | |||||
} | |||||
} | |||||
public void targetStarted(BuildEvent event) { | |||||
// log nothing | |||||
} | |||||
public void targetFinished(BuildEvent event) { | |||||
// log nothing | |||||
} | |||||
public void taskStarted(BuildEvent event) { | |||||
// log nothing | |||||
} | |||||
public void taskFinished(BuildEvent event) { | |||||
// log nothing | |||||
} | |||||
} |