Class UriResourceFetcher

java.lang.Object
io.github.ascopes.protobufmavenplugin.fs.UriResourceFetcher

@Description("Fetches and downloads resources from URIs") @Named public final class UriResourceFetcher extends Object
Component that consumes URIs to obtain resources from remote locations.
Since:
0.4.0
Author:
Ashley Scopes
  • Constructor Details

    • UriResourceFetcher

      @Inject public UriResourceFetcher(org.apache.maven.execution.MavenSession mavenSession, TemporarySpace temporarySpace)
  • Method Details

    • fetchFileFromUri

      public Optional<Path> fetchFileFromUri(URI uri, String extension) throws ResolutionException
      Fetch a file from the given URL, possibly downloading it to the local file system in a temporary location if it is not on the root file system.
      Parameters:
      uri - the URI of the resource to fetch.
      extension - a hint pointing to the potential file extension to use for the resource. This may be ignored if the URL points to a resource that is already on the root file system.
      Returns:
      the URL, or an empty optional if it points to a non-existent resource.
      Throws:
      ResolutionException - if resolution fails for any other reason.