Class MavenDependencyDownloader

java.lang.Object
enterprises.iwakura.amber.impl.MavenDependencyDownloader
All Implemented Interfaces:
DependencyDownloader

public class MavenDependencyDownloader extends Object implements DependencyDownloader
Implementation of DependencyDownloader that downloads dependencies from any Maven repositories. Supports version overrides via maven-metadata.xml.
  • Constructor Details

    • MavenDependencyDownloader

      public MavenDependencyDownloader()
  • Method Details

    • downloadJar

      public DownloadResult downloadJar(Dependency dependency, Repository repository, Path filePath) throws IOException
      Description copied from interface: DependencyDownloader
      Downloads the jar file for the specified dependency from the given repository and saves it to the specified file path.
      Specified by:
      downloadJar in interface DependencyDownloader
      Parameters:
      dependency - the dependency to download
      repository - the repository to download from
      filePath - the path to save the downloaded jar file
      Returns:
      a DownloadResult indicating the success or failure of the download
      Throws:
      IOException - if an I/O error occurs during the download
    • downloadChecksum

      public StringDownloadResult downloadChecksum(Dependency dependency, Repository repository, ChecksumType checksumType) throws IOException
      Description copied from interface: DependencyDownloader
      Downloads the checksum for the specified dependency from the given repository.
      Specified by:
      downloadChecksum in interface DependencyDownloader
      Parameters:
      dependency - the dependency to download the checksum for
      repository - the repository to download from
      checksumType - the type of checksum to download (e.g., MD5, SHA-1, SHA-256)
      Returns:
      a StringDownloadResult containing the checksum string if successful, or an error message if failed
      Throws:
      IOException - if an I/O error occurs during the download
    • downloadVersionOverrideFromMavenMetadata

      protected StringDownloadResult downloadVersionOverrideFromMavenMetadata(Dependency dependency, Repository repository)
      Tries to download and parse maven-metadata.xml to find a version override for the given dependency.
      Parameters:
      dependency - the dependency to check for version override
      repository - the repository to download from
      Returns:
      a StringDownloadResult containing the version override if found, null if not found, or an error message if failed
    • createConnection

      protected HttpURLConnection createConnection(String url) throws IOException
      Prepares an HTTP GET connection with the default User-Agent.
      Parameters:
      url - the URL to connect to
      Returns:
      the prepared HttpURLConnection
      Throws:
      IOException - if an I/O error occurs