For now, I've added a set method on the Options class for setting a default directory, which I get from a parameter in the Mojo. This is essentially what you suggested I could do. I just don't think it is very clean, and I see how it could be useful (and in this case cleaner) if Maven could process annotations on beans in collections that are defined as Mojo parameters.

Thanks,
Richard Allen

Allison, Bob wrote:

The configuration should look like (assuming that your definition of
parameter directory is actually specified as "private String
directory"):

<options>
 <option>
   <directory>/a/b/c</directory>
 </option>
 <option>
   <directory>/d/e/f</directory>
 </option>
</options>

I don't think that the expressions and default values available in the
Mojo are available in the classes used in this manner.  A workaround
might be to place variables which require an expression as a parameter
in the Mojo itself and have a way to propagate it to the sub-objects.

-----Original Message-----
From: Richard Allen [mailto:[EMAIL PROTECTED] Sent: Monday, November 14, 2005 14:59
To: users@maven.apache.org
Subject: [m2] How to inject values into a bean within a collection
definedas a plugin parameter?


I have an array (same question applies to Java Collections) that is defined as a parameter of a Mojo:

public class MyMojo extends AbstractMojo {
...
 /**
  * @parameter
  * @required
  */
 private Options[] optionsArray;
...
}

and within the Options bean, I would like to inject properties from
Maven:

public class Options {
...
 /**
  * @parameter expression="${project.build.directory}"
  */
 private directory;
...
}

such that the plugin can be configured like:

     <plugin>
       ...
       <executions>
         <execution>
           ...
           <configuration>
             <optionsArray>
               <options>
                 ...
               </options>
               <options>
                 ...
               </options>
             </compilations>
           </configuration>
           ...
         </execution>
       </executions>
     </plugin>

Is there a way to make this happen? It seems like I should be able to do

this since Maven is creating and populating the bean classes (Options class).

Thanks,
Richard Allen

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to