|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
How can I drop a custom Velocity tool into archetype:generate?I am finishing up a multimodule project archetype which needs to do some minor string transformations based on the standard archetype property 'rootArtifactId'.
For example, if rootArtifactId = "purchase-order" the requirement is to produce a derived string assigned using a Velocity directive. One example of this might be something like: #set( $camelCase = $myCustomTool.capitalize(${rootArtifactId}) ) which yields $camelCase = "PurchaseOrder" from $rootArtifactId = "purchase-order" I already have the custom Velocity tool written and working correctly as a standalone Java program, however I haven't found any specific information on how to incorporate this custom Velocity tool in an archetype. So my question is: "Is it possible to configure a custom Velocity tool in a VelocityContext and have it available to use during the Velocity processing part of project instantiation that occurs for archetype:generate in an archetype?" If the answer is yes, are there any examples of how to do this? I searched far and wide in the forums where I did see some indications that this idea was at least discussed, if not implemented. For example in the following Nabble posting, <http://www.nabble.com/-m2--Archetype-Plugin-parameters-and-templates-to966996.html#a977701> Jason van Zyl said: "The templates are velocity templates so you get the directives that velocity provides and you can make your own velocity macros or tools. A tool is simply a Java object that you drop into a velocity context so you can really do whatever you want. I would think velocity itself would give you enough flexibility. " TIA! |
|
|
Re: How can I drop a custom Velocity tool into archetype:generate?Is there some way to use Plexus injection to accomplish the addition of a custom Velocity tool in an archetype so that archetype:generate can leverage the custom Velocity tool?
I recently read an introductory posting on Plexus injection on the Sonatype blog, however I don't know whether it's possible to use Plexus for the case described above? Sonatype blog article on Plexus injection: Plexus Container Five Minute Tutorial <http://www.sonatype.com/people/2009/05/plexus-container-five-minute-tutorial/>
|
|
|
Re: How can I drop a custom Velocity tool into archetype:generate?Can anyone give pointers for this question?
|
|
|
Re: How can I drop a custom Velocity tool into archetype:generate?Hi stug23!
Did you make any progress on this topic? If yes, could you please explain the details. tia, - martin On 07 Sep 2009, stug23 wrote: > > Can anyone give pointers for this question? > > > stug23 wrote: > > > > Is there some way to use Plexus injection to accomplish the addition of a > > custom Velocity tool in an archetype so that archetype:generate can > > leverage the custom Velocity tool? > > > > I recently read an introductory posting on Plexus injection on the > > Sonatype blog, however I don't know whether it's possible to use Plexus > > for the case described above? > > > > Sonatype blog article on Plexus injection: > > > > Plexus Container Five Minute Tutorial > > > > > > <http://www.sonatype.com/people/2009/05/plexus-container-five-minute-tutorial/> > > > > > > stug23 wrote: > >> > >> I am finishing up a multimodule project archetype which needs to do some > >> minor string transformations based on the standard archetype property > >> 'rootArtifactId'. > >> > >> For example, if rootArtifactId = "purchase-order" the requirement is to > >> produce a derived string assigned using a Velocity directive. One example > >> of this might be something like: > >> > >> #set( $camelCase = $myCustomTool.capitalize(${rootArtifactId}) ) > >> > >> which yields $camelCase = "PurchaseOrder" from $rootArtifactId = > >> "purchase-order" > >> > >> I already have the custom Velocity tool written and working correctly as > >> a standalone Java program, however I haven't found any specific > >> information on how to incorporate this custom Velocity tool in an > >> archetype. > >> > >> So my question is: "Is it possible to configure a custom Velocity tool in > >> a VelocityContext and have it available to use during the Velocity > >> processing part of project instantiation that occurs for > >> archetype:generate in an archetype?" > >> > >> If the answer is yes, are there any examples of how to do this? > >> > >> I searched far and wide in the forums where I did see some indications > >> that this idea was at least discussed, if not implemented. For example in > >> the following Nabble posting, > >> > >> <http://www.nabble.com/-m2--Archetype-Plugin-parameters-and-templates-to966996.html#a977701> > >> > >> Jason van Zyl said: > >> > >> "The templates are velocity templates so you get the directives that > >> velocity provides and you can make your own velocity macros or tools. A > >> tool is simply a Java object that you drop into a velocity context so you > >> can really do whatever you want. I would think velocity itself would give > >> you enough flexibility. " > >> > >> TIA! > >> > >> > >> > >> > > > > > > -- > View this message in context: http://www.nabble.com/How-can-I-drop-a-custom-Velocity-tool-into-archetype%3Agenerate--tp25207677p25337553.html > Sent from the Maven - Users mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > |
|
|
Re: How can I drop a custom Velocity tool into archetype:generate?Unfortunately I never did find a way to do what I described in the posting.
Perhaps this could eventually be a feature in Maven 3?
|
| Free embeddable forum powered by Nabble | Forum Help |