简体   繁体   English

在没有项目的情况下执行Maven目标

[英]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. 我有一些使用mvn自动化程序,可以将工件下载到本地文件系统,以便可以在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 . 如果我碰巧从some-other-project的子文件夹中运行它。 This is confusing to the person running this script as the dependency:get execution does not actually build the project. 这对运行此脚本的人员造成了困扰,因为其dependency:get执行dependency:get实际上并未生成项目。 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? 缺少捕获和处理输出以剥离该信息的方法,是否有一种简单的方法告诉mvn它只是在没有相关项目的情况下运行目标?

You can suppress all INFO output by passing --quiet flag (or -q ). 您可以通过传递--quiet标志(或-q )来禁止显示所有INFO输出。

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. 如果您希望在删除其余INFO有一些INFO ,则可以通过对Maven github进行搜索并配置日志记录属性以排除这些内容,从而确定要静音的所有组件。

Eg you can add the following flag: -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.event.ExecutionEventLogger=ERROR for that Scanning for projects... message. 例如,您可以添加以下标志: -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.event.ExecutionEventLogger=ERROR ,表示正在Scanning for projects...消息。

If there's a pom.xml , it'll always be used; 如果有pom.xml ,将始终使用它; it could contain extra information for the maven-dependency-plugin. 它可能包含有关maven-dependency-plugin的其他信息。 So no, there's no option to ignore this Building ... message. 因此,没有,没有选择可以忽略此Building ...消息。 Even trying to refer to a non-existing pom-file ( -f no-pom.xml ) doesn't help, because Maven now assumes this file exists. 甚至尝试引用不存在的pom文件( -f no-pom.xml )也无济于事,因为Maven现在假定该文件存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM