1

Is it possible to execute a Maven plugin from the command line? I need to run dependency plugin:

<executions>
    <execution>
        <id>copy-dependencies</id>
        <phase>package</phase>
        <goals>
            <goal>copy-dependencies</goal>
        </goals>
        <configuration>
            <outputDirectory>${RPTBIN}/.tools/lib</outputDirectory>
            <overWriteReleases>false</overWriteReleases>
            <overWriteSnapshots>false</overWriteSnapshots>
            <overWriteIfNewer>true</overWriteIfNewer>
            <excludeTransitive>true</excludeTransitive>
        </configuration>
    </execution>
</executions>

Is there any way to execute this plugin just like this plugin executes during Maven build?

Duncan Jones
  • 67,400
  • 29
  • 193
  • 254
johnny-b-goode
  • 3,792
  • 12
  • 45
  • 68

3 Answers3

2

Yes that is possible. Maven is a Java tool, so you must have Java installed in order to proceed. Please go through the installation process here.

mvn dependency:copy-dependencies

A sample dependency plugin command. By the way how you have been running the Maven command till now?

Vijay Shanker Dubey
  • 4,308
  • 6
  • 32
  • 49
2

You should be able to run it with just mvn dependency:copy-dependencies and just add the relevant configuration parameters with -Dparameter=value, i.e. -DoverWriteReleases=false

maba
  • 47,113
  • 10
  • 108
  • 118
Joakim Z
  • 86
  • 2
2

You can use below command. It worked for me:

mvn {your groupId}:{your artifactId}:{your version}:{your goal}

But remember this command is good if your plugin main class is extending AbstractMojo.

It will run the execute() method of your plugin main class. Also, before running this command please run mvn clean install to build the jar

Sunil
  • 482
  • 6
  • 12