gpt4 book ai didi

java - Maven组装插件: Fetch files and move them to the right places

转载 作者:行者123 更新时间:2023-12-01 18:37:13 26 4
gpt4 key购买 nike

为了创建一个发行版,我决定使用 Maven 程序集插件。但就我而言,我还需要来自其他项目的资源或仅仅是 Artifact 。让我们在这里使用一个简单的示例,我相信稍后我可以自己解决更复杂的示例。

我们的本地存储库服务器上有一个 zip Artifact ,maven 配置为使用该 Artifact 。该 zip 文件具有平面层次结构,包含 native 代码包装器、jar 文件、自述文件和示例配置。对于分发包,我们需要前两个。包装器应放置在 bin/ 目录中,jar 文件应放置在 lib/ 目录中。但 zip 文件仅在组装步骤中需要。我不需要它来编译或测试。阅读有关依赖范围的文档后,我没有找到适合此特定用例的匹配文档。其他问题在下面的代码中进行了描述: 当我没有将 zip 指定为依赖项时,我以后将无法使用该 Artifact 。而且我无法将解压后的文件放在正确的位置。

也许我的整个方法都是错误的?我很想听听您的意见。

pom.xml

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<descriptors>
<descriptor>src/assembly/dist.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>dist</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>

dist.xml

 <dependencySets>
<dependencySet>
<includes>
<!-- does only work when specified as a dependency in pom.xml -->
<include>my:archive</include>
</includes>
<outputDirectory>unpacked</outputDirectory>
<unpack>true</unpack>
<unpackOptions>
<includes>
<include>wrapper</include>
<include>extraLib.jar</include>
<!-- can't move or rename -->
</includes>
</unpackOptions>
<useProjectArtifact>false</useProjectArtifact>
</dependencySet>
</dependencySets>

最佳答案

我已经通过直接使用 maven-dependency-plugin 而不是 maven-assemble 插件完成了几次类似的事情。

http://maven.apache.org/plugins/maven-dependency-plugin/unpack-mojo.html

这是另一个类似的问题:Unzip dependency in maven

关于java - Maven组装插件: Fetch files and move them to the right places,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60008750/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com