2

I have in my pom.xml a section

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-install-plugin</artifactId>
    <configuration>
      <pomFile>./lib/pom.xml</pomFile>
      <file>./lib/wls-maven-plugin.jar</file>
    </configuration>
    <executions>
       <execution> 
        <phase>install</phase>
            <goals>
              <goal>install-file</goal>
            </goals>
       </execution>
     </executions>

where i want to install the Weblogic plugin to my local repository. Note i indicated that i want this to be done in install phase. Then i want to use this plugin but in package and deploy phases. However when i try to run mvn install the package phase is invoked as well and i get error because my weblogic plugin is not installed yet. So why this is happening? I want my plugin to be installed first and then used. Sorry fo poor English.

Mandar Pandit
  • 2,171
  • 5
  • 36
  • 58
Oleksandr Papchenko
  • 2,071
  • 21
  • 30

4 Answers4

2

The Maven build lifecycle is composed of a sequence of phases. When you execute a certain phase, all phases prior to it in the lifecycle will be called in order until the phase you invoked. The default build lifecycle starts with the validate phase and ends with the deploy phase, and in between, the package phase comes prior to install.

More information can be obtained here.

M A
  • 71,713
  • 13
  • 134
  • 174
2

The install goal tells Maven to install the artifact(s) produced by the project or module in question. Maven has to package them into a jar or other suitable artifacts in order to have anything to install.

You really shouldn't be manually twiddling plugins like this. Instead, you should declare a proper Maven dependency on that Weblogic plugin, if it's actually even necessary.

chrylis -cautiouslyoptimistic-
  • 75,269
  • 21
  • 115
  • 152
1

package phase is called before in maven's lifecycle just before install, so if you ask to invoke particular phase it invokes all the phases upto that phase by default

skipping package phase is effectively don't run plugins which are binded to run at package phase (usually jar plugin) you can find all these plugins by mvn help:effective-pom and then create another build profile and skip their execution

jmj
  • 237,923
  • 42
  • 401
  • 438
0

I found this https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#usual-command-line-calls

You should select the phase that matches your outcome. If you want your jar, run package. If you want to run the unit tests, run test.

If you are uncertain what you want, the preferred phase to call is

mvn verify

This command executes each default lifecycle phase in order (validate, compile, package, etc.), before executing verify. You only need to call the last build phase to be executed, in this case, verify. In most cases the effect is the same as package. However, in case there are integration-tests, these will be executed as well. And during the verify phase some additional checks can be done, e.g. if your code written according to the predefined checkstyle rules.

Hai Mai
  • 370
  • 2
  • 6