Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to override default maven-install-plugin behavior?

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>
like image 424
zeratul021 Avatar asked Apr 24 '12 23:04

zeratul021


2 Answers

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>
like image 105
Michał Kalinowski Avatar answered Nov 10 '22 00:11

Michał Kalinowski


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
like image 45
mooreds Avatar answered Nov 10 '22 00:11

mooreds