Reputation: 2694
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:
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?
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>
Upvotes: 10
Views: 24087
Reputation: 17933
To disable maven-install-plugin
:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-install</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
and for execution of your custom installation goal:
<build>
<plugins>
<plugin>
<groupId>yourGroupId</groupId>
<artifactId>yourArtifactId</artifactId>
<executions>
<execution>
<id>custom-install</id>
<phase>install</phase>
<goals>
<goal>yourGoal</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Upvotes: 13
Reputation: 4978
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>
Then you can bind another plugin (the ant run plugin or anything else) to this phase by adding
<phase>install</phase>
to the execution section of the plugin, and you can run the new install process with
mvn install
Upvotes: 6