Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the syntax to run a maven plugin from the command line.

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?

like image 773
David Avatar asked Jun 14 '15 20:06

David


1 Answers

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.

like image 141
Robert Scholte Avatar answered Oct 12 '22 03:10

Robert Scholte