James, Johan,

Please copy me on this if it goes off-list. I'm trying to write a MoJo that
uses a utility that uses Spring and I'm getting what I think is a
classloader issue. If you solve it for your case I suspect I can use the
same solution for my own issue: http://rafb.net/p/fOEW5I52.html

Thanks!
James

> Sorry, forget exactly what it is but if you can wait 12 hours I can look
> it up ;)
>
> Found it in some of the maven APIs if that helps.
>
> And no, not on every list ;)
>
> Johan
>
> I forget what it is - not at work an
>
> James Carman wrote:
>> Johan,
>>
>> What kind of objects should I expect in that list?
>>
>> James
>>
>> p.s. Are you on every mailing list? :-)
>>
>>
>> On 4/3/07, Johan Lindquist <[EMAIL PROTECTED]> wrote:
>>>
>>> Hi James,
>>>
>>> Try using the following property in you Mojo.
>>>
>>>     /**
>>>      * The classpath elements of the project.
>>>      *
>>>      * @parameter expression="${project.runtimeClasspathElements}" *
>>> @required
>>>      * @readonly
>>>      */
>>>     private List classpathElements;
>>>
>>> I think in this case, you would have to provide your own classloader
>>> for spring - the classloader for the Mojo does (as far as I understand)
>>> not see the project dependencies.
>>>
>>> cheers,
>>>
>>> Johan
>>>
>>>
>>> James Carman wrote:
>>> > Franz,
>>> >
>>> > Thanks for replying.  Let me explain it a bit more.  I was trying to
>>> gloss
>>> > over things a bit.  Basically, I'm using Spring to instantiate the
>>> bean:
>>> >
>>> > public class RunLoaderMojo extends AbstractMojo
>>> > {
>>> >    /**
>>> >     * @parameter property="loaderBean" expression="${loaderBean}" *
>>> @required
>>> >     */
>>> >    private String loaderBean;
>>> >
>>> >    public void execute() throws MojoExecutionException
>>> >    {
>>> >        // Load all META-INF/beans.xml files on classpath!
>>> >        ClassPathXmlApplicationContext ctx = new
>>> > ClassPathXmlApplicationContext("classpath*:META-INF/beans.xml");
>>> >        getLog().info("Running loader '" + loaderBean + "'..."); final
>>> Loader loader = ( Loader )ctx.getBean(loaderBean,
>>> Loader.class
>>> > );
>>> >        loader.execute();
>>> >    }
>>> >
>>> >    public String getLoaderBean()
>>> >    {
>>> >        return loaderBean;
>>> >    }
>>> >
>>> >    public void setLoaderBean(String loaderBean)
>>> >    {
>>> >        this.loaderBean = loaderBean;
>>> >    }
>>> > }
>>> >
>>> > That's my mojo class.  Then, I want to use it in a project like this:
>>> >
>>> > <plugin>
>>> >  <groupId>com.myco.myproj</groupId>
>>> >  <artifactId>maven-loader-plugin</artifactId>
>>> > </plugin>
>>> >
>>> > Then, I try executing the plugin like this (from the project dir):
>>> >
>>> > mvn loader:run -DloaderBean=exampleLoader
>>> >
>>> > If I try to use a beans.xml file that's defined within my project, it
>>> doesn't even see it on the classpath.  If I put it into one of my
>>> project's
>>> > dependencies (another module of mine), then it sees it fine.  It just
>>> doesn't see anything within the enclosing project.  Does that make
>>> sense?
>>> >
>>> > James
>>> >
>>> > On 4/3/07, franz see <[EMAIL PROTECTED]> wrote:
>>> >>
>>> >>
>>> >> Good day to you, James,
>>> >>
>>> >> Not sure how you're instantiating those classes. Anyway, try adding
>>> those
>>> >> classes in your plugin's dependency ( see [1] ). And if you need the
>>> path
>>> >> to
>>> >> those binaries, see Getting dependency artifact path of [2].
>>> >>
>>> >> Cheers,
>>> >> Franz
>>> >>
>>> >> [1]
>>> >>
>>> http://maven.apache.org/ref/current/maven-model/maven.html#class_plugin
>>> >> [2] http://docs.codehaus.org/display/MAVENUSER/
>>> >>
>>> >>
>>> >> James Carman-3 wrote:
>>> >> >
>>> >> > All,
>>> >> >
>>> >> > I am developing a simple mojo which needs to access classes
>>> defined
>>> >> within
>>> >> > the project in which it is used.  But, they don't seem to be
>>> >> visible.  I
>>> >> > am
>>> >> > writing a mojo that can execute a "loader" (loads data into our
>>> >> database)
>>> >> > object.  It takes a parameter that tells which loader class to
>>> use. Anyway,
>>> >> > I now want to use that mojo within another project to run a loader
>>> >> defined
>>> >> > within that project.  When I try to instantiate that class, it's
>>> not available.  Is there something special I need to do to tell
>>> Maven to include
>>> >> > the current project's classpath in my mojo's environment?
>>> >> >
>>> >> > James
>>> >> >
>>> >> >
>>> >>
>>> >> --
>>> >> View this message in context:
>>> >>
>>> http://www.nabble.com/Using-containing-project%27s-classpath-within-mojo...-tf3519722s177.html#a9821549
>>>
>>> >>
>>> >> Sent from the Maven - Users mailing list archive at Nabble.com.
>>> >>
>>> >>
>>> >> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> >> For additional commands, e-mail: [EMAIL PROTECTED]
>>> >>
>>> >>
>>> >
>>>
>>> --
>>> you too?
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>
>
> --
> you too?
>
> --------------------------------------------------------------------- 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