You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Dennis Lundberg <de...@apache.org> on 2011/07/05 00:11:04 UTC

How to replace an old MavenEmbedder?

Hi

I'm trying to replace an old version 2.0 MavenEmbedder in the
aspectj-maven-plugin, over at mojo@codehaus. That's because we can't
upgrade other Maven core dependencies while the embedder is being used.

In a class that extends AbstractMojoTestCase we have this code:

        MavenEmbedder embedder = new MavenEmbedder();

        embedder.setClassLoader(
Thread.currentThread().getContextClassLoader() );
        embedder.setLogger( new MavenEmbedderConsoleLogger() );
        embedder.start();
        ArtifactRepository localRepository = embedder.getLocalRepository();

Now the only thing the embedder is used for is to create the
localRepository variable. There must be a better way to do this, but I
can't find out how. Does anyone have an idea they can share?


-- 
Dennis Lundberg

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


Re: How to replace an old MavenEmbedder?

Posted by Olivier Lamy <ol...@apache.org>.
Hello,
You can have a look at the "simple" embedder, I have done for jenkins [1].
Didn't have time yet to add this here (as it need some cleanup before).
Or the recent stuff from John here [2]

-- 
Olivier Lamy
http://twitter.com/olamy | http://www.linkedin.com/in/olamy

[1] https://github.com/jenkinsci/lib-jenkins-maven-embedder
[2] http://svn.apache.org/repos/asf/maven/sandbox/trunk/mae/

2011/7/5 Benson Margulies <bi...@gmail.com>:
> You have correctly diagnosed my incorrect diagnosis.
>
> On Tue, Jul 5, 2011 at 4:14 AM, Dennis Lundberg <de...@apache.org> wrote:
>> On 2011-07-05 01:51, Benson Margulies wrote:
>>> On Mon, Jul 4, 2011 at 6:11 PM, Dennis Lundberg <de...@apache.org> wrote:
>>>> Hi
>>>>
>>>> I'm trying to replace an old version 2.0 MavenEmbedder in the
>>>> aspectj-maven-plugin, over at mojo@codehaus. That's because we can't
>>>> upgrade other Maven core dependencies while the embedder is being used.
>>>>
>>>> In a class that extends AbstractMojoTestCase we have this code:
>>> Start at git://git.eclipse.org/gitroot/m2e/m2e-core.git.
>>>
>>> Then look in org.eclipse.m2e.core.
>>>
>>> To see how the new m2e code does this stuff.
>>
>> Thank you Benson. I see now that I wasn't very clear when I wrote the
>> above. What I am trying to do is remove the embedder, because I don't
>> believe it is needed anymore.
>>
>> I guess the m2e code will show me how to use the Maven 3 embedder, right?
>>
>>>>
>>>>        MavenEmbedder embedder = new MavenEmbedder();
>>>>
>>>>        embedder.setClassLoader(
>>>> Thread.currentThread().getContextClassLoader() );
>>>>        embedder.setLogger( new MavenEmbedderConsoleLogger() );
>>>>        embedder.start();
>>>>        ArtifactRepository localRepository = embedder.getLocalRepository();
>>>>
>>>> Now the only thing the embedder is used for is to create the
>>>> localRepository variable. There must be a better way to do this, but I
>>>> can't find out how. Does anyone have an idea they can share?
>>>>
>>>>
>>>> --
>>>> Dennis Lundberg
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>>>> For additional commands, e-mail: dev-help@maven.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: dev-help@maven.apache.org
>>>
>>>
>>
>>
>> --
>> Dennis Lundberg
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>> For additional commands, e-mail: dev-help@maven.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

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


Re: How to replace an old MavenEmbedder?

Posted by Benson Margulies <bi...@gmail.com>.
You have correctly diagnosed my incorrect diagnosis.

On Tue, Jul 5, 2011 at 4:14 AM, Dennis Lundberg <de...@apache.org> wrote:
> On 2011-07-05 01:51, Benson Margulies wrote:
>> On Mon, Jul 4, 2011 at 6:11 PM, Dennis Lundberg <de...@apache.org> wrote:
>>> Hi
>>>
>>> I'm trying to replace an old version 2.0 MavenEmbedder in the
>>> aspectj-maven-plugin, over at mojo@codehaus. That's because we can't
>>> upgrade other Maven core dependencies while the embedder is being used.
>>>
>>> In a class that extends AbstractMojoTestCase we have this code:
>> Start at git://git.eclipse.org/gitroot/m2e/m2e-core.git.
>>
>> Then look in org.eclipse.m2e.core.
>>
>> To see how the new m2e code does this stuff.
>
> Thank you Benson. I see now that I wasn't very clear when I wrote the
> above. What I am trying to do is remove the embedder, because I don't
> believe it is needed anymore.
>
> I guess the m2e code will show me how to use the Maven 3 embedder, right?
>
>>>
>>>        MavenEmbedder embedder = new MavenEmbedder();
>>>
>>>        embedder.setClassLoader(
>>> Thread.currentThread().getContextClassLoader() );
>>>        embedder.setLogger( new MavenEmbedderConsoleLogger() );
>>>        embedder.start();
>>>        ArtifactRepository localRepository = embedder.getLocalRepository();
>>>
>>> Now the only thing the embedder is used for is to create the
>>> localRepository variable. There must be a better way to do this, but I
>>> can't find out how. Does anyone have an idea they can share?
>>>
>>>
>>> --
>>> Dennis Lundberg
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: dev-help@maven.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>> For additional commands, e-mail: dev-help@maven.apache.org
>>
>>
>
>
> --
> Dennis Lundberg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

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


Re: How to replace an old MavenEmbedder?

Posted by Igor Fedorenko <ig...@ifedorenko.com>.
Have a look at #getLocalRepository() method around line 352 in [1].

[1] 
http://git.eclipse.org/c/m2e/m2e-core.git/tree/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java?id=releases/1.0/1.0.0.20110607-2117

--
Regards,
Igor

On 11-07-05 12:14 PM, Dennis Lundberg wrote:
> On 2011-07-05 01:51, Benson Margulies wrote:
>> On Mon, Jul 4, 2011 at 6:11 PM, Dennis Lundberg<de...@apache.org>  wrote:
>>> Hi
>>>
>>> I'm trying to replace an old version 2.0 MavenEmbedder in the
>>> aspectj-maven-plugin, over at mojo@codehaus. That's because we can't
>>> upgrade other Maven core dependencies while the embedder is being used.
>>>
>>> In a class that extends AbstractMojoTestCase we have this code:
>> Start at git://git.eclipse.org/gitroot/m2e/m2e-core.git.
>>
>> Then look in org.eclipse.m2e.core.
>>
>> To see how the new m2e code does this stuff.
>
> Thank you Benson. I see now that I wasn't very clear when I wrote the
> above. What I am trying to do is remove the embedder, because I don't
> believe it is needed anymore.
>
> I guess the m2e code will show me how to use the Maven 3 embedder, right?
>
>>>
>>>         MavenEmbedder embedder = new MavenEmbedder();
>>>
>>>         embedder.setClassLoader(
>>> Thread.currentThread().getContextClassLoader() );
>>>         embedder.setLogger( new MavenEmbedderConsoleLogger() );
>>>         embedder.start();
>>>         ArtifactRepository localRepository = embedder.getLocalRepository();
>>>
>>> Now the only thing the embedder is used for is to create the
>>> localRepository variable. There must be a better way to do this, but I
>>> can't find out how. Does anyone have an idea they can share?
>>>
>>>
>>> --
>>> Dennis Lundberg
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: dev-help@maven.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>> For additional commands, e-mail: dev-help@maven.apache.org
>>
>>
>
>

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


Re: How to replace an old MavenEmbedder?

Posted by Dennis Lundberg <de...@apache.org>.
On 2011-07-05 01:51, Benson Margulies wrote:
> On Mon, Jul 4, 2011 at 6:11 PM, Dennis Lundberg <de...@apache.org> wrote:
>> Hi
>>
>> I'm trying to replace an old version 2.0 MavenEmbedder in the
>> aspectj-maven-plugin, over at mojo@codehaus. That's because we can't
>> upgrade other Maven core dependencies while the embedder is being used.
>>
>> In a class that extends AbstractMojoTestCase we have this code:
> Start at git://git.eclipse.org/gitroot/m2e/m2e-core.git.
> 
> Then look in org.eclipse.m2e.core.
> 
> To see how the new m2e code does this stuff.

Thank you Benson. I see now that I wasn't very clear when I wrote the
above. What I am trying to do is remove the embedder, because I don't
believe it is needed anymore.

I guess the m2e code will show me how to use the Maven 3 embedder, right?

>>
>>        MavenEmbedder embedder = new MavenEmbedder();
>>
>>        embedder.setClassLoader(
>> Thread.currentThread().getContextClassLoader() );
>>        embedder.setLogger( new MavenEmbedderConsoleLogger() );
>>        embedder.start();
>>        ArtifactRepository localRepository = embedder.getLocalRepository();
>>
>> Now the only thing the embedder is used for is to create the
>> localRepository variable. There must be a better way to do this, but I
>> can't find out how. Does anyone have an idea they can share?
>>
>>
>> --
>> Dennis Lundberg
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>> For additional commands, e-mail: dev-help@maven.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
> 
> 


-- 
Dennis Lundberg

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


Re: How to replace an old MavenEmbedder?

Posted by Benson Margulies <bi...@gmail.com>.
On Mon, Jul 4, 2011 at 6:11 PM, Dennis Lundberg <de...@apache.org> wrote:
> Hi
>
> I'm trying to replace an old version 2.0 MavenEmbedder in the
> aspectj-maven-plugin, over at mojo@codehaus. That's because we can't
> upgrade other Maven core dependencies while the embedder is being used.
>
> In a class that extends AbstractMojoTestCase we have this code:
Start at git://git.eclipse.org/gitroot/m2e/m2e-core.git.

Then look in org.eclipse.m2e.core.

To see how the new m2e code does this stuff.

>
>        MavenEmbedder embedder = new MavenEmbedder();
>
>        embedder.setClassLoader(
> Thread.currentThread().getContextClassLoader() );
>        embedder.setLogger( new MavenEmbedderConsoleLogger() );
>        embedder.start();
>        ArtifactRepository localRepository = embedder.getLocalRepository();
>
> Now the only thing the embedder is used for is to create the
> localRepository variable. There must be a better way to do this, but I
> can't find out how. Does anyone have an idea they can share?
>
>
> --
> Dennis Lundberg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

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


Re: How to replace an old MavenEmbedder?

Posted by Dennis Lundberg <de...@apache.org>.
On 2011-07-05 00:22, Stephen Connolly wrote:
> Settings.getLocalRepository()?

> Alternatively filter a test resource and have
> ${settings.localRepository} as the filtered value

Well, I really need an ArtifactRepository object, not just the path to
the local repository. I suppose this can be looked up by Plexus somehow.

> 
> On 4 July 2011 23:11, Dennis Lundberg <de...@apache.org> wrote:
>> Hi
>>
>> I'm trying to replace an old version 2.0 MavenEmbedder in the
>> aspectj-maven-plugin, over at mojo@codehaus. That's because we can't
>> upgrade other Maven core dependencies while the embedder is being used.
>>
>> In a class that extends AbstractMojoTestCase we have this code:
>>
>>        MavenEmbedder embedder = new MavenEmbedder();
>>
>>        embedder.setClassLoader(
>> Thread.currentThread().getContextClassLoader() );
>>        embedder.setLogger( new MavenEmbedderConsoleLogger() );
>>        embedder.start();
>>        ArtifactRepository localRepository = embedder.getLocalRepository();
>>
>> Now the only thing the embedder is used for is to create the
>> localRepository variable. There must be a better way to do this, but I
>> can't find out how. Does anyone have an idea they can share?
>>
>>
>> --
>> Dennis Lundberg
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>> For additional commands, e-mail: dev-help@maven.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
> 
> 


-- 
Dennis Lundberg

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


Re: How to replace an old MavenEmbedder?

Posted by Stephen Connolly <st...@gmail.com>.
Settings.getLocalRepository()?

Alternatively filter a test resource and have
${settings.localRepository} as the filtered value

On 4 July 2011 23:11, Dennis Lundberg <de...@apache.org> wrote:
> Hi
>
> I'm trying to replace an old version 2.0 MavenEmbedder in the
> aspectj-maven-plugin, over at mojo@codehaus. That's because we can't
> upgrade other Maven core dependencies while the embedder is being used.
>
> In a class that extends AbstractMojoTestCase we have this code:
>
>        MavenEmbedder embedder = new MavenEmbedder();
>
>        embedder.setClassLoader(
> Thread.currentThread().getContextClassLoader() );
>        embedder.setLogger( new MavenEmbedderConsoleLogger() );
>        embedder.start();
>        ArtifactRepository localRepository = embedder.getLocalRepository();
>
> Now the only thing the embedder is used for is to create the
> localRepository variable. There must be a better way to do this, but I
> can't find out how. Does anyone have an idea they can share?
>
>
> --
> Dennis Lundberg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

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