我有一个仅由文件组成的项目。我想将这些文件打包成一个 zip 并将它们存储在一个 Maven 存储库中。我已将程序集插件配置为构建 zip 文件,并且该部分工作正常,但我似乎无法弄清楚如何安装 zip 文件?
另外,如果我想在另一个工件中使用这个程序集,我该怎么做?我打算调用依赖项:解包,但我在存储库中没有要解包的工件。
如何将 zip 文件放在我的存储库中,以便我可以在另一个工件中重新使用它?
家长会
<build>
<plugins>
<plugin>
<!--<groupId>org.apache.maven.plugins</groupId>-->
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<filters>
<filter></filter>
</filters>
<descriptors>
<descriptor>../packaging.xml</descriptor>
</descriptors>
</configuration>
</plugin>
</plugins>
</build>
子 POM
<parent>
<groupId>com. ... .virtualHost</groupId>
<artifactId>pom</artifactId>
<version>0.0.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<name>Virtual Host - ***</name>
<groupId>com. ... .virtualHost</groupId>
<artifactId>***</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
我把名字过滤掉了。这个 POM 正确吗?我只想将特定虚拟主机的文件捆绑在一起。
谢谢,
沃尔特
最佳答案
I have the assembly plugin configured to build the zip file and that part works just fine, but I cannot seem to figure out how to install the zip file?
好吧,创建的程序集应该会自动附加到项目中,然后上传到
install
上的存储库中。和 deploy
目标。你能展示你的pom吗?更新:使用您当前的配置,我认为程序集不会作为您的构建的一部分创建。您需要绑定(bind)
single
生命周期阶段的目标,通常为 package
: <plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<descriptors>
<descriptor>../packaging.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- append to the packaging phase. -->
<goals>
<goal>single</goal> <!-- goals == mojos -->
</goals>
</execution>
</executions>
</plugin>
现在它应该被正确安装/部署。
Also, if I want to use this assembly in another artifact, how would I do that? I am intending on calling dependency:unpack, but I don't have an artifact in the repository to unpack.
您可以声明对程序集的依赖项(在您的情况下使用正确的
classifier
和 type
),但由于依赖项是通过存储库解决的,因此您需要先解决第一步。然后,声明这样的内容(其中分类器是程序集的 id):<dependency>
<groupId>com. ... .virtualHost</groupId>
<artifactId>***</artifactId>
<version>0.0.1</version>
<classifier>...</classifier>
<type>zip</type>
</dependency>
关于maven-2 - Maven Assembly Plugin - 安装创建的程序集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2639585/