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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to