Maven 2 & 3
  1. Maven 2 & 3
  2. MNG-5017

Register VersionScheme as Plexus Component

    Details

    • Type: Wish Wish
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Incomplete
    • Affects Version/s: 3.0.2
    • Fix Version/s: None
    • Labels:
      None
    • Complexity:
      Intermediate
    • Number of attachments :
      1

      Description

      I would like to implement custom VersionConstraints, and have thought of creating a subclass of GenericVersionScheme to achieve that. However, I had to realize that GenericVersionScheme is instantiated via new GenericVersionScheme() instead of dependency injection.

      Please register GenericVersionScheme as a Plexus Component with the role org.sonatype.aether.version.VersionScheme, and use the injected version, that way I can write extensions that provide a wrapped version.

      Here are the affected instantiations that I could find:

      GenericVersionScheme() - org.sonatype.aether.util.version.GenericVersionScheme
      isMavenVersion(String) : boolean - org.apache.maven.rtinfo.internal.DefaultRuntimeInformation
      MytoysGenericVersionScheme - de.mytoys.maven.version.resolver
      resolveVersionRange(RepositorySystemSession, VersionRangeRequest) : VersionRangeResult - org.apache.maven.repository.internal.DefaultVersionRangeResolver
      selectVersion(DefaultPluginVersionResult, PluginVersionRequest, Versions) : void - org.apache.maven.plugin.version.internal.DefaultPluginVersionResolver

        Activity

        Hide
        Benjamin Bentmann added a comment -

        You might want to describe your specific use case and needs some more as otherwise the big picture and component interactions aren't clear.

        Show
        Benjamin Bentmann added a comment - You might want to describe your specific use case and needs some more as otherwise the big picture and component interactions aren't clear.
        Hide
        Sean Patrick Floyd added a comment - - edited

        My specific goal is to implement a solution for MNG-3092, but even without this specific scenario, I'd call it a bad practice (tight coupling) to instantiate a specific type of a key interface when IOC is available.

        My solution involves writing a replacement for GenericVersionScheme (actually, a wrapper around it) that creates VersionConstraint objects decorated with additional behavior to exclude snapshot versions from version ranges unless they are explicitly specified.

        Show
        Sean Patrick Floyd added a comment - - edited My specific goal is to implement a solution for MNG-3092 , but even without this specific scenario, I'd call it a bad practice (tight coupling) to instantiate a specific type of a key interface when IOC is available. My solution involves writing a replacement for GenericVersionScheme (actually, a wrapper around it) that creates VersionConstraint objects decorated with additional behavior to exclude snapshot versions from version ranges unless they are explicitly specified.
        Hide
        Sean Patrick Floyd added a comment -

        PS: Obviously the line MytoysGenericVersionScheme - de.mytoys.maven.version.resolver
        is not from the Maven codebase. Sorry.

        Show
        Sean Patrick Floyd added a comment - PS: Obviously the line MytoysGenericVersionScheme - de.mytoys.maven.version.resolver is not from the Maven codebase. Sorry.
        Hide
        Sean Patrick Floyd added a comment -

        This patch provides the functionality I am requesting. I verified that the current Maven 3.0.3 code base works as expected with this patch.

        However, I have used maven-core/META-INF/plexus/components.xml to register org.sonatype.aether.util.version.GenericVersionScheme . This is probably a bad place, it should be done in aether-util but I didn't want to create patches for more than one code base.

        Show
        Sean Patrick Floyd added a comment - This patch provides the functionality I am requesting. I verified that the current Maven 3.0.3 code base works as expected with this patch. However, I have used maven-core/META-INF/plexus/components.xml to register org.sonatype.aether.util.version.GenericVersionScheme . This is probably a bad place, it should be done in aether-util but I didn't want to create patches for more than one code base.
        Show
        Jason van Zyl added a comment - Please refer to https://cwiki.apache.org/confluence/display/MAVEN/The+Great+JIRA+Cleanup+of+2014
        Hide
        Jason van Zyl added a comment -

        Please refer to https://cwiki.apache.org/confluence/display/MAVEN/The+Great+JIRA+Cleanup+of+2014 if you're wondering why this issue was closed out.

        Show
        Jason van Zyl added a comment - Please refer to https://cwiki.apache.org/confluence/display/MAVEN/The+Great+JIRA+Cleanup+of+2014 if you're wondering why this issue was closed out.

          People

          • Assignee:
            Unassigned
            Reporter:
            Sean Patrick Floyd
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: