Search code examples
mavenmaven-pluginmaven-cargo

How do I know what are different goals available for plug-in in maven?


I recently started using maven. so this question might sound basic. This question came up when I was browsing through some code using cargo plug-in.

In the following snippet of maven plugin in pom.xml, that i extracted from here, my understanding is as follows:

<plugin>
      <groupId>org.codehaus.cargo</groupId>
      <artifactId>cargo-maven2-plugin</artifactId>
      <executions>
        <execution>
          <id>start-container</id>
          <phase>pre-integration-test</phase>
          <goals>
            <goal>start</goal>
          </goals>
        </execution>
        <execution>
          <id>stop-container</id>
          <phase>post-integration-test</phase>
          <goals>
            <goal>stop</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        [Cargo plugin configuration goes in here]
      </configuration>
    </plugin>
  1. This plug in bound to pre-integration-test and post-integration-test phase of build LifeCycle, which also means when I run mvn install this will be executed.

  2. The goals (start and stop) of this plug-in gets executed during these phases respectively

  3. Q1:: Does the <id>start-container</id> has any relevance? what's its purpose & importance?

  4. Q2:: How do I know what are the different goals available for a plug-in. In this case for cargo plug-in I see in one of the codes in my work, <goal>redeploy</goal> is used. so I am wondering how to find information on these specific goals and other goals available. I did look at online documentation. I did not find any. possible that I did not search in the right place.


Solution

  • A1: the id doesn't change how the execution works, it's just a way of giving it a name.

    A2: The best way is to read the documentation. Maven3 is also considerably better than maven2 in this aspect. If you call a plugin with an invalid goal, it will print out all the valid goals, but it won't print what are the different parameters that can be passed to the plugin (and some plugins use different parameter names for command line and pom parameters)

    The documentation of cargo is a bit odd, most other plugins have their documentation set up in a different way, which makes it easier to find the goals and the parameters that can be set.

    By the way, both your points 1 and 2 are correct.