Johan, The only thing that shows up when I look at what's in that list is the target/classes directory of the containing project. Is that right? Shouldn't the dependencies show up too?
James On 4/4/07, James Carman <[EMAIL PROTECTED]> wrote:
Johan, I think I see what you mean. I'll give it a whirl when I get to work today. Thanks for your help! James On 4/4/07, Johan Lindquist <[EMAIL PROTECTED]> wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi James & James, > > The classpath element list is simply a list of strings (to locations > within the repository). Please see attached Mojo for a simple example. > > One issue with this is that some classes (in your case, most likely the > spring classes) will be loaded in the URLClassloader as well as in the > Mojo class loader. So you may have to add a reference to the parent > loader in this case (and filter out any duplicate libraries from the > above list. Did that make sense? > > Cheers, > > Johan > > > James CE Johnson wrote: > > 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] > > > > > > - -- > you too? > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.6 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFGE04z1Tv8wj7aQ34RAiRkAJ49FAUcqoTmbq75O1QbQ7sBslATZACggZ8J > rzFTCXR2donhJ6vXVAEB7/A= > =h/ze > -----END PGP SIGNATURE----- > >
