0

I am having a new Maven project and I want to pass parameters through command line..

This is my requirement -

If I pass - install -Dinfra=local then my test should run on local machine

If I pass - install -Dinfra=ip then my test should run on the machine having desired ip.

I just wanted to know how to configure this infra into my project so that I can access that through command line.. Many thanks!

thisisdude
  • 501
  • 5
  • 23
  • Do you need to access the parameter from your code? If so, please see https://stackoverflow.com/questions/11500533/access-maven-properties-defined-in-the-pom. – gjoranv Jan 02 '18 at 13:53

1 Answers1

1

You can define a property in your POM:

<project>
    ...
    <properties>
         <infra>local</infra>
    </properties>
    ...
</project>

Then you can reference it in the POM by using ${infra}. You can overwrite the value of the property through the command line (as in your example).

Also see https://stackoverflow.com/a/13709976/927493

J Fabian Meier
  • 30,532
  • 9
  • 61
  • 119