Rob Avery IV
Rob Avery IV

Reputation: 3730

How to set the default-value for a maven array parameter?

I have a parameter in my custom plugin that is an array. If the parameter isn't given anything, I want to set the default-value to be a blank array. Of course, here is the normal syntax for a regular variable:

/**
* @parameter default-value="Hello Maven World"
*/
private String message;

But my array is set like this:

/**
* @parameter
*/
private String[] message;

How would I set the default-value of an array variable as a parameter in a custom maven plugin?

Upvotes: 6

Views: 1477

Answers (1)

maba
maba

Reputation: 48075

It should be possible to set the default values directly in the code instead of using a tag. This value can still be overridden in the pom file.

/**
 * @parameter
 */
private String[] message = new String[0];

That will give you an empty array.

Upvotes: 5

Related Questions