How to do a configurable plexus component in a maven extension?

368 Views Asked by At

I'm trying to modify tesla-profiler extension to support different output formats as well as to choose the path where to write the file.

My current components.xml defines a "renderer" with a specific implementation that is required by the profiler and selected by role-hint, but it's completelly static now, it looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<component-set>
  <components>
    <component>
      <role>io.tesla.lifecycle.profiler.SessionProfileRenderer</role>
      <role-hint>file-writer</role-hint>
      <implementation>io.tesla.lifecycle.profiler.SessionProfileFileWriter</implementation>
      <configuration>
        <filename>profile.out</filename>
      </configuration>
    </component>
    <component>
      <role>org.apache.maven.eventspy.EventSpy</role>
      <role-hint>tesla-profiler</role-hint>
      <implementation>io.tesla.lifecycle.profiler.LifecycleProfiler</implementation>
      <isolated-realm>false</isolated-realm>
      <requirements>
        <requirement>
          <role>io.tesla.lifecycle.profiler.SessionProfileRenderer</role>
          <role-hint>file-writer</role-hint>
        </requirement>
      </requirements>
    </component>
  </components>
</component-set>

I'd like to know if I could parametrize or override it somehow so I can select from a project's pom.xml the SessionProfileRenderer to use and maybe also the parameters for the renderer, e.g. the path of the file to write in the SessionProfileFileWriter.

0

There are 0 best solutions below