You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Vincent Massol <vm...@pivolis.com> on 2004/05/04 08:26:25 UTC

FW: [maven2] Anything Groovy in Maven2?

Hi Ant developers,

There's some discussion raging in Maven land for Maven2 as whether we
could/should reuse Ant tasks in embedded mode from within Maven plugins
written in java.

The contentious point is that it that some believe it won't be possible
to due to the strong tie of Ant tasks to the AntClassloader (see the
message below for an example of what I mean).

More specifically, I'd like to know why the JUnit task in Ant 1.6 has
now lots of dependencies on the Ant classloader. How can we now reuse it
in embedded mode?

Thanks
-Vincent

> -----Original Message-----
> From: Vincent Massol [mailto:vmassol@pivolis.com]
> Sent: 04 May 2004 08:21
> To: 'Maven Users List'
> Subject: RE: [maven2] Anything Groovy in Maven2?
> 
> 
> 
> > -----Original Message-----
> > From: Jason van Zyl [mailto:jvanzyl@maven.org]
> > Sent: 03 May 2004 23:20
> > To: Maven Users List
> > Subject: RE: [maven2] Anything Groovy in Maven2?
> >
> > On Mon, 2004-05-03 at 15:03, Vincent Massol wrote:
> >
> > > funnily, I'm running the JUnit task in embedded mode for the abbot
> > > plugin I've checked in a few days ago and .... believe it or
not... it
> > > works :-)
> > >
> > > Here's the url: http://tinyurl.com/2uy9b (look at the
> > > executeAntJunitTestRunner method).
> >
> > You are running that outside the context of an AntClassLoader? I
think
> > our notions of embedding are different i.e. I doubt something like
IDEA
> > or Eclipse are using the Ant JUnitTask internally. I could never get
it
> > work correctly without forking which I don't consider acceptable for
> > embedding.
> 
> Just to be sure, I've printed the CL used. Here's the output:
> 
> Classloader = sun.misc.Launcher$AppClassLoader@e80a59
> 
> Also, you can notice in the code that I have:
> 
> // Do not fork so that we use the same classpath that was used to
> // start this class.
> junit.setFork(false);
> 
> oh... I think I know what could be your problem. I'm running with Ant
> 1.5.x and you must be using Ant 1.6.x. I've just checked the
> JUnitTask.java code and it seems the Ant team has added some CL code
for
> Ant 1.6 which is not present for Ant 1.5.x. Maybe that's causing the
> problem. I don't know why they did this. I'll ask.
> 
> [snip]
> 
> -Vincent



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: FW: [maven2] Anything Groovy in Maven2?

Posted by Steve Loughran <st...@iseran.com>.
Stefan Bodewig wrote:

> On Tue, 4 May 2004, Vincent Massol <vm...@pivolis.com> wrote:
> 
> 
>>There's some discussion raging in Maven land for Maven2 as whether
>>we could/should reuse Ant tasks in embedded mode from within Maven
>>plugins written in java.
> 
> 
> Well, whether you should is beyond our opinion 8-)
> 
> "could", I'd say yes.  If you realize that you can't that probably
> means that Ant tasks aren't as embeddable/reusable as we'd like them
> to be.  And then we should probably fix that.
> 
> Tomcat's Jasper embeds Ant's javac task without using Ant's runtime
> environment IIRC, so at least for this task, embedding seems to work.
> I must admit that I don't know how many hoops the Jasper folks had to
> jump through, though.
> 

commons launcher, which is 'based on tomcat', uses ant as a bootloader 
for applications; it may be the case that tomcat does use the ant 
runtime after all. But I havent looked at the source to see.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: FW: [maven2] Anything Groovy in Maven2?

Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 4 May 2004, Vincent Massol <vm...@pivolis.com> wrote:
>> From: Stefan Bodewig [mailto:bodewig@apache.org]

>> If the only embedder of Ant tasks you know is Ant, it is hard to
>> see that you are creating a problem for other embedders.
> 
> True. But you could easily create a sample project in Ant CVS that
> would use Ant task in embedded mode. It would serve as a functional
> test bed.

Coding it is the easy part.  Imagining what could lead to problems and
thus writing the functional tests is what we are (at least I am)
lacking.

> However, the code is:
> 
>     private int executeInVM(JUnitTest arg) throws BuildException {
> [...]
>         try {
>             log("Using System properties " + System.getProperties(),
>                 Project.MSG_VERBOSE);
>             createClassLoader();
>             if (classLoader != null) {
>                 classLoader.setThreadContextLoader();
>             }
> 
> Thus the AntClassloader is created in all cases.

No.  createClassloader leaves classLoader set to null if no user
classpath has been specified.

> In any case, thanks for your feedback.

You're welcome.

> I'll start using Ant tasks to write maven2 plugins soon. If I have
> problems, I'll contact the list again.

Please do.

Cheers

        Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


RE: FW: [maven2] Anything Groovy in Maven2?

Posted by Vincent Massol <vm...@pivolis.com>.

> -----Original Message-----
> From: Stefan Bodewig [mailto:bodewig@apache.org]
> Sent: 04 May 2004 09:20
> To: dev@ant.apache.org
> Subject: Re: FW: [maven2] Anything Groovy in Maven2?
> 
> On Tue, 4 May 2004, Vincent Massol <vm...@pivolis.com> wrote:
> 
> > There's some discussion raging in Maven land for Maven2 as whether
> > we could/should reuse Ant tasks in embedded mode from within Maven
> > plugins written in java.
> 
> Well, whether you should is beyond our opinion 8-)

:-)

> 
> "could", I'd say yes.  If you realize that you can't that probably
> means that Ant tasks aren't as embeddable/reusable as we'd like them
> to be.  And then we should probably fix that.

cool

> 
> Tomcat's Jasper embeds Ant's javac task without using Ant's runtime
> environment IIRC, so at least for this task, embedding seems to work.
> I must admit that I don't know how many hoops the Jasper folks had to
> jump through, though.
> 
> > The contentious point is that it that some believe it won't be
> > possible to due to the strong tie of Ant tasks to the AntClassloader
> 
> Maybe.  If so it probably is because of oversight/lack of thought when
> it comes to embeddabilty (is this a word after all?).  If the only
> embedder of Ant tasks you know is Ant, it is hard to see that you are
> creating a problem for other embedders.

True. But you could easily create a sample project in Ant CVS that would
use Ant task in embedded mode. It would serve as a functional test bed.
I do this in Cactus land and it has worked very well for us.

> 
> > More specifically, I'd like to know why the JUnit task in Ant 1.6
> > has now lots of dependencies on the Ant classloader.
> 
> I cannot see that much difference between JUnitTask in CVS HEAD and
> the version in 1.5.4.  Both create an AntClassLoader if and only if
> the user has specified a classpath (as attribute or nested element).
> Just the creation of the classloader has moved into a separate method.
> 
> Ant 1.6 has added the reloading attribute.  While 1.5.x creates a
> fresh classloader instance of AntClassLoader for each test, Ant 1.6
> can be instructed to use a single instance for all tests.

You're right. Sorry. I was misled by the refactoring that happened in
Ant 1.6 and the introduction of the new createClassLoader() method.

However, the code is:

    private int executeInVM(JUnitTest arg) throws BuildException {
[...]
        try {
            log("Using System properties " + System.getProperties(),
                Project.MSG_VERBOSE);
            createClassLoader();
            if (classLoader != null) {
                classLoader.setThreadContextLoader();
            }

Thus the AntClassloader is created in all cases. However, I've not
pushed the investigation further and maybe that it is created but not
used.

> 
> > How can we now reuse it in embedded mode?
> 
> Unless there is a bug that I didn't see on first glance,
> AntClassLoader shouldn't get used at all unless you specify a
> classpath to the task.
> 
> What exactly is the problem you see.  Are classes loaded from the
> wrong classloader?  Is the task or test-runner missing classes that
> should be there?

Yes, I need to gather more details... Our conversation may end here for
now for lack of information. I have asked Jason if he could provide the
code that is not working for him. We'll see...

In any case, thanks for your feedback. I'll start using Ant tasks to
write maven2 plugins soon. If I have problems, I'll contact the list
again.

Thanks
-Vincent


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: FW: [maven2] Anything Groovy in Maven2?

Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 4 May 2004, Vincent Massol <vm...@pivolis.com> wrote:

> There's some discussion raging in Maven land for Maven2 as whether
> we could/should reuse Ant tasks in embedded mode from within Maven
> plugins written in java.

Well, whether you should is beyond our opinion 8-)

"could", I'd say yes.  If you realize that you can't that probably
means that Ant tasks aren't as embeddable/reusable as we'd like them
to be.  And then we should probably fix that.

Tomcat's Jasper embeds Ant's javac task without using Ant's runtime
environment IIRC, so at least for this task, embedding seems to work.
I must admit that I don't know how many hoops the Jasper folks had to
jump through, though.

> The contentious point is that it that some believe it won't be
> possible to due to the strong tie of Ant tasks to the AntClassloader

Maybe.  If so it probably is because of oversight/lack of thought when
it comes to embeddabilty (is this a word after all?).  If the only
embedder of Ant tasks you know is Ant, it is hard to see that you are
creating a problem for other embedders.

> More specifically, I'd like to know why the JUnit task in Ant 1.6
> has now lots of dependencies on the Ant classloader.

I cannot see that much difference between JUnitTask in CVS HEAD and
the version in 1.5.4.  Both create an AntClassLoader if and only if
the user has specified a classpath (as attribute or nested element).
Just the creation of the classloader has moved into a separate method.

Ant 1.6 has added the reloading attribute.  While 1.5.x creates a
fresh classloader instance of AntClassLoader for each test, Ant 1.6
can be instructed to use a single instance for all tests.

> How can we now reuse it in embedded mode?

Unless there is a bug that I didn't see on first glance,
AntClassLoader shouldn't get used at all unless you specify a
classpath to the task.

What exactly is the problem you see.  Are classes loaded from the
wrong classloader?  Is the task or test-runner missing classes that
should be there?

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: FW: [maven2] Anything Groovy in Maven2?

Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 4 May 2004, Vincent Massol <vm...@pivolis.com> wrote:

> There's some discussion raging in Maven land for Maven2 as whether
> we could/should reuse Ant tasks in embedded mode from within Maven
> plugins written in java.

Well, whether you should is beyond our opinion 8-)

"could", I'd say yes.  If you realize that you can't that probably
means that Ant tasks aren't as embeddable/reusable as we'd like them
to be.  And then we should probably fix that.

Tomcat's Jasper embeds Ant's javac task without using Ant's runtime
environment IIRC, so at least for this task, embedding seems to work.
I must admit that I don't know how many hoops the Jasper folks had to
jump through, though.

> The contentious point is that it that some believe it won't be
> possible to due to the strong tie of Ant tasks to the AntClassloader

Maybe.  If so it probably is because of oversight/lack of thought when
it comes to embeddabilty (is this a word after all?).  If the only
embedder of Ant tasks you know is Ant, it is hard to see that you are
creating a problem for other embedders.

> More specifically, I'd like to know why the JUnit task in Ant 1.6
> has now lots of dependencies on the Ant classloader.

I cannot see that much difference between JUnitTask in CVS HEAD and
the version in 1.5.4.  Both create an AntClassLoader if and only if
the use has specified a classpath (as attribute or nested element).
Just the creation of the classloader has moved into a separate method.

Ant 1.6 has added the reloading attribute.  While 1.5.x creates a
fresh classloader instance of AntClassLoader for each test, Ant 1.6
can be instructed to use a single instance for all tests.

> How can we now reuse it in embedded mode?

Unless there is a bug that I don't see on first glance, AntClassLoader
shouldn't get used at all unless you specify a classpath to the task.
What is the problem you see?

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org