You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Benson Margulies <bi...@gmail.com> on 2011/06/15 17:09:46 UTC
An example of a plugin that uses the as an actual
live classpath ...
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?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: An example of a plugin that uses the as an actual
live classpath ...
Posted by Benson Margulies <bi...@gmail.com>.
Point taken.
On Wed, Jun 15, 2011 at 11:40 AM, Stephen Connolly
<st...@gmail.com> wrote:
> Beware...you cause subtle break in maven if you rely on them being jars.
>
> if they have gone only as far as the compile phase in the lifecycle
> then they will not be jars but instead
> ${project.build.outputDirectory}s for each of the dependencies...
>
> The very best Maven Way plugins respect that difference enabling one
> to run tests and build everything without having to go as far as
> package in the lifecycle
>
> -Stephen
>
> On 15 June 2011 16:37, Benson Margulies <bi...@gmail.com> wrote:
>> Why? It just wants to construct a list of jars and pass them to the
>> compiler, not actually include them in a classloader. Not that's it is
>> especially hard to get from one to the other.
>>
>> On Wed, Jun 15, 2011 at 11:12 AM, Jochen Wiedmann
>> <jo...@gmail.com> wrote:
>>> The maven-compiler-plugin should do exactly that.
>>>
>>> On Wed, Jun 15, 2011 at 5:09 PM, Benson Margulies <bi...@gmail.com> 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?
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Capitalism is the astounding belief that the most wickedest of men
>>> will do the most wickedest of things for the greatest good of
>>> everyone.
>>>
>>> John Maynard Keynes (http://en.wikiquote.org/wiki/Keynes)
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>
> ---------------------------------------------------------------------
> 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: An example of a plugin that uses the as an actual
live classpath ...
Posted by Stephen Connolly <st...@gmail.com>.
Beware...you cause subtle break in maven if you rely on them being jars.
if they have gone only as far as the compile phase in the lifecycle
then they will not be jars but instead
${project.build.outputDirectory}s for each of the dependencies...
The very best Maven Way plugins respect that difference enabling one
to run tests and build everything without having to go as far as
package in the lifecycle
-Stephen
On 15 June 2011 16:37, Benson Margulies <bi...@gmail.com> wrote:
> Why? It just wants to construct a list of jars and pass them to the
> compiler, not actually include them in a classloader. Not that's it is
> especially hard to get from one to the other.
>
> On Wed, Jun 15, 2011 at 11:12 AM, Jochen Wiedmann
> <jo...@gmail.com> wrote:
>> The maven-compiler-plugin should do exactly that.
>>
>> On Wed, Jun 15, 2011 at 5:09 PM, Benson Margulies <bi...@gmail.com> 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?
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>>
>>
>>
>>
>> --
>> Capitalism is the astounding belief that the most wickedest of men
>> will do the most wickedest of things for the greatest good of
>> everyone.
>>
>> John Maynard Keynes (http://en.wikiquote.org/wiki/Keynes)
>>
>> ---------------------------------------------------------------------
>> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: An example of a plugin that uses the as an
actual live classpath ...
Posted by Martin Gainty <mg...@hotmail.com>.
in J2EE world one must be aware of which CL one where a class load happens
does maven have a architecture document which delineates classloader boundaries? e.g.
System CL starts and passes to Plexus Container
Plexus container is initialised
Plexus initialises plugins
I assume Plexus is implementing its own CL? or is this still system CL?
does Plexus container quiesce and handoff to system CL occur during an execution of ant?
it would be helpful to have these architectural issues identified and mapped out
..I know Its a dumb question but i needed to ask..
thanks,
Martin Gainty
______________________________________________
Jogi és Bizalmassági kinyilatkoztatás/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Ez az
üzenet bizalmas. Ha nem ön az akinek szánva volt, akkor kérjük, hogy
jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának
készítése nem megengedett. Ez az üzenet csak ismeret cserét szolgál és
semmiféle jogi alkalmazhatósága sincs. Mivel az electronikus üzenetek
könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet
ezen üzenet tartalma miatt.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
> Date: Wed, 15 Jun 2011 11:37:51 -0400
> Subject: Re: An example of a plugin that uses the <dependencies/> as an actual live classpath ...
> From: bimargulies@gmail.com
> To: users@maven.apache.org
>
> Why? It just wants to construct a list of jars and pass them to the
> compiler, not actually include them in a classloader. Not that's it is
> especially hard to get from one to the other.
>
> On Wed, Jun 15, 2011 at 11:12 AM, Jochen Wiedmann
> <jo...@gmail.com> wrote:
> > The maven-compiler-plugin should do exactly that.
> >
> > On Wed, Jun 15, 2011 at 5:09 PM, Benson Margulies <bi...@gmail.com> 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?
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >> For additional commands, e-mail: users-help@maven.apache.org
> >>
> >>
> >
> >
> >
> > --
> > Capitalism is the astounding belief that the most wickedest of men
> > will do the most wickedest of things for the greatest good of
> > everyone.
> >
> > John Maynard Keynes (http://en.wikiquote.org/wiki/Keynes)
> >
> > ---------------------------------------------------------------------
> > 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: An example of a plugin that uses the as an actual
live classpath ...
Posted by Benson Margulies <bi...@gmail.com>.
Why? It just wants to construct a list of jars and pass them to the
compiler, not actually include them in a classloader. Not that's it is
especially hard to get from one to the other.
On Wed, Jun 15, 2011 at 11:12 AM, Jochen Wiedmann
<jo...@gmail.com> wrote:
> The maven-compiler-plugin should do exactly that.
>
> On Wed, Jun 15, 2011 at 5:09 PM, Benson Margulies <bi...@gmail.com> 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?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>
>
>
> --
> Capitalism is the astounding belief that the most wickedest of men
> will do the most wickedest of things for the greatest good of
> everyone.
>
> John Maynard Keynes (http://en.wikiquote.org/wiki/Keynes)
>
> ---------------------------------------------------------------------
> 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: An example of a plugin that uses the as an actual
live classpath ...
Posted by Jochen Wiedmann <jo...@gmail.com>.
The maven-compiler-plugin should do exactly that.
On Wed, Jun 15, 2011 at 5:09 PM, Benson Margulies <bi...@gmail.com> 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?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
--
Capitalism is the astounding belief that the most wickedest of men
will do the most wickedest of things for the greatest good of
everyone.
John Maynard Keynes (http://en.wikiquote.org/wiki/Keynes)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: An example of a plugin that uses the as an actual
live classpath ...
Posted by Benson Margulies <bi...@gmail.com>.
I needed the former, I derived code much like Jörg's, it works, and I
wonder if there was some advantage to talking to Aether instead, but
not for very long.
On Fri, Jun 17, 2011 at 3:36 AM, Mark Struberg <st...@yahoo.de> wrote:
> 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 <jo...@scalaris.com> wrote:
>
>> From: Jörg Schaible <jo...@scalaris.com>
>> Subject: Re: An example of a plugin that uses the <dependencies/> as an actual live classpath ...
>> To: users@maven.apache.org
>> 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: 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: An example of a plugin that uses the as an actual live classpath ...
Posted by Mark Struberg <st...@yahoo.de>.
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 <jo...@scalaris.com> wrote:
> From: Jörg Schaible <jo...@scalaris.com>
> Subject: Re: An example of a plugin that uses the <dependencies/> as an actual live classpath ...
> To: users@maven.apache.org
> 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: 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: An example of a plugin that uses the as an actual live classpath ...
Posted by Jörg Schaible <jo...@scalaris.com>.
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: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: An example of a plugin that uses the as an actual live classpath ...
Posted by Mark Struberg <st...@yahoo.de>.
You might look at the way we did it for the openjpa-maven-plugin:
https://svn.codehaus.org/mojo/trunk/mojo/openjpa-maven-plugin/src/main/java/org/codehaus/mojo/openjpa/AbstractOpenJpaMojo.java
check the extendRealmClasspath() method.
LieGrue,
strub
--- On Wed, 6/15/11, Benson Margulies <bi...@gmail.com> wrote:
> From: Benson Margulies <bi...@gmail.com>
> Subject: An example of a plugin that uses the <dependencies/> as an actual live classpath ...
> To: "Maven Users List" <us...@maven.apache.org>
> Date: Wednesday, June 15, 2011, 3:09 PM
> 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?
>
> ---------------------------------------------------------------------
> 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