views:

1518

answers:

3

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!

+3  A: 

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
whaley
+2  A: 

Usually you set maven properties using the same syntax as java system properties. Have you tried the following line?

mvn -DuseRepositoryLayout=true dependency:copy-dependencies
David Rabinowitz
This only works if the plugin author has annotated the variable with an expression. They will be shown in the plugin docs as shown in the above answer.
Brian Fox
A: 

Define the properties as arbitrary properties ... not the standard maven props such as version. In my case I defined a new property build.version:

<properties> build.version=unknown </properties>

I use the property:

<warName>${build.version}</warName>

I define the property:

mvn -P prod -Dbuild.version=app_name-branch_name-build_number package
bcolfer
Here is a good link: http://www.sonatype.com/books/mvnref-book/reference/resource-filtering-sect-properties.html#resource-filtering-sect-user-defined
bcolfer