如何覆盖默认的maven-install-plugin行为? [英] How to override default maven-install-plugin behavior?
问题描述
我需要自定义工件安装,无法确定如何覆盖默认对象(从默认的maven生命周期开始).所以我的问题是:
I'm need of custom artifact installation and can't figure how to override the default one (from default maven lifecycle). So my question is:
如何在pom.xml中配置maven安装插件,使其不执行默认安装并仅执行我的自定义安装文件目标?
How to configure maven install plugin in my pom.xml so it doesn't do default install and executes just my custom install-file goals?
我尝试了没有id并使用默认安装 id并没有帮助.
I tried without id and with default-install id and it didn't help.
更新: 根据提供的答案-这对我不起作用(我在日志中看到两次安装尝试).
Update: From the provided answer - this does not work for me (I see two install attempts in log).
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>default-install</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>install-jar-lib</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>install</phase>
<configuration>
<file>${project.build.directory}/${project.build.finalName}.jar</file>
<generatePom>false</generatePom>
<pomFile>pom.xml</pomFile>
<packaging>jar</packaging>
<version>${unicorn.version}</version>
</configuration>
</execution>
</executions>
</plugin>
推荐答案
如果您至少具有2.4版本的安装插件,则可以跳过默认安装.
You can have the default install skipped if you have at least version 2.4 of the install plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
然后,您可以通过添加
<phase>install</phase>
转到插件的执行部分,您可以使用来运行新的安装过程
to the execution section of the plugin, and you can run the new install process with
mvn install
这篇关于如何覆盖默认的maven-install-plugin行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!