You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Benjamin Bentmann <be...@udo.edu> on 2007/10/26 20:44:29 UTC

Re: Execution of a AbstractMojoTestCase test from within Eclipse


Bateman, Patrick wrote:
> 
> The test works from within a Maven context, but when run it as a
> stand-alone test from within Eclipse the following stack trace is
> produced.
> 
> org.codehaus.plexus.component.repository.exception.ComponentLookupException:
> Component descriptor cannot be found in the component repository:
> org.apache.maven.plugin.Mojocom.qualcomm.uds.tools.qcgen:qcgen-maven-plugin:0.1:generate.
>             at
> org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:319)

I ran into this problem today using Maven 2.0.7 and
maven-plugin-testing-harness-1.1. After some debugging of Maven I figured
out that the DefaultPlexusContainer is missing a component called
"MavenPluginDiscoverer" when run inside Eclipse compared to a real Maven
run.

So I put maven-core.jar along with the dependency
maven-plugin-descriptor.jar on the Eclipse class path and now the Mojo
lookup works for me. Besides those JARs, one must also have the
"META-INF/maven/plugin.xml" for the plugin under test somewhere in the test
class path. The plugin.xml is obviously the file that is evaluated by the
MavenPluginDiscoverer and used to register the Mojos with the Plexus
container.

That's all kind of hacking. I would really appreciate some tweaks to the
testing harness that allows debugging using IDEs out-of-the-box.


Benjamin Bentmann
-- 
View this message in context: http://www.nabble.com/Execution-of-a-AbstractMojoTestCase-test-from-within-Eclipse-tf4034442s177.html#a13433155
Sent from the Maven Developers mailing list archive at Nabble.com.


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


Re: Execution of a AbstractMojoTestCase test from within Eclipse

Posted by Benjamin Bentmann <be...@udo.edu>.

Benjamin Bentmann wrote:
> 
> The later one gets the mojo from the caller and hence needs no lookup from
> the Plexus container.
> 

A warning:
Not looking up the mojo from the container seems to have a drawback:
Injection of components into mojo fields annotated with "@component" is
disabled and needs to be manually performed (e.g. using
setVariableValueToObject() or similar).


Benjamin Bentmann
-- 
View this message in context: http://www.nabble.com/Execution-of-a-AbstractMojoTestCase-test-from-within-Eclipse-tf4034442s177.html#a13536244
Sent from the Maven Developers mailing list archive at Nabble.com.


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


RE: Execution of a AbstractMojoTestCase test from within Eclipse

Posted by "Brian E. Fox" <br...@reply.infinity.nu>.
Interesting. I'm able to debug my unit tests from eclipse (dependency
and enforcer etc), but sometimes I need to run mvn test to get
everything setup correctly. I wonder if this fixes that.

-----Original Message-----
From: Benjamin Bentmann [mailto:benjamin.bentmann@udo.edu] 
Sent: Saturday, October 27, 2007 12:12 PM
To: dev@maven.apache.org
Subject: Re: Execution of a AbstractMojoTestCase test from within
Eclipse



Benjamin Bentmann wrote:
> 
> I would really appreciate some tweaks to the testing harness that
allows
> debugging using IDEs out-of-the-box.
> 

Well, it seems I just should have better studied the
AbstractMojoTestCase:
Besides lookupMojo(), it offers configureMojo(). The later one gets the
mojo
from the caller and hence needs no lookup from the Plexus container. So
simply coding
    MyMojo mojo = new MyMojo();
    configureMojo(mojo, "myplugin-maven-plugin", testPom);
should work fine both inside Maven builds and IDE debugging sessions
without
my formerly mentioned class path hacks.


Benjamin Bentmann
-- 
View this message in context:
http://www.nabble.com/Execution-of-a-AbstractMojoTestCase-test-from-with
in-Eclipse-tf4034442s177.html#a13444708
Sent from the Maven Developers mailing list archive at Nabble.com.


---------------------------------------------------------------------
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: Execution of a AbstractMojoTestCase test from within Eclipse

Posted by Benjamin Bentmann <be...@udo.edu>.

Benjamin Bentmann wrote:
> 
> I would really appreciate some tweaks to the testing harness that allows
> debugging using IDEs out-of-the-box.
> 

Well, it seems I just should have better studied the AbstractMojoTestCase:
Besides lookupMojo(), it offers configureMojo(). The later one gets the mojo
from the caller and hence needs no lookup from the Plexus container. So
simply coding
    MyMojo mojo = new MyMojo();
    configureMojo(mojo, "myplugin-maven-plugin", testPom);
should work fine both inside Maven builds and IDE debugging sessions without
my formerly mentioned class path hacks.


Benjamin Bentmann
-- 
View this message in context: http://www.nabble.com/Execution-of-a-AbstractMojoTestCase-test-from-within-Eclipse-tf4034442s177.html#a13444708
Sent from the Maven Developers mailing list archive at Nabble.com.


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