You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by John Fallows <jo...@gmail.com> on 2005/09/15 09:47:49 UTC

[m2] plugin classpath

Is it possible to add project dependencies to a plugin classpath?

Here's the usecase project layout.

project/
  api-module/
  impl-module/
  build-module/

The same plugin is used in both api-module and impl-module and needs
access to the same config files.

The build-module contains the common config files and delivers a
self-contained JAR.

The api-module and impl-module each depend on build-module.

Is there some way to get build-module onto the classpath for the
plugin, so that ClassLoader.getResource("...") will see into the
contents of the build-module JAR during plugin execution?

Perhaps <plugin><dependency/> ?

Kind Regards,
John Fallows.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: [m2] plugin classpath

Posted by Kenney Westerhof <ke...@apache.org>.
On Thu, 15 Sep 2005, John Fallows wrote:

Yes, specify @requiresDependencyResolution [compile|runtime|test]
at the class level javadoc. The project.getDependencies are just
empty artifacts, not resolved yet ( so no path ).

-- Kenney

> Makes sense - thanks.
>
> When I tried to implement this approach,
> project.getCompileClasspathElements() unexpectedly returned just the
> project build output directory, and project.getArtifacts() returned
> the empty set.  However, project.getDependencies() is populated as
> expected.
>
> The plugin executes during generate-sources phase, and is triggered
> implicitly by
>   m2 generate-sources
>
> Any ideas on how to get a fully resolved compile classpath?
>
> Kind Regards,
> John Fallows.
>
> On 9/15/05, Kenney Westerhof <fo...@neonics.com> wrote:
> > On Thu, 15 Sep 2005, John Fallows wrote:
> >
> > Hi,
> >
> > For now, you have to create an URLClassLoader and add the results
> > of project.getXXXClasspath() to it. Then use that classloader to call
> > getResource().
> >
> > Ofcourse, the build-project should be refferred to from the current
> > project in a dependency, but I think that's already the case..?
> >
> > -- Kenney
> >
> > > Is it possible to add project dependencies to a plugin classpath?
> > >
> > > Here's the usecase project layout.
> > >
> > > project/
> > >   api-module/
> > >   impl-module/
> > >   build-module/
> > >
> > > The same plugin is used in both api-module and impl-module and needs
> > > access to the same config files.
> > >
> > > The build-module contains the common config files and delivers a
> > > self-contained JAR.
> > >
> > > The api-module and impl-module each depend on build-module.
> > >
> > > Is there some way to get build-module onto the classpath for the
> > > plugin, so that ClassLoader.getResource("...") will see into the
> > > contents of the build-module JAR during plugin execution?
> > >
> > > Perhaps <plugin><dependency/> ?
> > >
> > > Kind Regards,
> > > John Fallows.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: users-help@maven.apache.org
> > >
> > >
> >
> > --
> > Kenney Westerhof
> > http://www.neonics.com
> > GPG public key: http://www.gods.nl/~forge/kenneyw.key
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

--
Kenney Westerhof
http://www.neonics.com
GPG public key: http://www.gods.nl/~forge/kenneyw.key

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: [m2] plugin classpath

Posted by John Fallows <jo...@gmail.com>.
Makes sense - thanks.

When I tried to implement this approach,
project.getCompileClasspathElements() unexpectedly returned just the
project build output directory, and project.getArtifacts() returned
the empty set.  However, project.getDependencies() is populated as
expected.

The plugin executes during generate-sources phase, and is triggered
implicitly by
  m2 generate-sources

Any ideas on how to get a fully resolved compile classpath?

Kind Regards,
John Fallows.

On 9/15/05, Kenney Westerhof <fo...@neonics.com> wrote:
> On Thu, 15 Sep 2005, John Fallows wrote:
> 
> Hi,
> 
> For now, you have to create an URLClassLoader and add the results
> of project.getXXXClasspath() to it. Then use that classloader to call
> getResource().
> 
> Ofcourse, the build-project should be refferred to from the current
> project in a dependency, but I think that's already the case..?
> 
> -- Kenney
> 
> > Is it possible to add project dependencies to a plugin classpath?
> >
> > Here's the usecase project layout.
> >
> > project/
> >   api-module/
> >   impl-module/
> >   build-module/
> >
> > The same plugin is used in both api-module and impl-module and needs
> > access to the same config files.
> >
> > The build-module contains the common config files and delivers a
> > self-contained JAR.
> >
> > The api-module and impl-module each depend on build-module.
> >
> > Is there some way to get build-module onto the classpath for the
> > plugin, so that ClassLoader.getResource("...") will see into the
> > contents of the build-module JAR during plugin execution?
> >
> > Perhaps <plugin><dependency/> ?
> >
> > Kind Regards,
> > John Fallows.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
> 
> --
> Kenney Westerhof
> http://www.neonics.com
> GPG public key: http://www.gods.nl/~forge/kenneyw.key
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: [m2] plugin classpath

Posted by Kenney Westerhof <fo...@neonics.com>.
On Thu, 15 Sep 2005, John Fallows wrote:

Hi,

For now, you have to create an URLClassLoader and add the results
of project.getXXXClasspath() to it. Then use that classloader to call
getResource().

Ofcourse, the build-project should be refferred to from the current
project in a dependency, but I think that's already the case..?

-- Kenney

> Is it possible to add project dependencies to a plugin classpath?
>
> Here's the usecase project layout.
>
> project/
>   api-module/
>   impl-module/
>   build-module/
>
> The same plugin is used in both api-module and impl-module and needs
> access to the same config files.
>
> The build-module contains the common config files and delivers a
> self-contained JAR.
>
> The api-module and impl-module each depend on build-module.
>
> Is there some way to get build-module onto the classpath for the
> plugin, so that ClassLoader.getResource("...") will see into the
> contents of the build-module JAR during plugin execution?
>
> Perhaps <plugin><dependency/> ?
>
> Kind Regards,
> John Fallows.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

--
Kenney Westerhof
http://www.neonics.com
GPG public key: http://www.gods.nl/~forge/kenneyw.key

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org