Suppose I have a plugin parameter like this:

/**
 * @parameter *default-value="hoopy"* property="disposition"
 */
private String disposition;

...and a getter/setter pair like this:

public String getDisposition() {
  return this.disposition;
}

public void setDisposition(final String disposition) {
  this.disposition = disposition;
}

...then when my mojo is loaded and configured by Maven it will call my
setter method with "hoopy" (the plugin parameter's defaultValue value) if I
haven't used a <configuration> element with a <disposition> element inside
it.

Now suppose additionally I have a constructor like this:

public MyMojo() {
  super();
*  this.setDisposition("crabby");*
}

I am observing in my plugin tests (based on the
maven-plugin-testing-harness<http://maven.apache.org/plugin-testing/maven-plugin-testing-harness/>machinery,
using
configureMojo()<http://maven.apache.org/plugin-testing/maven-plugin-testing-harness/apidocs/org/apache/maven/plugin/testing/AbstractMojoTestCase.html#configureMojo%28org.apache.maven.plugin.Mojo,%20java.lang.String,%20java.io.File%29>)
that if my constructor contains a setter call, Maven (or Plexus, I guess?)
does not subsequently call setDisposition() with "hoopy" ever.  Does it do
some kind of a getDisposition() == null test first to decide whether to
configure my plugin?  Why, if so?

I would think that whatever I do in my constructor is my business, and that
if my XML configuration does not supply a value, Maven would supply the
defaultValue of the @parameter, perhaps (justifiably) overwriting anything
that I might have set up in my constructor.  Why does Maven/Plexus not do
this?  Or what have I misunderstood?

Best,
Laird

-- 
http://about.me/lairdnelson

Reply via email to