git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271951 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -127,6 +127,7 @@ public class Ant1CompatProject extends Project | |||
| m_context.info( msg ); | |||
| break; | |||
| case Ant1CompatProject.MSG_VERBOSE: | |||
| m_context.verbose( msg ); | |||
| case Ant1CompatProject.MSG_DEBUG: | |||
| m_context.debug( msg ); | |||
| } | |||
| @@ -43,7 +43,7 @@ public abstract class Pack | |||
| { | |||
| validate(); | |||
| final String message = "Building: " + m_zipFile.getAbsolutePath(); | |||
| getContext().info( message ); | |||
| getContext().verbose( message ); | |||
| pack(); | |||
| } | |||
| @@ -52,7 +52,7 @@ public abstract class Unpack | |||
| { | |||
| final String message = "Expanding " + src.getAbsolutePath() + | |||
| " to " + dest.getAbsolutePath(); | |||
| getContext().info( message ); | |||
| getContext().verbose( message ); | |||
| extract(); | |||
| } | |||
| @@ -207,7 +207,6 @@ public class Checksum | |||
| { | |||
| final String message = "Could not find file " + file.getAbsolutePath() + | |||
| " to generate checksum for."; | |||
| getContext().info( message ); | |||
| throw new TaskException( message ); | |||
| } | |||
| } | |||
| @@ -225,7 +224,7 @@ public class Checksum | |||
| { | |||
| final File src = (File)includes.nextElement(); | |||
| final String message = "Calculating " + m_algorithm + " checksum for " + src; | |||
| getContext().info( message ); | |||
| getContext().verbose( message ); | |||
| checksumMatches = z( src, checksumMatches ); | |||
| } | |||
| @@ -28,7 +28,7 @@ public class Log | |||
| /** | |||
| * The level at which to print out messages. | |||
| */ | |||
| private LogLevel m_level = LogLevel.WARN; | |||
| private LogLevel m_level = LogLevel.INFO; | |||
| /** | |||
| * Set the level at which the message will be logged. | |||
| @@ -35,7 +35,7 @@ public class PropertyDump | |||
| { | |||
| final String key = (String)iterator.next(); | |||
| final Object value = properties.get( key ); | |||
| getContext().warn( key + "=" + value ); | |||
| getContext().info( key + "=" + value ); | |||
| } | |||
| } | |||
| } | |||
| @@ -328,7 +328,7 @@ public class CopyTask | |||
| { | |||
| final String message = | |||
| REZ.getString( "copy.selfcopy-ignored.notice", source ); | |||
| getContext().info( message ); | |||
| getContext().verbose( message ); | |||
| continue; | |||
| } | |||
| @@ -336,7 +336,7 @@ public class CopyTask | |||
| { | |||
| final String message = | |||
| REZ.getString( "copy.filecopy.notice", source, destination ); | |||
| getContext().info( message ); | |||
| getContext().verbose( message ); | |||
| doOperation( source, destination ); | |||
| } | |||
| @@ -43,7 +43,7 @@ public class ListPathTask | |||
| for( int i = 0; i < files.length; i++ ) | |||
| { | |||
| final String file = files[ i ]; | |||
| getContext().warn( file ); | |||
| getContext().info( file ); | |||
| } | |||
| } | |||
| } | |||
| @@ -21,67 +21,67 @@ public class PrimitiveTypesTest | |||
| { | |||
| public void setInteger( final Integer value ) | |||
| { | |||
| getContext().warn( "setInteger( " + value + " );" ); | |||
| getContext().info( "setInteger( " + value + " );" ); | |||
| } | |||
| public void setInteger2( final int value ) | |||
| { | |||
| getContext().warn( "setInteger2( " + value + " );" ); | |||
| getContext().info( "setInteger2( " + value + " );" ); | |||
| } | |||
| public void setShort( final Short value ) | |||
| { | |||
| getContext().warn( "setShort( " + value + " );" ); | |||
| getContext().info( "setShort( " + value + " );" ); | |||
| } | |||
| public void setShort2( final short value ) | |||
| { | |||
| getContext().warn( "setShort2( " + value + " );" ); | |||
| getContext().info( "setShort2( " + value + " );" ); | |||
| } | |||
| public void setByte( final Byte value ) | |||
| { | |||
| getContext().warn( "setByte( " + value + " );" ); | |||
| getContext().info( "setByte( " + value + " );" ); | |||
| } | |||
| public void setByte2( final byte value ) | |||
| { | |||
| getContext().warn( "setByte2( " + value + " );" ); | |||
| getContext().info( "setByte2( " + value + " );" ); | |||
| } | |||
| public void setLong( final Long value ) | |||
| { | |||
| getContext().warn( "setLong( " + value + " );" ); | |||
| getContext().info( "setLong( " + value + " );" ); | |||
| } | |||
| public void setLong2( final long value ) | |||
| { | |||
| getContext().warn( "setLong2( " + value + " );" ); | |||
| getContext().info( "setLong2( " + value + " );" ); | |||
| } | |||
| public void setFloat( final Float value ) | |||
| { | |||
| getContext().warn( "setFloat( " + value + " );" ); | |||
| getContext().info( "setFloat( " + value + " );" ); | |||
| } | |||
| public void setFloat2( final float value ) | |||
| { | |||
| getContext().warn( "setFloat2( " + value + " );" ); | |||
| getContext().info( "setFloat2( " + value + " );" ); | |||
| } | |||
| public void setDouble( final Double value ) | |||
| { | |||
| getContext().warn( "setDouble( " + value + " );" ); | |||
| getContext().info( "setDouble( " + value + " );" ); | |||
| } | |||
| public void setDouble2( final double value ) | |||
| { | |||
| getContext().warn( "setDouble2( " + value + " );" ); | |||
| getContext().info( "setDouble2( " + value + " );" ); | |||
| } | |||
| public void setString( final String value ) | |||
| { | |||
| getContext().warn( "setString( " + value + " );" ); | |||
| getContext().info( "setString( " + value + " );" ); | |||
| } | |||
| public void execute() | |||
| @@ -113,7 +113,7 @@ public class CopyFilesTask | |||
| m_destFile = m_destDir.resolveFile( m_srcFile.getName().getBaseName() ); | |||
| } | |||
| getContext().info( "copy " + m_srcFile + " to " + m_destFile ); | |||
| getContext().verbose( "copy " + m_srcFile + " to " + m_destFile ); | |||
| m_destFile.copy( m_srcFile ); | |||
| } | |||
| @@ -141,7 +141,7 @@ public class CopyFilesTask | |||
| final FileObject destFile = m_destDir.resolveFile( path, NameScope.DESCENDENT ); | |||
| // Copy the file across | |||
| getContext().info( "copy " + srcFile + " to " + destFile ); | |||
| getContext().verbose( "copy " + srcFile + " to " + destFile ); | |||
| destFile.copy( srcFile ); | |||
| } | |||
| } | |||
| @@ -251,7 +251,6 @@ public class XSLTProcess | |||
| catch( final Exception e ) | |||
| { | |||
| final String message = "Failed to read stylesheet " + m_stylesheet; | |||
| getContext().info( message ); | |||
| throw new TaskException( e.getMessage(), e ); | |||
| } | |||
| } | |||
| @@ -122,6 +122,28 @@ public interface TaskContext | |||
| */ | |||
| boolean isDebugEnabled(); | |||
| /** | |||
| * Log a verbose message. | |||
| * | |||
| * @param message the message | |||
| */ | |||
| void verbose( String message ); | |||
| /** | |||
| * Log a verbose message. | |||
| * | |||
| * @param message the message | |||
| * @param throwable the throwable | |||
| */ | |||
| void verbose( String message, Throwable throwable ); | |||
| /** | |||
| * Determine if messages of priority "verbose" will be logged. | |||
| * | |||
| * @return true if "verbose" messages will be logged | |||
| */ | |||
| boolean isVerboseEnabled(); | |||
| /** | |||
| * Log a info message. | |||
| * | |||
| @@ -242,6 +242,37 @@ public class DefaultTaskContext | |||
| return m_logger.isDebugEnabled(); | |||
| } | |||
| /** | |||
| * Log a verbose message. | |||
| * | |||
| * @param message the message | |||
| */ | |||
| public void verbose( String message ) | |||
| { | |||
| m_logger.info( message ); | |||
| } | |||
| /** | |||
| * Log a verbose message. | |||
| * | |||
| * @param message the message | |||
| * @param throwable the throwable | |||
| */ | |||
| public void verbose( String message, Throwable throwable ) | |||
| { | |||
| m_logger.info( message, throwable ); | |||
| } | |||
| /** | |||
| * Determine if messages of priority "verbose" will be logged. | |||
| * | |||
| * @return true if "verbose" messages will be logged | |||
| */ | |||
| public boolean isVerboseEnabled() | |||
| { | |||
| return m_logger.isInfoEnabled(); | |||
| } | |||
| /** | |||
| * Log a info message. | |||
| * | |||
| @@ -249,7 +280,7 @@ public class DefaultTaskContext | |||
| */ | |||
| public void info( final String message ) | |||
| { | |||
| m_logger.info( message ); | |||
| m_logger.warn( message ); | |||
| } | |||
| /** | |||
| @@ -260,7 +291,7 @@ public class DefaultTaskContext | |||
| */ | |||
| public void info( final String message, final Throwable throwable ) | |||
| { | |||
| m_logger.info( message, throwable ); | |||
| m_logger.warn( message, throwable ); | |||
| } | |||
| /** | |||
| @@ -270,7 +301,7 @@ public class DefaultTaskContext | |||
| */ | |||
| public boolean isInfoEnabled() | |||
| { | |||
| return m_logger.isInfoEnabled(); | |||
| return m_logger.isWarnEnabled(); | |||
| } | |||
| /** | |||
| @@ -280,7 +311,7 @@ public class DefaultTaskContext | |||
| */ | |||
| public void warn( final String message ) | |||
| { | |||
| m_logger.warn( message ); | |||
| m_logger.error( message ); | |||
| } | |||
| /** | |||
| @@ -291,7 +322,7 @@ public class DefaultTaskContext | |||
| */ | |||
| public void warn( final String message, final Throwable throwable ) | |||
| { | |||
| m_logger.warn( message, throwable ); | |||
| m_logger.error( message, throwable ); | |||
| } | |||
| /** | |||
| @@ -301,7 +332,7 @@ public class DefaultTaskContext | |||
| */ | |||
| public boolean isWarnEnabled() | |||
| { | |||
| return m_logger.isWarnEnabled(); | |||
| return m_logger.isErrorEnabled(); | |||
| } | |||
| /** | |||
| @@ -311,7 +342,7 @@ public class DefaultTaskContext | |||
| */ | |||
| public void error( final String message ) | |||
| { | |||
| m_logger.error( message ); | |||
| m_logger.fatalError( message ); | |||
| } | |||
| /** | |||
| @@ -322,7 +353,7 @@ public class DefaultTaskContext | |||
| */ | |||
| public void error( final String message, final Throwable throwable ) | |||
| { | |||
| m_logger.error( message, throwable ); | |||
| m_logger.fatalError( message, throwable ); | |||
| } | |||
| /** | |||
| @@ -332,7 +363,7 @@ public class DefaultTaskContext | |||
| */ | |||
| public boolean isErrorEnabled() | |||
| { | |||
| return m_logger.isErrorEnabled(); | |||
| return m_logger.isFatalErrorEnabled(); | |||
| } | |||
| /** | |||
| @@ -189,11 +189,11 @@ public class Execute | |||
| final TaskContext context ) | |||
| throws TaskException | |||
| { | |||
| if( context.isInfoEnabled() ) | |||
| if( context.isVerboseEnabled() ) | |||
| { | |||
| final String cmdline = FileUtils.formatCommandLine( metaData.getCommand() ); | |||
| final String message = REZ.getString( "execute.command.notice", cmdline ); | |||
| context.info( message ); | |||
| context.verbose( message ); | |||
| } | |||
| if( context.isDebugEnabled() ) | |||
| { | |||
| @@ -26,10 +26,10 @@ public final class LogLevel | |||
| private final static HashMap c_levels = new HashMap(); | |||
| //standard enums for version of JVM | |||
| public final static LogLevel FATAL_ERROR = new LogLevel( "fatalError" ); | |||
| public final static LogLevel ERROR = new LogLevel( "error" ); | |||
| public final static LogLevel WARN = new LogLevel( "warn" ); | |||
| public final static LogLevel INFO = new LogLevel( "info" ); | |||
| public final static LogLevel VERBOSE = new LogLevel( "verbose" ); | |||
| public final static LogLevel DEBUG = new LogLevel( "debug" ); | |||
| /** | |||
| @@ -64,18 +64,22 @@ public final class LogLevel | |||
| final LogLevel level, | |||
| final String message ) | |||
| { | |||
| if( LogLevel.ERROR == level ) | |||
| if( ERROR == level ) | |||
| { | |||
| context.error( message ); | |||
| } | |||
| else if( LogLevel.WARN == level ) | |||
| else if( WARN == level ) | |||
| { | |||
| context.warn( message ); | |||
| } | |||
| else if( LogLevel.INFO == level ) | |||
| else if( INFO == level ) | |||
| { | |||
| context.info( message ); | |||
| } | |||
| else if( VERBOSE == level ) | |||
| { | |||
| context.verbose( message ); | |||
| } | |||
| else | |||
| { | |||
| context.debug( message ); | |||
| @@ -94,18 +98,22 @@ public final class LogLevel | |||
| final String message, | |||
| final Throwable throwable ) | |||
| { | |||
| if( LogLevel.ERROR == level ) | |||
| if( ERROR == level ) | |||
| { | |||
| context.error( message, throwable ); | |||
| } | |||
| else if( LogLevel.WARN == level ) | |||
| else if( WARN == level ) | |||
| { | |||
| context.warn( message, throwable ); | |||
| } | |||
| else if( LogLevel.INFO == level ) | |||
| else if( INFO == level ) | |||
| { | |||
| context.info( message, throwable ); | |||
| } | |||
| else if( VERBOSE == level ) | |||
| { | |||
| context.verbose( message, throwable ); | |||
| } | |||
| else | |||
| { | |||
| context.debug( message, throwable ); | |||
| @@ -33,9 +33,7 @@ public class LoggingExecOutputHandler | |||
| */ | |||
| public void stdout( final String line ) | |||
| { | |||
| // TODO - should be using info(), but currently that is only used | |||
| // when ant is run in verbose mode | |||
| m_context.warn( line ); | |||
| m_context.info( line ); | |||
| } | |||
| /** | |||
| @@ -223,11 +223,14 @@ public class ExecuteJava | |||
| final String[] args = m_args.getArguments(); | |||
| // Log message | |||
| final String debugMessage | |||
| = REZ.getString( "executejava.exec-in-jvm.notice", | |||
| m_className, | |||
| FileUtils.formatCommandLine( args ) ); | |||
| context.info( debugMessage ); | |||
| if( context.isVerboseEnabled() ) | |||
| { | |||
| final String debugMessage | |||
| = REZ.getString( "executejava.exec-in-jvm.notice", | |||
| m_className, | |||
| FileUtils.formatCommandLine( args ) ); | |||
| context.verbose( debugMessage ); | |||
| } | |||
| // Locate the class | |||
| final Class target; | |||
| @@ -160,7 +160,7 @@ public class Get extends AbstractTask | |||
| if( verbose ) | |||
| { | |||
| Date t = new Date( timestamp ); | |||
| getContext().info( "local file date : " + t.toString() ); | |||
| getContext().verbose( "local file date : " + t.toString() ); | |||
| } | |||
| hasTimestamp = true; | |||
| @@ -206,7 +206,7 @@ public class Get extends AbstractTask | |||
| //not modified so no file download. just return instead | |||
| //and trace out something so the user doesn't think that the | |||
| //download happened when it didnt | |||
| getContext().info( "Not modified - so not downloaded" ); | |||
| getContext().verbose( "Not modified - so not downloaded" ); | |||
| return; | |||
| } | |||
| // test for 401 result (HTTP only) | |||
| @@ -273,8 +273,8 @@ public class Get extends AbstractTask | |||
| if( verbose ) | |||
| { | |||
| Date t = new Date( remoteTimestamp ); | |||
| getContext().info( "last modified = " + t.toString() | |||
| + ( ( remoteTimestamp == 0 ) ? " - using current time instead" : "" ) ); | |||
| getContext().verbose( "last modified = " + t.toString() | |||
| + ( ( remoteTimestamp == 0 ) ? " - using current time instead" : "" ) ); | |||
| } | |||
| if( remoteTimestamp != 0 ) | |||
| @@ -156,7 +156,7 @@ public class JJTree | |||
| targetName.substring( 0, targetName.indexOf( ".jjt" ) ) + ".jj" ); | |||
| if( javaFile.exists() && target.lastModified() < javaFile.lastModified() ) | |||
| { | |||
| getContext().info( "Target is already built - skipping (" + target + ")" ); | |||
| getContext().verbose( "Target is already built - skipping (" + target + ")" ); | |||
| return; | |||
| } | |||
| exe.getArguments().addArgument( target ); | |||
| @@ -810,8 +810,6 @@ public class Javadoc | |||
| } | |||
| getContext().debug( "Javadoc args: " + cmd ); | |||
| getContext().info( "Javadoc execution" ); | |||
| final Execute exe = new Execute(); | |||
| exe.setExecOutputHandler( this ); | |||
| @@ -1025,7 +1023,7 @@ public class Javadoc | |||
| { | |||
| if( line.startsWith( "Generating " ) || line.startsWith( "Building " ) ) | |||
| { | |||
| getContext().debug( line ); | |||
| getContext().verbose( line ); | |||
| } | |||
| else | |||
| { | |||
| @@ -229,7 +229,6 @@ public class JDependTask | |||
| catch( IOException e ) | |||
| { | |||
| String msg = "JDepend Failed when creating the output file: " + e.getMessage(); | |||
| getContext().info( msg ); | |||
| throw new TaskException( msg ); | |||
| } | |||
| jdepend.setWriter( new PrintWriter( fw ) ); | |||
| @@ -245,7 +244,6 @@ public class JDependTask | |||
| if( !f.exists() || !f.isDirectory() ) | |||
| { | |||
| String msg = "\"" + f.getPath() + "\" does not represent a valid directory. JDepend would fail."; | |||
| getContext().info( msg ); | |||
| throw new TaskException( msg ); | |||
| } | |||
| try | |||
| @@ -255,7 +253,6 @@ public class JDependTask | |||
| catch( IOException e ) | |||
| { | |||
| String msg = "JDepend Failed when adding a source directory: " + e.getMessage(); | |||
| getContext().info( msg ); | |||
| throw new TaskException( msg ); | |||
| } | |||
| } | |||
| @@ -408,11 +408,11 @@ public class JspC extends MatchingTask | |||
| { | |||
| if( filecount == 0 ) | |||
| { | |||
| getContext().info( "there were no files to compile" ); | |||
| getContext().verbose( "there were no files to compile" ); | |||
| } | |||
| else | |||
| { | |||
| getContext().debug( "all files are up to date" ); | |||
| getContext().verbose( "all files are up to date" ); | |||
| } | |||
| } | |||
| } | |||
| @@ -266,7 +266,7 @@ public class MParse | |||
| File javaFile = new File( pathname ); | |||
| if( javaFile.exists() && m_target.lastModified() < javaFile.lastModified() ) | |||
| { | |||
| getContext().info( "Target is already build - skipping (" + m_target + ")" ); | |||
| getContext().verbose( "Target is already build - skipping (" + m_target + ")" ); | |||
| return; | |||
| } | |||
| @@ -325,7 +325,7 @@ public class MParse | |||
| final File sunjj = new File( m_target.getParent(), name ); | |||
| if( sunjj.exists() ) | |||
| { | |||
| getContext().info( "Removing stale file: " + sunjj.getName() ); | |||
| getContext().debug( "Removing stale file: " + sunjj.getName() ); | |||
| sunjj.delete(); | |||
| } | |||
| } | |||
| @@ -411,7 +411,7 @@ public class FTP | |||
| if( m_verbose ) | |||
| { | |||
| getContext().info( "transferring " + filename + " to " + file.getAbsolutePath() ); | |||
| getContext().verbose( "transferring " + filename + " to " + file.getAbsolutePath() ); | |||
| } | |||
| final File parent = file.getParentFile(); | |||
| @@ -581,7 +581,7 @@ public class FTP | |||
| { | |||
| if( m_verbose ) | |||
| { | |||
| getContext().info( "deleting " + filename ); | |||
| getContext().verbose( "deleting " + filename ); | |||
| } | |||
| if( !ftp.deleteFile( remoteResolveFile( filename ) ) ) | |||
| @@ -616,7 +616,7 @@ public class FTP | |||
| { | |||
| if( m_verbose ) | |||
| { | |||
| getContext().info( "listing " + filename ); | |||
| getContext().verbose( "listing " + filename ); | |||
| } | |||
| FTPFile ftpfile = ftp.listFiles( remoteResolveFile( filename ) )[ 0 ]; | |||
| @@ -639,7 +639,7 @@ public class FTP | |||
| { | |||
| if( m_verbose ) | |||
| { | |||
| getContext().info( "creating directory: " + dir ); | |||
| getContext().verbose( "creating directory: " + dir ); | |||
| } | |||
| if( !ftp.makeDirectory( dir ) ) | |||
| @@ -657,14 +657,14 @@ public class FTP | |||
| if( m_verbose ) | |||
| { | |||
| getContext().info( "directory already exists" ); | |||
| getContext().verbose( "directory already exists" ); | |||
| } | |||
| } | |||
| else | |||
| { | |||
| if( m_verbose ) | |||
| { | |||
| getContext().info( "directory created OK" ); | |||
| getContext().verbose( "directory created OK" ); | |||
| } | |||
| } | |||
| } | |||
| @@ -715,7 +715,7 @@ public class FTP | |||
| if( m_verbose ) | |||
| { | |||
| getContext().info( "transferring " + file.getAbsolutePath() ); | |||
| getContext().verbose( "transferring " + file.getAbsolutePath() ); | |||
| } | |||
| instream = new BufferedInputStream( new FileInputStream( file ) ); | |||
| @@ -165,7 +165,7 @@ public class P4Add extends P4Base | |||
| if( getContext().isInfoEnabled() ) | |||
| { | |||
| final String message = "Execing add " + m_p4CmdOpts + " " + addCmd + list; | |||
| getContext().info( message ); | |||
| getContext().verbose( message ); | |||
| } | |||
| final String command = "-s add " + m_p4CmdOpts + " " + addCmd + list; | |||
| @@ -150,11 +150,11 @@ public abstract class DefaultRmicAdapter | |||
| if( attributes.getIiop() ) | |||
| { | |||
| getTaskContext().info( "IIOP has been turned on." ); | |||
| getTaskContext().verbose( "IIOP has been turned on." ); | |||
| cmd.addArgument( "-iiop" ); | |||
| if( attributes.getIiopopts() != null ) | |||
| { | |||
| getTaskContext().info( "IIOP Options: " + attributes.getIiopopts() ); | |||
| getTaskContext().verbose( "IIOP Options: " + attributes.getIiopopts() ); | |||
| cmd.addArgument( attributes.getIiopopts() ); | |||
| } | |||
| } | |||
| @@ -162,11 +162,11 @@ public abstract class DefaultRmicAdapter | |||
| if( attributes.getIdl() ) | |||
| { | |||
| cmd.addArgument( "-idl" ); | |||
| getTaskContext().info( "IDL has been turned on." ); | |||
| getTaskContext().verbose( "IDL has been turned on." ); | |||
| if( attributes.getIdlopts() != null ) | |||
| { | |||
| cmd.addArgument( attributes.getIdlopts() ); | |||
| getTaskContext().info( "IDL Options: " + attributes.getIdlopts() ); | |||
| getTaskContext().verbose( "IDL Options: " + attributes.getIdlopts() ); | |||
| } | |||
| } | |||
| @@ -475,7 +475,7 @@ public class Rmic extends MatchingTask | |||
| if( verify ) | |||
| { | |||
| getContext().info( "Verify has been turned on." ); | |||
| getContext().verbose( "Verify has been turned on." ); | |||
| } | |||
| String compiler = getContext().getProperty( "build.rmic" ).toString(); | |||
| @@ -310,7 +310,7 @@ public class ReplaceRegExp | |||
| ( byline ? " by line" : "" ) + | |||
| ( flags.length() > 0 ? " with flags: '" + flags + "'" : "" ) + | |||
| "."; | |||
| getContext().warn( message ); | |||
| getContext().info( message ); | |||
| if( byline ) | |||
| { | |||