maven - Maven:依赖项:解包/如何覆盖工件依赖项?
问题描述
我正在开发一个 maven 项目,该项目依赖于一些工件(此处命名为“artifact1”),它使用依赖项解决:解包:
pom.xml 提取:
<project>
[...]
<build>
<plugins>
[...]
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>unpack</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.xxx.xxx</groupId>
<artifactId>artifact1</artifactId>
<version>100.1.1</version>
<type>zip</type>
[...]
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
[...]
</build>
[...]
</project>
“artifact1”有它自己的依赖:
[INFO] +- com.xxx.xxx:artifact1:zip:100.1.1:compile
[INFO] | \- com.xxx.xxx:artifact2:zip:100.1.1:compile
[INFO] | +- com.xxx.xxx:xxx:artifact3:zip:100.1.1:compile
我正在寻找一种方法来覆盖“artifact3”的版本(让我们说版本 100.1.2)(不修改 artifact1 项目本身的任何内容)
预期结果,在上面使用 pom.xml 运行 mvn dependency:tree 并获取依赖树:
[INFO] +- com.xxx.xxx:artifact1:zip:100.1.1:compile
[INFO] | \- com.xxx.xxx:artifact2:zip:100.1.1:compile
[INFO] | +- com.xxx.xxx:xxx:artifact3:zip:100.1.2:compile
你知道是否有可能做到这一点?
提前致谢
解决方案
基本上 Maven 是一个构建工具,而不是一个部署工具。(它有一个deploy
阶段,但是除了开发人员本地机器上的本地存储库之外,它还用于将工件部署到远程 Maven 存储库。)
有些插件支持将任意文件部署到任意位置(间接):
- Exec Maven Plugin:“用于执行外部程序的插件。 ”
- GMavenPlus 插件:“一个 Maven 插件,允许您将 Groovy 集成到您的 Maven 项目中。 ”
- Maven AntRun 插件:“这个插件提供了在 Maven 中运行 Ant 任务的能力。 ”
一个支持直接部署,但它的 2.0.0 版本已经快两年了,我遇到了一些不适用于最新 Maven 版本的事情。但是,现在我看到两天前有一个 2.0.1:
Wagon Maven 插件:“使用这个插件来查看和使用 Maven Wagon 在存储库之间传输资源。 ”
(不要让“存储库之间”混淆您。它支持任意文件和 URL。)
推荐阅读
- ruby - Homebrew 警告:忽略 X,因为它的扩展未构建。试试: gem pristine X --version Y
- sql - 如何用 where 子句 group by with date 求和?
- javascript - 从另一个类中的函数获取返回值
- java - Java - 在 Web 服务调用上覆盖 WebRequest
- android - 如何在 TextInputLayout unfocus 中更改边框和颜色?
- c# - 为什么这个网络服务器会忽略我的 POST 请求,而是向我发送正常 GET 请求会得到的信息?
- reactjs - 在 map 函数中调用 useState 钩子导致无限循环
- reactjs - 对象不支持属性或方法“条目” - IE11 中的错误
- python-3.x - Python - 让用户输入一个函数
- excel - VBA 通过选择单元格在列表中打开 PDF