0

Is it possible to pass a Collection or a Map to the Maven command line using the -D option?

Currently I've got a mojo with a lot of maven parameters which are passed by calling:

mvn.bat -DparamterName=parameterValue

I know that Lists and Maps can be passed through an .xml file, but I need to use the maven command line to start the mojo.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302

1 Answers1

0

You cannot pass Collection/Map to maven. If the value you passed in will be used at runtime (not build time), you can make the value follow some rule, like foo=1;bar=2;blah=3 or foo:1,bar:2,blah:3 ... and parse it in your codes. However by reading your question, maven profile could be the direction to go.

You can predefine the set of properties in certain profile, when you start mvn, active the certain profile instead of setting those properties in cmdline/start script.

Kent
  • 189,393
  • 32
  • 233
  • 301