You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Christian Schuhegger <Ch...@gmx.de> on 2011/06/23 20:20:29 UTC

Question about maven archetype: how to convert ${artifactId} into a file system path?

Hello list,

I am writing a maven archetype and it would be useful to convert an 
${artifactId} (e.g. my.nice.little.project) into a path: 
my/nice/little/project.

If this is possible, could somebody please point me to the relevant 
documentation? I did not find it via google.

Many thanks,
-- 
Christian Schuhegger
http://www.el-chef.de/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Question about maven archetype: how to convert ${artifactId} into a file system path?

Posted by goutham vasireddi <go...@gmail.com>.
Hi

I don't know this helps you are not but if you want to create a file system
path with a parameter.

You can set packaged="true" in fileset  tag , then all the defined files in
filetag will be created in a file system path as given to ${package}.

example:

${package}=my.nice.little.project

//////////archetype-metadata.xml/////////

<fileSets>
<fileSet filtered="true" *packaged="true"*  encoding="UTF-8">

		<directory>api</directory>
		<includes>
			<include>Test.java</include>
		</includes>
</fileSet>
</fileSets>

then your Test.java file will be created in
api/my/nice/little/project/Test.java

-Goutham

On Sun, Jun 26, 2011 at 2:40 PM, Unico Homme <un...@apache.org> wrote:

> As far as I know this is not possible. Velocity is not powerful enough to
> do
> string manipulation, it's only a templating language.
>
> Actually I am running into the same limitation.
>
> For this to work you would need to put a custom object into the Velocity
> context that parses the artifactId property and exposes the data to the
> template. Currently this is not possible.
>
> I've found several mails on the user list that mentioned similar
> requirements: a mechanism in the archetype plugin to hook in custom
> velocity
> context objects.
>
> Additionally I've found [1], where the same is mentioned and from which I
> conclude that such an addition to the archetype plugin would be welcome and
> possible.
>
> This mail describes the possibility of user defined hooks that get called
> while preparing the velocity context to enhance the velocity context.
> However I don't readily see how such a hook could be loaded. I assume such
> a
> hook would be packaged together with the archetype template archive. This
> archetype template archive is not a dependency on the maven classpath as
> far
> as I know.
>
> Of course, usually you can add extra dependencies when you configure a
> plugin in the pom. However, the archetype plugin is special in that
> normally
> when you use archetype:generate you will not have any pom yet.
>
> So it puzzles me how in [1] JvZ imagined this was going to work.
>
> Anyone have suggestions?
>
>
> 1.
>
> http://maven.40175.n5.nabble.com/Archetype-capabilities-limitations-td216158.html#a216159
>
>
>
> On Thu, Jun 23, 2011 at 8:20 PM, Christian Schuhegger <
> Christian.Schuhegger@gmx.de> wrote:
>
> > Hello list,
> >
> > I am writing a maven archetype and it would be useful to convert an
> > ${artifactId} (e.g. my.nice.little.project) into a path:
> > my/nice/little/project.
> >
> > If this is possible, could somebody please point me to the relevant
> > documentation? I did not find it via google.
> >
> > Many thanks,
> > --
> > Christian Schuhegger
> > http://www.el-chef.de/
> >
> >
> > ------------------------------**------------------------------**---------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.**org<
> dev-unsubscribe@maven.apache.org>
> > For additional commands, e-mail: dev-help@maven.apache.org
> >
> >
>

Re: Question about maven archetype: how to convert ${artifactId} into a file system path?

Posted by Unico Homme <un...@apache.org>.
As far as I know this is not possible. Velocity is not powerful enough to do
string manipulation, it's only a templating language.

Actually I am running into the same limitation.

For this to work you would need to put a custom object into the Velocity
context that parses the artifactId property and exposes the data to the
template. Currently this is not possible.

I've found several mails on the user list that mentioned similar
requirements: a mechanism in the archetype plugin to hook in custom velocity
context objects.

Additionally I've found [1], where the same is mentioned and from which I
conclude that such an addition to the archetype plugin would be welcome and
possible.

This mail describes the possibility of user defined hooks that get called
while preparing the velocity context to enhance the velocity context.
However I don't readily see how such a hook could be loaded. I assume such a
hook would be packaged together with the archetype template archive. This
archetype template archive is not a dependency on the maven classpath as far
as I know.

Of course, usually you can add extra dependencies when you configure a
plugin in the pom. However, the archetype plugin is special in that normally
when you use archetype:generate you will not have any pom yet.

So it puzzles me how in [1] JvZ imagined this was going to work.

Anyone have suggestions?


1.
http://maven.40175.n5.nabble.com/Archetype-capabilities-limitations-td216158.html#a216159



On Thu, Jun 23, 2011 at 8:20 PM, Christian Schuhegger <
Christian.Schuhegger@gmx.de> wrote:

> Hello list,
>
> I am writing a maven archetype and it would be useful to convert an
> ${artifactId} (e.g. my.nice.little.project) into a path:
> my/nice/little/project.
>
> If this is possible, could somebody please point me to the relevant
> documentation? I did not find it via google.
>
> Many thanks,
> --
> Christian Schuhegger
> http://www.el-chef.de/
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.**org<de...@maven.apache.org>
> For additional commands, e-mail: dev-help@maven.apache.org
>
>