Class UriPlexusConverter

java.lang.Object
org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter
org.codehaus.plexus.component.configurator.converters.basic.AbstractBasicConverter
io.github.ascopes.protobufmavenplugin.fs.UriPlexusConverter
All Implemented Interfaces:
org.codehaus.plexus.component.configurator.converters.ConfigurationConverter

public final class UriPlexusConverter extends org.codehaus.plexus.component.configurator.converters.basic.AbstractBasicConverter
Plexus/Sisu parameter converter for URIs.

We provide this to avoid using the URL and File APIs in the Mojo interface. URLs do an immediate lookup for the URL scheme's appropriate URLStreamHandlerProvider upon construction, and we have no control over how that works. We have no ability to inject custom URL handlers at this point because the URL class is hardcoded to only consider the system classloader. Since Maven uses ClassWorlds to run multiple classloaders for each plugin and component, we will not be loaded as part of that default classloader. By deferring this operation to as late as possible (i.e. in UriResourceFetcher), we can ensure we provide the desired URL handler directly instead. This allows us to hook custom URL handlers in via ServiceLoader dynamically, like we would be able to outside a Maven plugin running in Plexus.

Newer versions of Plexus/Sisu provide this for us, so in the future, we can remove these components (looks to be supported from Maven 3.9.x).

Since:
3.1.3
Author:
Ashley Scopes
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canConvert(Class<?> type)
     
    protected Object
     

    Methods inherited from class org.codehaus.plexus.component.configurator.converters.basic.AbstractBasicConverter

    fromConfiguration, fromExpression, fromString

    Methods inherited from class org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter

    failIfNotTypeCompatible, fromConfiguration, fromExpression, fromExpression, fromXML, getClassForImplementationHint, instantiateObject

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • UriPlexusConverter

      public UriPlexusConverter()
  • Method Details

    • canConvert

      public boolean canConvert(Class<?> type)
    • fromString

      protected Object fromString(String str) throws org.codehaus.plexus.component.configurator.ComponentConfigurationException
      Overrides:
      fromString in class org.codehaus.plexus.component.configurator.converters.basic.AbstractBasicConverter
      Throws:
      org.codehaus.plexus.component.configurator.ComponentConfigurationException