Bug 47303

Summary: Copy failonerror is internally inconsistent with Warning message
Product: Ant Reporter: dsuits
Component: Core tasksAssignee: Ant Notifications List <notifications>
Status: NEW ---    
Severity: trivial    
Priority: P2    
Version: 1.7.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows Server 2003   

Description dsuits 2009-06-02 17:19:51 UTC
org.apache.tools.ant.taskdefs.Copy.copySingleFile()

If the source file does not exist, the following log is executed:

                String message = "Warning: Could not find file "
                    + file.getAbsolutePath() + " to copy.";
                if (!failonerror) {
                    log(message, Project.MSG_ERR);
                } else {
                    throw new BuildException(message);
                }

This is inconsistent and misleading.  If it is an error for the file to be missing, then the message is incorrect "Warning:" should be spelled "Error:".  If instead the intent of failonerror is to convert errors to warnings, then the message priority should be Project.MSG_WARN.
Comment 1 Stefan Bodewig 2009-06-03 08:23:19 UTC
There are other places where the code says "Warning" and logs it as ERR in
Copy (lines 441, 504 and 519 in trunk).

While I agree this looks confusing I don't really think we should change it at all.
The change is really more of a cosmetic one and there might be code out there
scanning for the word "Warning".
Comment 2 dsuits 2009-06-03 11:06:29 UTC
The documentation available here:
apache-ant-1.7.1-src.zip/apache-ant-1.7.1/docs/manual/CoreTasks/copy.html


"If false, log a warning message, but do not stop the build, when the file to copy does not exist or one of the nested filesets points to a directory that doesn't exist or an error occurs while copying."

So build script developers are being told to expect a warning, but BuildEvent consumers (custom BuildListeners) are receiving an error to process.