使用 Maven 创建 tar.gz 存档
我有一个 Maven 项目,在 src/main 目录下有一个名为 output 的子目录。该文件夹需要打包成tar.gz。使用程序集插件时如下:
来自 pom.xml:
<build>
<finalName>front</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
</plugin>
</plugins>
</build>
程序集.xml:
<assembly>
<id>bundle</id>
<formats>
<format>tar.gz</format>
</formats>
<fileSets>
<fileSet>
<directory>src/main/output</directory>
</fileSet>
</fileSets>
</assembly>
我的问题是我正在尝试结果将与运行 tar 实用程序本身一样,这意味着在提取时获取输出目录及其所有内容。我得到的是包含所有项目路径的输出文件夹 - name/src/main/output。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(2)
月下伊人醉 2024-09-18 16:44:23
尝试在 ="">outputDirectory >文件集。这应该删除 src/main/output 目录。
<fileSet>
<directory>src/main/output</directory>
<outputDirectory>.</outputDirectory>
</fileSet>
您可能还需要设置 includeBaseDirectory
为假。这将删除名称目录。
<assembly>
<id>bundle</id>
<includeBaseDirectory>false</includeBaseDirectory>
<!-- ... -->
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
您需要将程序集描述符配置为不包含基目录,并为
fileSet
配置输出目录:使用上面的程序集描述符,我得到以下结果(当在重现结构的项目上运行):
另请参阅
You need to configure the assembly descriptor to not include the base directory and to configure an output directory for the
fileSet
:With the above assembly descriptor, I get the following result (when running on a project reproducing the structure):
See also