Class MavenDownloaderImpl

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.tooling.maven.MavenDownloaderImpl
All Implemented Interfaces:
AutoCloseable, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.StatefulService, org.apache.camel.SuspendableService, MavenDownloader

public class MavenDownloaderImpl extends org.apache.camel.support.service.ServiceSupport implements MavenDownloader
The only class in Camel that deals with all these DI mechanisms of maven-resolver library.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final org.slf4j.Logger
     
    static final String
     

    Fields inherited from class org.apache.camel.support.service.BaseService

    BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    MavenDownloaderImpl(org.eclipse.aether.RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystemSession repositorySystemSession, org.apache.maven.settings.Settings settings)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    customize(String localRepository, int connectTimeout, int requestTimeout)
    Existing, configured MavenDownloader can be used as a template to create customized version which shares most of the configuration except underlying org.eclipse.aether.RepositorySystemSession, which can't be shared.
    protected void
     
    protected void
     
    protected void
     
    Gets the repository resolver.
    boolean
    Sets whether using SNAPSHOT versions of Apache Camel is enabled.
    boolean
    Sets whether maven central repository should be included and as first in the list of repositories.
    resolveArtifacts(String rootGav, List<String> dependencyGAVs, Set<String> extraRepositories, boolean transitively, boolean useApacheSnapshots)
    Main resolution method.
    resolveArtifacts(List<String> dependencyGAVs, Set<String> extraRepositories, boolean transitively, boolean useApacheSnapshots)
    resolveAvailableVersions(String groupId, String artifactId, String repository)
    Resolves available versions for groupId + artifactId from single remote repository.
    void
    setFresh(boolean fresh)
    Set a flag determining Maven update behavior.
    void
    setMavenApacheSnapshotEnabled(boolean mavenApacheSnapshotEnabled)
    Sets whether using SNAPSHOT versions of Apache Camel is enabled.
    void
    setMavenCentralEnabled(boolean mavenCentralEnabled)
    Sets whether maven central repository should be included and as first in the list of repositories.
    void
    Configure a location of settings.xml (when not set, defaults to ~/.m2/settings.xml unless it's explicitly set to "false".
    void
    Configure a location of settings-security.xml (when not set, defaults to ~/.m2/settings-security.xml unless MavenDownloader.setMavenSettingsLocation(String) is set explicitly set to "false".
    void
    setOffline(boolean offline)
    Sets maven downloader in offline mode
    void
    To use a listener when downloading from remote repositories.
    void
    Configure comma-separated list of repositories to use (in addition to the ones discovered from Maven settings).
    void
    Sets a custom repository resolver.

    Methods inherited from class org.apache.camel.support.service.BaseService

    build, doFail, doLifecycleChange, doResume, doShutdown, doStart, doSuspend, fail, getInternalLock, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.camel.Service

    build, close, init, start, stop

    Methods inherited from interface org.apache.camel.ShutdownableService

    shutdown

    Methods inherited from interface org.apache.camel.StatefulService

    getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending

    Methods inherited from interface org.apache.camel.SuspendableService

    isSuspended, resume, suspend
  • Field Details

  • Constructor Details

    • MavenDownloaderImpl

      public MavenDownloaderImpl()
    • MavenDownloaderImpl

      public MavenDownloaderImpl(org.eclipse.aether.RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystemSession repositorySystemSession, org.apache.maven.settings.Settings settings)
  • Method Details

    • doBuild

      protected void doBuild()
      Overrides:
      doBuild in class org.apache.camel.support.service.BaseService
    • doInit

      protected void doInit()
      Overrides:
      doInit in class org.apache.camel.support.service.BaseService
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • setRemoteArtifactDownloadListener

      public void setRemoteArtifactDownloadListener(RemoteArtifactDownloadListener remoteArtifactDownloadListener)
      Description copied from interface: MavenDownloader
      To use a listener when downloading from remote repositories.
      Specified by:
      setRemoteArtifactDownloadListener in interface MavenDownloader
    • resolveArtifacts

      public List<MavenArtifact> resolveArtifacts(List<String> dependencyGAVs, Set<String> extraRepositories, boolean transitively, boolean useApacheSnapshots) throws MavenResolutionException
      Description copied from interface: MavenDownloader
      Specified by:
      resolveArtifacts in interface MavenDownloader
      Throws:
      MavenResolutionException
    • resolveArtifacts

      public List<MavenArtifact> resolveArtifacts(String rootGav, List<String> dependencyGAVs, Set<String> extraRepositories, boolean transitively, boolean useApacheSnapshots) throws MavenResolutionException
      Description copied from interface: MavenDownloader
      Main resolution method. Using Maven Resolver, a list of maven coordinates (in the form of groupId:artifactId[:packaging[:classifier]]:version) is used to download artifacts from configured Maven repositories.
      Specified by:
      resolveArtifacts in interface MavenDownloader
      Parameters:
      rootGav - root Maven artifact
      dependencyGAVs - a list of Maven coordinates
      extraRepositories - nullable list of additional repositories to use (except the discovered ones)
      transitively - whether to download/resolve dependencies transitively
      useApacheSnapshots - whether to include Apache Snapshots repository in the list of used repositories
      Throws:
      MavenResolutionException
    • resolveAvailableVersions

      public List<MavenGav> resolveAvailableVersions(String groupId, String artifactId, String repository) throws MavenResolutionException
      Description copied from interface: MavenDownloader
      Resolves available versions for groupId + artifactId from single remote repository.
      Specified by:
      resolveAvailableVersions in interface MavenDownloader
      Parameters:
      groupId - groupId
      artifactId - artifactId
      repository - external repository to use (defaults to Maven Central if null)
      Throws:
      MavenResolutionException
    • customize

      public MavenDownloader customize(String localRepository, int connectTimeout, int requestTimeout)
      Description copied from interface: MavenDownloader
      Existing, configured MavenDownloader can be used as a template to create customized version which shares most of the configuration except underlying org.eclipse.aether.RepositorySystemSession, which can't be shared.
      Specified by:
      customize in interface MavenDownloader
    • setMavenSettingsLocation

      public void setMavenSettingsLocation(String mavenSettings)
      Description copied from interface: MavenDownloader
      Configure a location of settings.xml (when not set, defaults to ~/.m2/settings.xml unless it's explicitly set to "false".
      Specified by:
      setMavenSettingsLocation in interface MavenDownloader
    • setMavenSettingsSecurityLocation

      public void setMavenSettingsSecurityLocation(String mavenSettingsSecurity)
      Description copied from interface: MavenDownloader
      Configure a location of settings-security.xml (when not set, defaults to ~/.m2/settings-security.xml unless MavenDownloader.setMavenSettingsLocation(String) is set explicitly set to "false".
      Specified by:
      setMavenSettingsSecurityLocation in interface MavenDownloader
    • getRepositoryResolver

      public RepositoryResolver getRepositoryResolver()
      Description copied from interface: MavenDownloader
      Gets the repository resolver.
      Specified by:
      getRepositoryResolver in interface MavenDownloader
    • setRepositoryResolver

      public void setRepositoryResolver(RepositoryResolver repositoryResolver)
      Description copied from interface: MavenDownloader
      Sets a custom repository resolver.
      Specified by:
      setRepositoryResolver in interface MavenDownloader
    • setRepos

      public void setRepos(String repos)
      Description copied from interface: MavenDownloader
      Configure comma-separated list of repositories to use (in addition to the ones discovered from Maven settings).
      Specified by:
      setRepos in interface MavenDownloader
    • setFresh

      public void setFresh(boolean fresh)
      Description copied from interface: MavenDownloader
      Set a flag determining Maven update behavior. See the description of -U,--update-snapshots Maven option. When set to true, Maven metadata (to determine newest SNAPSHOT or RELEASE or LATEST version) is always fetched.
      Specified by:
      setFresh in interface MavenDownloader
    • setOffline

      public void setOffline(boolean offline)
      Description copied from interface: MavenDownloader
      Sets maven downloader in offline mode
      Specified by:
      setOffline in interface MavenDownloader
    • isMavenCentralEnabled

      public boolean isMavenCentralEnabled()
      Description copied from interface: MavenDownloader
      Sets whether maven central repository should be included and as first in the list of repositories. This can be used to turn of maven central for users that may use their own maven proxy.
      Specified by:
      isMavenCentralEnabled in interface MavenDownloader
    • setMavenCentralEnabled

      public void setMavenCentralEnabled(boolean mavenCentralEnabled)
      Description copied from interface: MavenDownloader
      Sets whether maven central repository should be included and as first in the list of repositories. This can be used to turn of maven central for users that may use their own maven proxy.
      Specified by:
      setMavenCentralEnabled in interface MavenDownloader
    • isMavenApacheSnapshotEnabled

      public boolean isMavenApacheSnapshotEnabled()
      Description copied from interface: MavenDownloader
      Sets whether using SNAPSHOT versions of Apache Camel is enabled. If enabled then SNAPSHOT can be downloaded from the ASF SNAPSHOT maven repository.
      Specified by:
      isMavenApacheSnapshotEnabled in interface MavenDownloader
    • setMavenApacheSnapshotEnabled

      public void setMavenApacheSnapshotEnabled(boolean mavenApacheSnapshotEnabled)
      Description copied from interface: MavenDownloader
      Sets whether using SNAPSHOT versions of Apache Camel is enabled. If enabled then SNAPSHOT can be downloaded from the ASF SNAPSHOT maven repository.
      Specified by:
      setMavenApacheSnapshotEnabled in interface MavenDownloader