Maven:如何检查工件是否已安装到本地存储库

时间:2017-04-06 12:31:21

标签: maven build-tools

我正在编写shell脚本,如果尚未安装它,应该安装它。

是否存在类似mvn install:check artifact-name的内容?

我正在使用:Apache Maven 3.3.9

1 个答案:

答案 0 :(得分:1)

You can try with dependenct:get in offline mode and specify your repository, the command has the following structure:

mvn dependency:get -Dartifact={groupId}:{artifactId}:{version} -o -DrepoUrl=file://your/repo/path

For example:

mvn dependency:get -Dartifact=junit:junit:4.10 -o -DrepoUrl=file://~/.m2/repository

If it finds the dependency, then you will get:

[INFO] BUILD SUCCESS