Bug 59379 - Get task not quiet if dest file exists
Summary: Get task not quiet if dest file exists
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.9.6
Hardware: PC other
: P2 normal (vote)
Target Milestone: 1.9.8
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-26 17:14 UTC by J. Lewis Muir
Modified: 2016-05-01 04:42 UTC (History)
0 users



Attachments
Test case (328 bytes, text/xml)
2016-04-26 17:14 UTC, J. Lewis Muir
Details
Fix (695 bytes, patch)
2016-04-26 17:15 UTC, J. Lewis Muir
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description J. Lewis Muir 2016-04-26 17:14:49 UTC
Created attachment 33806 [details]
Test case

# Overview

The Get task is not quiet when the `dest' file exists and the `quiet' and `skipexisting' attributes are set to `true'; it displays a message like this:

[get] Destination already exists (skipping): /tmp/ant-get-test/mylib.jar

# Steps to Reproduce

1. Save the attached build.xml file to the directory /tmp/ant-get-test (or wherever)

2. Run Ant in the directory:

   $ ant

# Actual Results

Buildfile: /tmp/ant-get-test/build.xml

build:
    [touch] Creating /tmp/ant-get-test/mylib.jar
      [get] Destination already exists (skipping): /tmp/ant-get-test/mylib.jar

BUILD SUCCESSFUL
Total time: 0 seconds

# Expected Results

The Get task should not write the message about the destination file already existing because the `quiet' attribute is set to `true':

Buildfile: /tmp/ant-get-test/build.xml

build:
    [touch] Creating /tmp/ant-get-test/mylib.jar

BUILD SUCCESSFUL
Total time: 0 seconds

# Build Date & Hardware

Ant 1.9.6 on OS X El Capitan (10.11.4).

# Additional Builds and Platforms

I haven't tested on other platforms, but the problem probably exists everywhere.

# Additional Information

Looking at the source code for the Get task from the Git master branch, it seems like one fix would be to only call the `log' method if the `quiet' attribute is not set to `true' as in the attached get-quiet-skip-existing.diff (untested).

Another approach would be to change the `log(String, int)' method to use a different conditional for the `msgLevel' test.  Right now, it uses `msgLevel >= Project.MSG_ERR', but in Project, MSG_ERR, MSG_WARN, MSG_INFO, MSG_VERBOSE, and MSG_DEBUG are set to 0-4, respectively, so the `msgLevel >= Project.MSG_ERR' test will always evaluate to true (and hence the super.log call will always be made) unless a value less than 0 is specified (i.e. not one of the Project class constants).
Comment 1 J. Lewis Muir 2016-04-26 17:15:47 UTC
Created attachment 33807 [details]
Fix
Comment 2 Stefan Bodewig 2016-05-01 04:42:35 UTC
Thank you!

I've opted to fix the logic inside the log method as the intend was to suppress anything less severe than ERR - and it now does with commit 647bdfb - will be fixed in 1.9.8 and 1.10.0.