Oliver Watkins
Oliver Watkins

Reputation: 13539

Mechanics of Goal execution in Maven

I have the wsimport plugin in my project.

I would like to execute the wsimport. According to the website, the string to execute is "mvn jaxws:wsimport".

Firstly, is this string deductable from the XML ?

The artifact ID is :

<artifactId>jaxws-maven-plugin</artifactId>

and goal :

<goal>wsimport</goal>

so is the artifact-part just the substring of the artifactid leading up to "-maven-plugin" ?

..And when I execute my plugin goal "mvn jaxws:wsimport" does this completely ignore which phase I am in? Ie. is this running outside of the phase? And if no, is there a way to run this standalone?

ie. is there a way I can set the phase to none? (eg [phase]none[/phase]).

Pom code :

<build>
    <plugins>
        <plugin>
            <groupId>org.jvnet.jax-ws-commons</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>2.3</version>
            <executions>                    
                <execution>
                    <id>wsimport-from-jdk</id>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <configuration>
                        <executable>${tool.wsimport}</executable>
                        <wsdlUrls>
                            <wsdlUrl>http://WorkPC:8080/server-web/AirlineWS?wsdl</wsdlUrl>     
                        </wsdlUrls>
                        <packageName>com.bluewalrus</packageName>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Upvotes: 1

Views: 427

Answers (1)

Tome
Tome

Reputation: 3464

When you issue a command like mvn [plugin]:[goal], it launches Maven out of any lifecycle, so if you do not intend to perform that goal inside a lifecycle, but only via such commands, you shouldn't have any <execution> defined, just place <configuration> right after <version>. About how Maven can shorten the plugin call (i.e. mvn dependency:tree instead of mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:tree), it is based on several conventions:

  1. When no version defined, it tries to take the latest from available repositories
  2. When the groupId is omitted, it looks among the predefined or user-defined pluginGroups to find a suitable one. See here for more information (Configuring Maven to Search for Plugins)
  3. On the same page, you can see how plugins prefixes are used to shorten the plugin prefix, by using a prefix instead of the artifactId of the plugin. Thirdparty plugins should use [prefix]-maven-plugin construction, and it looks OK here.
  4. And to disable the default execution of a plugin (although it might not be useful in this case), you can use this answer

Upvotes: 1

Related Questions