在 Maven 的组装指南( https://maven.apache.org/guides/mini/guide-assemblies.html )中指出:
You'll notice that the assembly descriptor is located in ${project.basedir}/src/assembly which is the standard location for assembly descriptors.
但是在 Maven 程序集插件页面 ( https://maven.apache.org/plugins/maven-assembly-plugin/examples/sharing-descriptors.html ) 中它说:
Note: Your assembly descriptors must be in the directory /src/main/resources/assemblies to be available to the Assembly Plugin.
它们是两个不同的东西吗?它们中的任何一个都已经过时了吗?
最佳答案
这是使用程序集和使其可供其他项目使用之间的区别。
将程序集描述符放在 src/main/resources/assemblies
中的想法是使它们可供其他模块或项目使用。您可以在 src/main/resources/assemblies
中创建一个项目,例如 my-assemble-descriptor
,其中包含一个或多个程序集描述符。然后,在您想要使用描述符的不同项目中,配置程序集插件以使用 my-assemble-descriptor
作为依赖项。
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<dependencies>
<dependency>
<groupId>your.group.id</groupId>
<artifactId>my-assembly-descriptor</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<executions>
...
</executions>
</plugin>
程序集插件在其类路径上找到您的描述符并可以使用它们。
放置在 src/Assembly 中的程序集描述符可用于组装 Artifact ,但不能在其他模块或项目中重用。
关于java - 在 Maven 中存储程序集文件的正确位置是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36510692/