java.lang.Object
org.springframework.core.io.AbstractResource
org.springframework.cloud.function.deployer.utils.MavenResource
All Implemented Interfaces:
org.springframework.core.io.InputStreamSource, org.springframework.core.io.Resource

public final class MavenResource extends org.springframework.core.io.AbstractResource
A Resource implementation for resolving an artifact via maven coordinates.

The MavenResource class contains Maven coordinates for a jar file containing an app/library, or a Bill of Materials pom.

To create a new instance, either use MavenResource.Builder to set the individual fields:

 new MavenResource.Builder()
     .setGroupId("org.springframework.sample")
     .setArtifactId("some-app")
     .setExtension("jar") //optional
     .setClassifier("exec") //optional
     .setVersion("2.0.0")
     .build()
 
...or use parse(String) to parse the coordinates as a colon delimited string: <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>
 MavenResource.parse("org.springframework.sample:some-app:2.0.0);
 MavenResource.parse("org.springframework.sample:some-app:jar:exec:2.0.0);
 
Author:
David Turanski, Mark Fisher, Patrick Peralta, Venil Noronha, Ilayaperumal Gopinathan
  • Field Details

    • URI_SCHEME

      public static String URI_SCHEME
      URI Scheme.
  • Method Details

    • getGroupId

      public String getGroupId()
    • getArtifactId

      public String getArtifactId()
    • getExtension

      public String getExtension()
    • getClassifier

      public String getClassifier()
    • getVersion

      public String getVersion()
    • getDescription

      public String getDescription()
    • getInputStream

      public InputStream getInputStream() throws IOException
      Throws:
      IOException
    • getFile

      public File getFile() throws IOException
      Specified by:
      getFile in interface org.springframework.core.io.Resource
      Overrides:
      getFile in class org.springframework.core.io.AbstractResource
      Throws:
      IOException
    • getFilename

      public String getFilename()
      Specified by:
      getFilename in interface org.springframework.core.io.Resource
      Overrides:
      getFilename in class org.springframework.core.io.AbstractResource
    • exists

      public boolean exists()
      Specified by:
      exists in interface org.springframework.core.io.Resource
      Overrides:
      exists in class org.springframework.core.io.AbstractResource
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class org.springframework.core.io.AbstractResource
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class org.springframework.core.io.AbstractResource
    • toString

      public String toString()
      Returns the coordinates encoded as <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>, conforming to the Aether convention.
      Overrides:
      toString in class org.springframework.core.io.AbstractResource
    • getURI

      public URI getURI() throws IOException
      Specified by:
      getURI in interface org.springframework.core.io.Resource
      Overrides:
      getURI in class org.springframework.core.io.AbstractResource
      Throws:
      IOException
    • parse

      public static MavenResource parse(String coordinates)
      Create a MavenResource for the provided coordinates and default properties.
      Parameters:
      coordinates - coordinates encoded as <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>, conforming to the Aether convention.
      Returns:
      the MavenResource
    • parse

      public static MavenResource parse(String coordinates, MavenProperties properties)
      Create a MavenResource for the provided coordinates and properties.
      Parameters:
      coordinates - coordinates encoded as <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>, conforming to the Aether convention.
      properties - the properties for the repositories, proxies, and authentication
      Returns:
      the MavenResource
    • getVersions

      public List<String> getVersions(String coordinates)
      Get all the available versions on this maven co-ordinate.
      Parameters:
      coordinates - the co-ordinate with the version constraint added. Example: org.springframework.cloud.stream.app:http-source-rabbit:[0,)
      Returns:
      the list of all the available versions