对于目标“包",不会自动调用Maven阴影插件. [英] Maven shade plugin is not called automatically for goal "package"
问题描述
我花了很多时间弄清楚如何调用Maven阴影插件来构建uber-jar(具有所有依赖项). 我发现的大多数可谷歌搜索的信息(包括大量示例和Maven文档)表明,我要做的就是将插件包含在pom.xml中:
I've spent quite a bit of time figuring out how to invoke Maven shade plugin to build a uber-jar (with all dependencies). Most of the google-able info that I found (including numerous examples, and Maven documentation) suggests that all I have to do is include the plugin into pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
然后"mvn软件包"(或最终调用软件包"的任何其他目标)将自动触发该插件.
and then "mvn package" (or any other goal that eventually invokes "package") will automatically trigger this plugin.
但是,不管我尝试了什么-实际调用该插件的唯一方法似乎是:运行"mvn软件包shade:shade"(这似乎违反了配置驱动的构建的目的).无论是从Eclipse(STS版本:3.8.2.RELEASE)还是从命令行(Apache Maven 3.3.9)运行Maven,结果都是相同的.
But no matter what I tried - the only way to actually invoke the plugin appears to be: running "mvn package shade:shade" (which seems to defeat the purpose of config-driven build). Same results whether running Maven from within Eclipse (STS Version: 3.8.2.RELEASE), or from command line (Apache Maven 3.3.9).
我想念什么吗?
UPD:已解决,请参见GauravJ的回答.
UPD: solved, see answer by GauravJ.
推荐答案
我设法重现了您的问题.在pom.xml中,您必须已定义如下的插件,
I have managed to reproduce your problem. In your pom.xml, you must have defined plugin like below,
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
....
</plugins>
</pluginManagement>
</build>
代替
<build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</build>
这可能会解决您的问题.
This will probably fix your problem.
这篇关于对于目标“包",不会自动调用Maven阴影插件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!