如何将 uber jar 依赖项下载到特定的本地位置/文件夹?



使用 shade im 将 uberjar 上传到存储库:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>myjar</shadedClassifierName>
</configuration>
</execution>
</executions>
</plugin>

然后我有另一个应用程序需要访问该罐子。我计划在其他应用程序存储库中只有一个 pom,并部署调用 mvn install 或任何脚本在本地下载 uber jar。我不确定如何下载超级罐子。

当我运行 mvn 安装时,此 POM 会在目标文件夹中创建一个blahblah-1.jar。我想要的是让它将 uber jar 拉到特定的目录中。如何在 pom 配置中执行此操作?我不想将特定的参数传递给 mvn- 我希望配置在 pom 中,这样我就可以执行类似mvn install的东西,它将 uber jar 依赖项拉到正确的目录中。我想对所有设置使用 pom,因为这意味着我的 CI\CD 服务器只需要为其他类似的应用程序调用相同的命令,并且设置将在 pom 中

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>derps</groupId>
<artifactId>blahblah</artifactId>
<version>1</version>
<!-- Retrieve artifacts from internal repo -->
<repositories>
<repository>
<id>myrepo</id>
<name>my repo</name>
<url>https://myrepo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<classifier>myjar</classifier>
</dependency>
</dependencies>
</project>

您可以使用 maven 依赖项插件在特定文件夹中复制依赖项:

https://maven.apache.org/plugins/maven-dependency-plugin/examples/copying-artifacts.html

最新更新