我想仅更新“ groupA”的依赖项。如何使用命令行执行此操作?
<dependency>
<groupId>group-A</groupId>
<artifactId>artifact-1</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>group-A</groupId>
<artifactId>artifact-2</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>group-B</groupId>
<artifactId>artifact-1</artifactId>
<version>1.0.0</version>
</dependency>
答案 0 :(得分:0)
版本插件的目标“ use-latest-versions”似乎可以满足您的需求。
假设您有类似的东西:
<dependencies>
<dependency>
<groupId>group-B</groupId>
<artifactId>artifact-1</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.9</version>
</dependency>
</dependencies>
然后运行:mvn versions:use-latest-versions -D"includes=org.apache.commons:*:*:*:*"
将更新该组中的这两个依赖项:
[INFO] --- versions-maven-plugin:2.7:use-latest-versions (default-cli) @ artifact-id ---
[INFO] Major version changes allowed
[INFO] Updated org.apache.commons:commons-lang3:jar:3.1 to version 3.9
[INFO] artifact org.apache.commons:commons-compress: checking for updates from central
[INFO] Updated org.apache.commons:commons-compress:jar:1.9 to version 1.18
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
假设您只需要可以在存储库中找到的最新版本。 versions plugin还提供其他一些功能。对于依赖项工作,dependency plugin通常也很方便。