5

I see that this has already been asked over here: How to execute maven plugin from command line? but I don't really understand the answer. It looks like the syntax is of the form:

mvn foo:bar

But I'm not really sure what foo and bar are supposed to be.

Specifically I have configured the maven-resource-plugin like this:

<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.5</version>
    <executions>
        <execution>
            <id>copy-resources</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <!--configuration here-->
            </configuration>
        </execution>
    </executions>
</plugin>

I've tried several permutations of mvn artifactId|id|phase|goal:artifactidId|id|phase|goal but none of them are working. I figured i'd stop trying to brute-force it and just ask the internet. Also, is this documented anywhere?

Community
  • 1
  • 1
David
  • 14,569
  • 34
  • 78
  • 107

2 Answers2

12

There are 3 patterns:

groupId:artifactId:version:goal
groupId:artifactId:goal
prefix:goal

If you run this from a location with a pom.xml and you haven't specified the version, Maven will search for a matching plugin in the build-section. The prefix can often (not always) be recognized as part of the artifactId, e.g. maven-help-plugin has the prefix help. The plugin documentation should give you the exact prefix.

Robert Scholte
  • 11,889
  • 2
  • 35
  • 44
5

You would call this plugin goal as follows:

mvn resources:copy-resources

where copy-resources is the plugin goal that you configured in the POM, and resources is prefix of the maven-resources-plugin (see this link for plugin prefix resolution).

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