gpt4 book ai didi

java - 如何使用具有预定义 "src"描述符的 Maven 程序集插件制作单个 zip 存档?

转载 作者:行者123 更新时间:2023-12-01 12:35:10 25 4
gpt4 key购买 nike

我被明确要求使用预定义的“src”描述符制作一个包,但我无法让它工作。这是我的 POM 中的 maven-assemble-plugin 配置:

<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<descriptorRefs>
<descriptorRef>src</descriptorRef>
</descriptorRefs>
</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>
</plugins>
</pluginManagement>
</build>

我可以毫无问题地制作 jar 文件,但我不知道如何生成 zip 文件。我正在使用 eclipse,我应该选择什么选项?

enter image description here

我还有一个 jar 插件,它似乎一直在生成 jar:

  <plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>

最佳答案

你必须真正执行插件,因为在pluginManagement中插件并没有真正执行。因此,您必须更改以下内容:

<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<descriptorRefs>
<descriptorRef>src</descriptorRef>
</descriptorRefs>
</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>
</plugins>
</pluginManagement>
</build>

进入此:

<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>src</descriptorRef>
</descriptorRefs>
</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>
</plugins>
</build>

之后只需调用

 mvn clean package

关于java - 如何使用具有预定义 "src"描述符的 Maven 程序集插件制作单个 zip 存档?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25653619/

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