Kenney Westerhof wrote:
On Wed, 28 Sep 2005, Brian Moseley wrote:

Correct, target/classes is not in the classpath when executing maven on a
project. It will only be on the classpath during test excution.

I recommend you create a plugin containing the
org.osaf.cosmo.jackrabbit.RepositoryLoader, unless this is generated code.
>
Normally you don't use the project sources to build the project itself,
but split that out to a reusable plugin.

i'm not trying to build the project. let me explain.

my project is a server with an embedded content repository. i can get the server built and deployed, no problem. now i need to load some data in the repository, preferably reusing code from the server itself to access the repository. this is why i'm not super interested in writing a plugin.

i did try making a plugin subproject and moving org.osaf.cosmo.jackrabbit.RepositoryLoader into it, but then the plugin subproject has dependencies on code from the main project, which doesn't seem workable.

But if you really must, you can add the target/classes to the classpath
using some jelly magic. I've tried something like this but I can't create
the correct URL[] parameter, but this should give you a start:

    <j:new var="file" className="java.io.File">
      <j:arg value="target/classes"/>
    </j:new>
    <j:invoke var="url" method="toURL" on="${file}"/>

    <j:invokeStatic var="cthread" method="currentThread" 
className="java.lang.Thread"/>

    <j:invokeStatic var="urlclassloader"
      className="java.net.URLClassLoader"
      method="newInstance"
    >
    <j:arg type="java.net.URL"/> <!-- null, i hope; doesn't work, need [] -->
    <j:arg type="java.lang.ClassLoader" value="${cthread.contextClassLoader}"/>
    </j:invokeStatic>

    <j:invoke method="addURL" on="${urlclassloader}">
      <j:arg value="${url}"/>
    </j:invoke>

and then use the new classloader 'urlclassloader' to load your class.

to be honest, i haven't been able to make much sense of jelly other than to do pretty basic things. i have no real idea how to construct the URL[] parameter either :/

Another, better, option is to use define:classLoader
(see
http://jakarta.apache.org/commons/jelly/libs/define/tags.html#define:classLoader
)

but then your class needs to be a Tag.

now you've gone right over my head :) i understand the concept of making a custom tag, but i don't really get define:classLoader.

anyway, thanks for the suggestions. they've prompted to explore further in some of these areas that are still fuzzy for me.

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

Reply via email to