I’m having trouble setting a default-value for a complex object in a maven plugin.
If I have a class called MyObject I would like to new it up by default, so I would like to do something like this in my Mojo:
/**
* Value class that wraps all report configuration.
*
* @parameter default-value="new MyCLass()"
*/
private MyClass classObject;
Now this is not valid, it doesn’t create a new instance of MyClass by default (It compiles, but I get an error when trying to use the plugin). I can put something into my mojo that news up classObject if it is null, but I would prefer to automatically do it using the @parameter annotation.
Is this possible?
Found the answer, actually very simple (and i’m kicking myself for not realising it sooner now):
Just use the maven magic variable to set an instance of itself and it news it up for you.