Package org.apache.camel.tooling.maven
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
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final org.slf4j.Loggerstatic final StringFields 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
ConstructorsConstructorDescriptionMavenDownloaderImpl(org.eclipse.aether.RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystemSession repositorySystemSession, org.apache.maven.settings.Settings settings) -
Method Summary
Modifier and TypeMethodDescriptionExisting, configuredMavenDownloadercan be used as a template to create customized version which shares most of the configuration except underlyingorg.eclipse.aether.RepositorySystemSession, which can't be shared.protected voiddoBuild()protected voiddoInit()protected voiddoStop()Gets the repository resolver.booleanSets whether using SNAPSHOT versions of Apache Camel is enabled.booleanSets 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.voidsetFresh(boolean fresh) Set a flag determining Maven update behavior.voidsetMavenApacheSnapshotEnabled(boolean mavenApacheSnapshotEnabled) Sets whether using SNAPSHOT versions of Apache Camel is enabled.voidsetMavenCentralEnabled(boolean mavenCentralEnabled) Sets whether maven central repository should be included and as first in the list of repositories.voidsetMavenSettingsLocation(String mavenSettings) Configure a location ofsettings.xml(when not set, defaults to~/.m2/settings.xmlunless it's explicitly set to"false".voidsetMavenSettingsSecurityLocation(String mavenSettingsSecurity) Configure a location ofsettings-security.xml(when not set, defaults to~/.m2/settings-security.xmlunlessMavenDownloader.setMavenSettingsLocation(String)is set explicitly set to"false".voidsetOffline(boolean offline) Sets maven downloader in offline modevoidsetRemoteArtifactDownloadListener(RemoteArtifactDownloadListener remoteArtifactDownloadListener) To use a listener when downloading from remote repositories.voidConfigure comma-separated list of repositories to use (in addition to the ones discovered from Maven settings).voidsetRepositoryResolver(RepositoryResolver repositoryResolver) 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, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Field Details
-
LOG
public static final org.slf4j.Logger LOG -
MAVEN_CENTRAL_REPO
- See Also:
-
APACHE_SNAPSHOT_REPO
- See Also:
-
-
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:
doBuildin classorg.apache.camel.support.service.BaseService
-
doInit
protected void doInit()- Overrides:
doInitin classorg.apache.camel.support.service.BaseService
-
doStop
- Overrides:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
setRemoteArtifactDownloadListener
public void setRemoteArtifactDownloadListener(RemoteArtifactDownloadListener remoteArtifactDownloadListener) Description copied from interface:MavenDownloaderTo use a listener when downloading from remote repositories.- Specified by:
setRemoteArtifactDownloadListenerin interfaceMavenDownloader
-
resolveArtifacts
public List<MavenArtifact> resolveArtifacts(List<String> dependencyGAVs, Set<String> extraRepositories, boolean transitively, boolean useApacheSnapshots) throws MavenResolutionException Description copied from interface:MavenDownloader- Specified by:
resolveArtifactsin interfaceMavenDownloader- 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:MavenDownloaderMain resolution method. Using Maven Resolver, a list of maven coordinates (in the form ofgroupId:artifactId[:packaging[:classifier]]:version) is used to download artifacts from configured Maven repositories.- Specified by:
resolveArtifactsin interfaceMavenDownloader- Parameters:
rootGav- root Maven artifactdependencyGAVs- a list of Maven coordinatesextraRepositories- nullable list of additional repositories to use (except the discovered ones)transitively- whether to download/resolve dependencies transitivelyuseApacheSnapshots- 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:MavenDownloaderResolves available versions for groupId + artifactId from single remote repository.- Specified by:
resolveAvailableVersionsin interfaceMavenDownloader- Parameters:
groupId- groupIdartifactId- artifactIdrepository- external repository to use (defaults to Maven Central ifnull)- Throws:
MavenResolutionException
-
customize
Description copied from interface:MavenDownloaderExisting, configuredMavenDownloadercan be used as a template to create customized version which shares most of the configuration except underlyingorg.eclipse.aether.RepositorySystemSession, which can't be shared.- Specified by:
customizein interfaceMavenDownloader
-
setMavenSettingsLocation
Description copied from interface:MavenDownloaderConfigure a location ofsettings.xml(when not set, defaults to~/.m2/settings.xmlunless it's explicitly set to"false".- Specified by:
setMavenSettingsLocationin interfaceMavenDownloader
-
setMavenSettingsSecurityLocation
Description copied from interface:MavenDownloaderConfigure a location ofsettings-security.xml(when not set, defaults to~/.m2/settings-security.xmlunlessMavenDownloader.setMavenSettingsLocation(String)is set explicitly set to"false".- Specified by:
setMavenSettingsSecurityLocationin interfaceMavenDownloader
-
getRepositoryResolver
Description copied from interface:MavenDownloaderGets the repository resolver.- Specified by:
getRepositoryResolverin interfaceMavenDownloader
-
setRepositoryResolver
Description copied from interface:MavenDownloaderSets a custom repository resolver.- Specified by:
setRepositoryResolverin interfaceMavenDownloader
-
setRepos
Description copied from interface:MavenDownloaderConfigure comma-separated list of repositories to use (in addition to the ones discovered from Maven settings).- Specified by:
setReposin interfaceMavenDownloader
-
setFresh
public void setFresh(boolean fresh) Description copied from interface:MavenDownloaderSet a flag determining Maven update behavior. See the description of-U,--update-snapshotsMaven option. When set totrue, Maven metadata (to determine newest SNAPSHOT or RELEASE or LATEST version) is always fetched.- Specified by:
setFreshin interfaceMavenDownloader
-
setOffline
public void setOffline(boolean offline) Description copied from interface:MavenDownloaderSets maven downloader in offline mode- Specified by:
setOfflinein interfaceMavenDownloader
-
isMavenCentralEnabled
public boolean isMavenCentralEnabled()Description copied from interface:MavenDownloaderSets 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:
isMavenCentralEnabledin interfaceMavenDownloader
-
setMavenCentralEnabled
public void setMavenCentralEnabled(boolean mavenCentralEnabled) Description copied from interface:MavenDownloaderSets 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:
setMavenCentralEnabledin interfaceMavenDownloader
-
isMavenApacheSnapshotEnabled
public boolean isMavenApacheSnapshotEnabled()Description copied from interface:MavenDownloaderSets whether using SNAPSHOT versions of Apache Camel is enabled. If enabled then SNAPSHOT can be downloaded from the ASF SNAPSHOT maven repository.- Specified by:
isMavenApacheSnapshotEnabledin interfaceMavenDownloader
-
setMavenApacheSnapshotEnabled
public void setMavenApacheSnapshotEnabled(boolean mavenApacheSnapshotEnabled) Description copied from interface:MavenDownloaderSets whether using SNAPSHOT versions of Apache Camel is enabled. If enabled then SNAPSHOT can be downloaded from the ASF SNAPSHOT maven repository.- Specified by:
setMavenApacheSnapshotEnabledin interfaceMavenDownloader
-