Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure defaults for a parameter with multiple values for a Maven plugin

I'm writing a Maven plugin and I am using default values for all parameters such as this:

/**
 * The file with the site structure.
 * 
 * @parameter expression="${generateSite.siteFile}" default-value="${basedir}/src/oda/site.xml"
 */
private File siteFile;

Now I am adding a new parameter which is a collection. Is there a way to set default values for a parameter like the following one?

/**
 * A list of file/directory names to exclude in the processing.
 * 
 * @parameter ????
 */
private Set<String> excludes;
like image 886
Peter Becker Avatar asked Nov 02 '09 01:11

Peter Becker


1 Answers

To my knowledge, this is actually not possible, there is no real way to specify default values for Parameter Types With Multiple Values (like Arrays, Collections, or Maps), at least not as parameter. I had to do this in the past too and, having read threads like array (or collecton) as a default-value of a mojo configuration parameter or configuring a list as default value for a plugin parameter, I ended up setting defaults in the execute() method, like Chris mentioned in a comment to his answer (see for example the flexmojos:wrapper plugin sources and the parameters parameter).

like image 85
Pascal Thivent Avatar answered Oct 24 '22 02:10

Pascal Thivent