I need to replace some of the default Maven functionality with my own implementation, and I'm looking for a clean way to do this.
I extended org.apache.maven.repository.internal.DefaultVersionRangeResolverand registered my extended component using component.xml as follows:
<component-set>
<components>
<component>
<role>org.sonatype.aether.impl.VersionRangeResolver</role>
<role-hint>default</role-hint>
<implementation>com.my.custom.VersionRangeResolver
</implementation>
<isolated-realm>false</isolated-realm>
<requirements>
<requirement>
<role>org.sonatype.aether.spi.log.Logger</role>
<role-hint />
<field-name>logger</field-name>
</requirement>
<requirement>
<role>org.sonatype.aether.spi.log.Logger</role>
<role-hint />
<field-name>logger2</field-name>
</requirement>
<requirement>
<role>org.sonatype.aether.impl.MetadataResolver</role>
<role-hint />
<field-name>metadataResolver</field-name>
</requirement>
</requirements>
</component>
</components>
</component-set>
I installed a project that contains this in my local repo and I refer to it as another pom.xml project:
<build>
<extensions>
<extension>
<groupId>my.groupId</groupId>
<artifactId>maven-version-resolver</artifactId>
<version>SNAPSHOT</version>
</extension>
</extensions>
</build>
However, my artifact is not used. When I ran this little GMaven groovy script inside the assembly:
session.container.getComponentDescriptorList(
'org.sonatype.aether.impl.VersionRangeResolver'
).each{
println "Role Hint: ${it.roleHint}, implementation: ${it.implementation}" ;
}
it shows me both the default implementation and my own implementation, as with the "default" hint. So how can I solve this?
- Do I need to set an additional parameter in component.xml (possibly a higher priority)?
- Maven ?
- Plexus, ?