You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Jochen Wiedmann <jo...@gmail.com> on 2006/03/10 14:05:26 UTC
Plexus self configuration
Hi,
in an attempt to resolve MCOMPILER-8, I have had a look at the
plexus-compiler-api.
What I found is, that the compiler API seems to have some magic way of
configuring itself, most possibly through
META-INF/plexus/components.xml.
I do not have the slightest idea, how this self configuration works
and where in the code it takes place. Can anyone enlighten me on that?
Regards,
Jochen
--
Whenever you find yourself on the side of the
majority, it is time to pause and reflect.
(Mark Twain)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
Re: Plexus self configuration
Posted by Brett Porter <br...@apache.org>.
When a JAR is added to Plexus, it is scanned for
META-INF/plexus/components.xml, and if that exists the components are
registered.
So, plexus-compiler-manager has:
<component>
<role>org.codehaus.plexus.compiler.manager.CompilerManager</role>
<implementation>org.codehaus.plexus.compiler.manager.DefaultCompilerManager</implementation>
<requirements>
<requirement>
<role>org.codehaus.plexus.compiler.Compiler</role>
<field-name>compilers</field-name>
</requirement>
</requirements>
</component>
Which means there is a component called "CompilerManager" (the
interface) that should be instantiated as a DefaultCompilerManager
unless otherwise told to use another implementation. IT has a field
"compilers" that should be filled with all instances of Compiler found
in the classpath.
Compilers such as plexus-compiler-javac have a components file that
declare it has an implementation of Compiler, so it will be in the list:
<component>
<role>org.codehaus.plexus.compiler.Compiler</role>
<role-hint>javac</role-hint>
<implementation>org.codehaus.plexus.compiler.javac.JavacCompiler</implementation>
</component>
Since it has a role hint of "javac", it will be added to the compilers
map in the manager with that key, so it is easily looked up by
compilerId from the plugin.
As for the instantiation of compilerManager in the mojo, mojos are
plexus components too with an extended components descriptor called
META-INF/maven/plugin.xml. It is generated from the annotations in the
code, so the @component annotation for a field makes it like a
requirement (just like the compilers map above). The legacy syntax for
that is expression="${component.ROLE}".
I hope this helps. Any volunteers to capture this in a brief guide?
- Brett
Jochen Wiedmann wrote:
> Hi,
>
> in an attempt to resolve MCOMPILER-8, I have had a look at the
> plexus-compiler-api.
>
> What I found is, that the compiler API seems to have some magic way of
> configuring itself, most possibly through
> META-INF/plexus/components.xml.
>
> I do not have the slightest idea, how this self configuration works
> and where in the code it takes place. Can anyone enlighten me on that?
>
> Regards,
>
> Jochen
>
> --
> Whenever you find yourself on the side of the
> majority, it is time to pause and reflect.
> (Mark Twain)
>
> ---------------------------------------------------------------------
> 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: Plexus self configuration
Posted by Jesse McConnell <je...@gmail.com>.
look into the plexus-containers/plexus-container-default and the
plexus-components/plexus-compiler in the plexus source tree
The container has the code that does the private variable injection and
populates what the compiler manager needs...it takes a bit to work out but
it is really quite neat :) The components.xml defines roles (which are
named after the Interface) and the default implementation that uses the
interface...
#plexus on irc.codehaus.org is also a good place to ask questions.
jesse
On 3/10/06, Jochen Wiedmann <jo...@gmail.com> wrote:
>
> Hi,
>
> in an attempt to resolve MCOMPILER-8, I have had a look at the
> plexus-compiler-api.
>
> What I found is, that the compiler API seems to have some magic way of
> configuring itself, most possibly through
> META-INF/plexus/components.xml.
>
> I do not have the slightest idea, how this self configuration works
> and where in the code it takes place. Can anyone enlighten me on that?
>
> Regards,
>
> Jochen
>
> --
> Whenever you find yourself on the side of the
> majority, it is time to pause and reflect.
> (Mark Twain)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>
--
jesse mcconnell
jesseDOTmcconnellATgmailDOTcom