You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Allan Ramirez <ar...@exist.com> on 2005/09/30 04:03:57 UTC
[m2b2] reading velocity template from external projects
Hi everyone,
I have this plugin that can read a velocity template, but the template
must be in the classpath of the plugin to read it.
Now, I am trying to modify the plugin which it can able to read
templates from other projects. Any ideas?
From my components.xml, I already tried to change the classpath
resource loader path to a common path
--------------------------------------------------------------------------------
<plexus>
<components>
<component>
<role>org.codehaus.plexus.velocity.VelocityComponent</role>
<implementation>org.codehaus.plexus.velocity.DefaultVelocityComponent</implementation>
<configuration>
<properties>
<property>
<name>resource.loader</name>
<value>classpath</value>
</property>
<property>
<name>classpath.resource.loader.class</name>
<value>org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader</value>
</property>
<property>
<name>classpath.resource.loader.path</name>
<value>C:\templates</value>
</property>
</properties>
</configuration>
</component>
</components>
</plexus>
-------------------------------------------------------------------------------
But still no luck and the output is :
[ERROR] ResourceManager : unable to find resource
'C:\templates\template.vm' in any resource loader.
[INFO]
----------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO]
----------------------------------------------------------------------------
[INFO] Reason: resource not found.
[INFO]
----------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Fri Sep 30 09:54:22 CST 2005
[INFO] Final Memory: 5M/10M
[INFO]
----------------------------------------------------------------------------
I s there a way on to make the resource loader path to read from the
project and not from the plugin?
Thanks
-allan
Re: [m2b2] reading velocity template from external projects
Posted by Jason van Zyl <ja...@maven.org>.
On Fri, 2005-09-30 at 10:03 +0800, Allan Ramirez wrote:
> Hi everyone,
>
> I have this plugin that can read a velocity template, but the template
> must be in the classpath of the plugin to read it.
> Now, I am trying to modify the plugin which it can able to read
> templates from other projects. Any ideas?
You can specify a parameter for the template as an URL and use the
URLResourceLoader buried in Velocity if you're looking for a general way
to locate a template.
So you can use:
http://svn.apache.org/viewcvs.cgi/jakarta/velocity/core/trunk/whiteboard/geir/URLResourceLoader.java?rev=191743&view=markup
Just make it part of the mojo.
You can also use the ContextClassLoaderResourceLoader which is part of
the plexus-velocity-component itself which is what the archetype
mechanism users. If you want to put your templates in a JAR, then create
your own classloader, add the JAR url and set the context classloader.
Or there's actually a JAR resource loader in velocity.
Or you can make your own resource loader :-)
--
jvz.
Jason van Zyl
jason at maven.org
http://maven.apache.org
We know what we are, but know not what we may be.
-- Shakespeare
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org