I think the question is ambiguous: Did he like to get the classpath of all dependencies of the current project to invoke a java method which needs those classes on the classpath (annotation scanning or enhancement, etc)?
Or does he like to contruct a classpath string which he can pass to a shell invocation? LieGrue, strub --- On Fri, 6/17/11, Jörg Schaible <[email protected]> wrote: > From: Jörg Schaible <[email protected]> > Subject: Re: An example of a plugin that uses the <dependencies/> as an > actual live classpath ... > To: [email protected] > Date: Friday, June 17, 2011, 7:27 AM > Benson Margulies wrote: > > > I find myself looking to create a plugin where, as > part of execution, > > it wants to create a classpath composed of the > declared dependencies. > > Can anyone suggest a model? > > Not sure, which plugin I used to look this up, but I had > once the need to > scan the compiled classes for annotations and to load them; > I had to build > my own classloader: > > ================ %< ================= > private ClassLoader getCompilationClassLoader() throws > DependencyResolutionRequiredException > { > final Log log = getLog(); > @SuppressWarnings("unchecked") > final List<String> classpathElements = > project.getCompileClasspathElements(); > > final List<URL> urls = new > ArrayList<URL>(); > for (final String classpathElement : > classpathElements) { > try { > final URL url = new > File(classpathElement).toURI().toURL(); > if (log.isDebugEnabled()) { > log.debug("Add to compilation > classpath: " + url.toString()); > } > urls.add(url); > } catch (final MalformedURLException e) { > log.warn("Cannot convert strange class > path element into URL: " + > classpathElement); > } > } > > return new URLClassLoader(urls.toArray(new > URL[urls.size()]), > Thread.currentThread().getContextClassLoader()); > } > ================ %< ================= > > - Jörg > > > --------------------------------------------------------------------- > 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]
