52

I wanted pass maven command line parameter to POM.xml so that i can use those value for some other purpose in building purpose.

Gautam
  • 3,707
  • 5
  • 36
  • 57
  • 1
    Did you already have a look at the [maven reference](http://books.sonatype.com/mvnref-book/reference/running-sect-options.html)? – SpaceTrucker Jun 13 '14 at 13:12

3 Answers3

74
mvn install "-Dsomeproperty=propety value"

In pom.xml:

<properties>
    <someproperty> ${someproperty} </someproperty>
</properties>

Referred from this question

coreJavare
  • 1,409
  • 2
  • 10
  • 21
28

We can Supply parameter in different way after some search I found some useful

<plugin>
  <artifactId>${release.artifactId}</artifactId>
  <version>${release.version}-${release.svm.version}</version>...

...

Actually in my application I need to save and supply SVN Version as parameter so i have implemented as above .

While Running build we need supply value for those parameter as follows.

RestProj_Bizs>mvn clean install package -Drelease.artifactId=RestAPIBiz -Drelease.version=10.6 -Drelease.svm.version=74

Here I am supplying

release.artifactId=RestAPIBiz
release.version=10.6
release.svm.version=74

It worked for me. Thanks

Gautam
  • 3,707
  • 5
  • 36
  • 57
16

If we have parameter like below in our POM XML

<version>${project.version}.${svn.version}</version>
  <packaging>war</packaging>

I run maven command line as follows :

mvn clean install package -Dproject.version=10 -Dsvn.version=1
Gautam
  • 3,707
  • 5
  • 36
  • 57