Lucas
Lucas

Reputation: 14979

Execute maven goal without a project

I have some automation that uses mvn to download artifacts to a local filesystem so they can be used outside of maven. Basically, I do something like this:

#!/bin/bash
mvn dependency:get \
    -DgroupId="my.group.id" \
    -DartifactId="$1" \
    -Dversion="$2" \
    -Dpackaging="war" \
    -DremoteRepositories="http://my.repo/nexus/content/repositories/foo"

The problem (and its not really a problem) is that I get the following output:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building some-other-project 1.2.7-SNAPSHOT
[INFO] ------------------------------------------------------------------------

If I happen to run this from a sub folder of some-other-project. This is confusing to the person running this script as the dependency:get execution does not actually build the project. Short of capturing and processing the output to strip that info, is there a simple way to tell mvn that it is just running a goal without an associated project?

Upvotes: 1

Views: 323

Answers (2)

Robert Scholte
Robert Scholte

Reputation: 12345

If there's a pom.xml, it'll always be used; it could contain extra information for the maven-dependency-plugin. So no, there's no option to ignore this Building ... message. Even trying to refer to a non-existing pom-file ( -f no-pom.xml ) doesn't help, because Maven now assumes this file exists.

Upvotes: -1

Ivan
Ivan

Reputation: 3836

You can suppress all INFO output by passing --quiet flag (or -q).

If you'd like to have some INFO's while dropping the rest, you can identify all the components you'd like to silence by doing searches against Maven github and configure the logging properties to exclude those.

E.g. you can add the following flag: -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.event.ExecutionEventLogger=ERROR for that Scanning for projects... message.

Upvotes: 3

Related Questions