232

In our company in the CI machines maven local repository is purged before every build. As result my build logs always have a bunch of noise like this

Downloading: http://.../artifactory/repo/com/codahale/metrics/metrics-core/3.0.1/metrics-core-3.0.1.jar
4/2122 KB   
8/2122 KB   
12/2122 KB   
16/2122 KB   
18/2122 KB   
18/2122 KB   4/480 KB   
18/2122 KB   8/480 KB   
18/2122 KB   12/480 KB   
18/2122 KB   16/480 KB   
18/2122 KB   16/480 KB   4/1181 KB   
18/2122 KB   16/480 KB   8/1181 KB   
18/2122 KB   16/480 KB   12/1181 KB

Is there an option I to be able to disable the download progress indication?

gsf
  • 6,612
  • 7
  • 35
  • 64

7 Answers7

298

mvn -B .. or mvn --batch-mode ... will do the trick.

Update

mernst
  • 7,437
  • 30
  • 45
khmarbaise
  • 92,914
  • 28
  • 189
  • 235
  • 8
    thank you, this did it, can I get rid of downloading/downloaded lines too? – gsf Feb 07 '14 at 22:49
  • You can try `mvn -q` but than you will don't see other message as well. May be you can take a look [here](http://maven.apache.org/maven-logging.html). – khmarbaise Feb 08 '14 at 09:34
  • 1
    mvn --batch-mode ... | grep -v 'Download.* http://' is what I sometimes use to get rid of the download* messages. – Lars Kiesow Oct 16 '14 at 17:47
  • 1
    Does it work for all versions of maven? It seems in my case (version 2.0.4), maven still print ugly "downloaded..." lines regardless adding -B flag. – Kamil Jul 27 '16 at 08:15
  • Seems pretty well documented to me... https://maven.apache.org/maven-release/maven-release-plugin/examples/non-interactive-release.html – Barett Dec 19 '17 at 20:21
  • 4
    @Barett the link you provided is only documentation of the release-plugin. It does not mention at all how `--batch-mode` affects output. – Superole Feb 27 '18 at 13:06
  • 1
    This solution suppresses upload messages as well as downloads, which is usually not desired in a `deploy` task – Hilikus Jun 12 '20 at 17:08
  • @Hilikus The usage of `--no-transfer-progress` will suppress the output by default. In case of errors they will be shown. Apart from that I don't understand the relationship to `deploy`? Where is the difference to download? – khmarbaise Jun 14 '20 at 21:47
  • 4
    the question is asking specifically about suppressing download noise, which is very verbose with maven. My point is that your solution has an unintended side-effect: It also disables upload logs in the deploy plugin so for example you can't see to which repo you *really* deployed your artifacts – Hilikus Jun 15 '20 at 00:30
  • Maven 3.6.2: -B wasn't sufficient for me, but -ntp did suppress all the "Downloading / Downloaded" messages indeed – zeralight Aug 13 '21 at 06:53
85

First of all, as already answered by khmarbaise, you should use mvn -B to enable batch mode.

If you want also to get rid of the "Downloading/Downloaded" lines you can set the corresponding logger org.apache.maven.cli.transfer.Slf4jMavenTransferListener to a level higher than info. Therefore I used the org.slf4j.simpleLogger.log property as documented here.

Using only the command line, you can do this:

mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B ...

Or you can use the MAVEN_OPTS environment variable as described here:

export MAVEN_OPTS=-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn

Note: As far as I am aware this only works for maven 3.1 and above.

Naman
  • 27,789
  • 26
  • 218
  • 353
FelixRabe
  • 976
  • 7
  • 9
  • 7
    This is great. Can also add ``org.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn`` to $MAVEN_HOME/conf/logging/simplelogging.properties, to make it permanent. – Ben Nov 02 '16 at 17:33
  • 3
    This solution suppresses upload messages as well as downloads, which is usually not desired in a `deploy` task – Hilikus Jun 12 '20 at 17:08
  • It sets the level to WARN so you will still know if there's a problem. But I agree it would be nice to have a separate setting. – Olivier Gérardin Jun 14 '20 at 20:59
61

Starting with Maven 3.6.1, Maven now has an option to suppress the transfer progress when downloading/uploading in interactive mode.

mvn --no-transfer-progress ....

or in short:

mvn -ntp ... ....

The full release note can be found here: http://maven.apache.org/docs/3.6.1/release-notes.html

Rene Larsen
  • 1,178
  • 9
  • 16
7

Same as above answers, but you don't need to add options to command line everytime. Just add the lines into file ${maven.projectBasedir}/.mvn/maven.config:

--no-transfer-progress

Then you can use mvn as was:

mvn test
mvn deploy
aleung
  • 9,848
  • 3
  • 55
  • 69
5

Quick answer, use maven batch mode, add following to your maven command:

-B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn

For example:

mvn deploy -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
bladekp
  • 1,529
  • 22
  • 29
2

The only useful way to suppress downloading/downloaded messages is as follows:

mvn --batch-mode ... bla bla bla ... | grep -v 'Download.* http'

It is the only useful way because it does not suppress anything else, i.e. the uploading/uploaded [INFO] messages, which anyone in their right mind would want to keep.

Mike Nakis
  • 56,297
  • 11
  • 110
  • 142
1

I am using apache-maven-3.8.6. Adding --no-transfer-progress option to mvn works for me:

mvn --no-transfer-progress clean install

David W
  • 31
  • 3