禁用执行:default-jar [英] disable the execution: default-jar
问题描述
我正在使用maven程序集插件来打包一个jar文件。
但是当我运行 mvn package
时,maven总是触发[jar:jar {execution:default-jar}]来创建一个默认的jar文件。
所以我将有2个jar文件(一个由程序集插件创建,另一个由maven jar创建,我不想创建)。我如何关闭执行:default-jar。
i am using maven assembly plugin to pack a jar file.
But when i run mvn package
, maven always trigger the [jar:jar {execution: default-jar}] to create a default jar file.
So i will have 2 jar files (one created by assembly plugin and one created by maven jar which i dont want to be created). How can i turn off the execution: default-jar.
在我的pom.xml中,我使用的是:
< packaging> ;罐子< /包装>
。我不想将其更改为< packaging> pom< / packaging>
。
in my pom.xml, i am using :
<packaging>jar</packaging>
. i dont want to change it to <packaging>pom</packaging>
.
推荐答案
(...)所以我将有2个jar文件(一个由程序集插件创建,另一个由maven jar创建,我不想创建)。
(...) So i will have 2 jar files (one created by assembly plugin and one created by maven jar which i dont want to be created).
看起来你做的很复杂。也许Maven不适合你的情况。
Looks like you're doing pretty complicated things. Maybe Maven is not the right tool in your case.
如何关闭执行:default-jar。
How can I turn off the execution: default-jar.
您可以将相应执行的< phase>
设置为未知的内容,例如无
:
You can set the <phase>
of the corresponding execution to something unknown, like none
:
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-jar</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</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>
只要您提供其他要安装的东西,就像装配一样,这似乎有效(我只测试了安装
)。但当然,这是一个黑客。
This seems to work as long as you're providing something else to be installed, like an assembly (I only tested install
). But of course, this is a hack.
这篇关于禁用执行:default-jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!