Hi,

thanks for your question, but you picked the wrong channel. Next time you should use the Maven users mailing list.

Regarding your question: you can't pass complex Objects via commandline. But there might be a trick which could work for you.

---
private DeployConfig deployConfig = new DeployConfig();

@Parameter
private String bucket

public void setBucket(String bucket)
{
  this.deployConfig.setBucket(bucket);
}
---

If there is a parameter X AND there's a public method called setX, then this method is called. Be aware that bucket will stay null, unless you *also* add this.bucket = bucket;

thanks,
Robert


On Mon, 14 Mar 2016 23:15:16 +0100, João Martins <[email protected]> wrote:

Hi,

hope this is the correct channel to respond to this question.

I'm building a Maven plugin whose every action take around 75 possible
flags (and counting).

To help with compartmentalizing all this configuration, I created Java
classes to hold the configs for each goal (e.g., DeployConfig, RunConfig,
etc.). It makes pom.xml look much better, but the downside is that
specifying parameters on the command line becomes a bit complicated.

According to this
<http://blog.sonatype.com/2011/03/configuring-plugin-goals-in-maven-3/#.Vuba4qgrJE4>
article, if my parameter isn't of a simple type, collection of array, I'm
only left with the set(String args) method. I don't want to pass all args
in a single String and then parse it, so I thought of having a DeployConfig
and all the parameters inside it at the Mojo level. That would result in
stuff like:

<deployConfig>
  <bucket>this bucket</bucket>
<deployConfig>
<bucket>that bucket</bucket>

Where I'd have to add priorities and it would also get complicated.

Finally, since the mvn call sets system properties with -D, I'm thinking of going over System.getProperties() at the beginning of my Mojo.execute() and
override the pom.xml values with the ones in the command line.

1) This gets rid of all @Parameter annotations except one, and we're
getting actual parameters hiding from Maven. Is there any automation by
Maven that uses those annotations and that we might be missing on?

2) Is there a better way to accomplish Complex Object parameters through
command line?

Thanks a lot for your time,
joão



--
Using Opera's mail client: http://www.opera.com/mail/

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to