在我的 Maven 构建中,我调用了一个生成一些 tar.gz Artifact 的脚本。如何指定maven groupId, artifactId, version 和packaging, 所以它在mvn deploy
期间将最终的tar.gz 部署到artifactory?
我的挑战是,这可以通过程序集插件实现,但如果是任意脚本,则在输出 Artifact 时无法实现。
例如:假设我的 shell 生成带有一些 groupId 和 artifactId 的 ABC.tar.gz
。我的版本是 0.0.1
。
我想将 ABC.tar.gz
部署到 artifactory,所以在下一个项目的 pom 文件中,我能够像这样引用它:
<dependency>
<groupId>my_group</groupId>
<artifactId>ABC</artifactId>
<version>0.0.1</version>
<type>tar.gz</type>
</dependency>
然后maven下载ABC.tar.gz
到.m2
。
出于一系列原因,我不想使用程序集插件。
最佳答案
您可以使用 build-helper:attach-artifact
Build Helper Maven Plugin 的目标:
Attach additional artifacts to be installed and deployed.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${project.build.directory}/path/to/targz</file>
<type>tar.gz</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
这将附加具有与当前 Maven 项目相同的 groupId、artifactId 和版本的 tar.gz 文件。这个额外的 Artifact 将像项目的主要 Artifact 一样部署和安装。
关于maven - 在没有程序集插件的情况下将 maven tar.gz Artifact 部署为构建输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35095909/