Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set plugin's property on the command line in maven 2

In maven 2.x, how would one set a plugin's property on the command line instead of in the <configuration> of that plugin in the pom or in settings.xml?

For example, if I was using mvn dependency:copy-dependencies(seen here) how can I set the useRepositoryLayout property without touching either the pom or my settings.xml?

Thanks!

like image 660
whaley Avatar asked Apr 15 '09 17:04

whaley


People also ask

What is Maven command line?

Maven is a command-line tool for building Java (and other) programs. The Maven project provides a simple ZIP file containing a precompiled version of Maven for your convenience. There is no installer. It's up to you to set up your prerequisites and environment to run Maven on Windows.

What is D in Mvn command?

-D, --define <arg> Defines a system property. This is the option most frequently used to customized the behavior of Maven plugins. Some examples of using the -D command line argument: $ mvn help:describe -Dcmd=compiler:compile $ mvn install -Dmaven.test.skip=true.

What is P in Mvn?

A reference tells us that -P specifies which profile Maven is to run under. Projects can define multiple profiles which may pull in different dependencies, so this is required if you have a project that can do that.

Where do I put build in POM xml?

Build plugins They execute during the build process and should be configured in the <build/> element of pom. xml.


1 Answers

Answer was right in front of me in the copy-dependencies mojo docs (I even linked to it). The documentation for the property includes the Expression you can refer to it by.

useRepositoryLayout: Place each artifact in the same directory layout as a default repository. example: /outputDirectory/junit/junit/3.8.1/junit-3.8.1.jar

* Type: boolean * Since: 2.0-alpha-2 * Required: No * Expression: ${mdep.useRepositoryLayout} * Default: false 

To set this property from command line you need to run

mvn -Dmdep.useRepositoryLayout=true <goals go here> 
like image 110
whaley Avatar answered Sep 23 '22 06:09

whaley