Class MavenDependencyResolver

java.lang.Object
org.robolectric.internal.dependency.MavenDependencyResolver
All Implemented Interfaces:
DependencyResolver

public class MavenDependencyResolver extends Object implements DependencyResolver
This class is mainly responsible for fetching Android framework JAR dependencies from MavenCentral. Initially the fetching was being done with maven-ant-tasks, but that dependency become outdated and unmaintained and had security vulnerabilities.

There was an initial attempt to use maven-resolver for this, but that depends on a newer version of Apache Http Client that is not compatible with the one expected to be on the classpath for Android 16-18.

This uses only basic HttpURLConnection for fetching. In general using an HTTP client library here could create conflicts with the ones in the Android system.

See Also:
  • Constructor Details

    • MavenDependencyResolver

      public MavenDependencyResolver()
    • MavenDependencyResolver

      public MavenDependencyResolver(String repositoryUrl, String repositoryId, String repositoryUserName, String repositoryPassword, String proxyHost, int proxyPort)
  • Method Details

    • getLocalArtifactUrls

      public URL[] getLocalArtifactUrls(DependencyJar dependency)
      Description copied from interface: DependencyResolver
      Returns URLs representing the full transitive dependency graph of the given Maven dependency.
      Specified by:
      getLocalArtifactUrls in interface DependencyResolver
    • getLocalArtifactUrls

      public URL[] getLocalArtifactUrls(DependencyJar... dependencies)
      Get an array of local artifact URLs for the given dependencies. The order of the URLs is guaranteed to be the same as the input order of dependencies, i.e., urls[i] is the local artifact URL for dependencies[i].
    • createLockFile

      protected File createLockFile()
    • getLocalArtifactUrl

      public URL getLocalArtifactUrl(DependencyJar dependency)
      Specified by:
      getLocalArtifactUrl in interface DependencyResolver
    • getLocalRepositoryDir

      protected File getLocalRepositoryDir()
      Locates the local maven repo.
    • createMavenFetcher

      protected MavenArtifactFetcher createMavenFetcher(String repositoryUrl, String repositoryUserName, String repositoryPassword, String proxyHost, int proxyPort, File localRepositoryDir, ExecutorService executorService)
    • createExecutorService

      protected ExecutorService createExecutorService()