org.apache.ivy.core.resolve

Class ResolveEngine

public class ResolveEngine extends Object

The resolve engine which is the core of the dependency resolution mechanism used in Ivy. It features several resolve methods, some very simple, like resolve and resolve which allow to simply resolve dependencies of a single module descriptor, or more complete one, like the ResolveEngine which allows to provide options to the resolution engine.

See Also: ResolveOptions

Constructor Summary
ResolveEngine(ResolveEngineSettings settings, EventManager eventManager, SortEngine sortEngine)
Constructs a ResolveEngine.
Method Summary
ArtifactDownloadReportdownload(Artifact artifact, DownloadOptions options)
Download an artifact to the cache.
ArtifactDownloadReportdownload(ArtifactOrigin origin, DownloadOptions options)
Materialize an artifact already located.
voiddownloadArtifacts(ResolveReport report, Filter artifactFilter, DownloadOptions options)
ResolvedModuleRevisionfindModule(ModuleRevisionId id, ResolveOptions options)
IvyNode[]getDependencies(URL ivySource, ResolveOptions options)
Resolve the dependencies of a module without downloading corresponding artifacts.
IvyNode[]getDependencies(ModuleDescriptor md, ResolveOptions options, ResolveReport report)
Resolve the dependencies of a module without downloading corresponding artifacts.
DependencyResolvergetDictatorResolver()
Returns the currently configured dictator resolver, which when non null is used in place of any specified resolver in the IvySettings
EventManagergetEventManager()
ResolveEngineSettingsgetSettings()
SortEnginegetSortEngine()
ArtifactOriginlocate(Artifact artifact)
Locates an artifact in dependency resolvers, and return its location if it can be located and actually exists, or an unknown ArtifactOrigin in other cases.
DependencyDescriptormediate(DependencyDescriptor dd, ResolveOptions options)
Mediates the given dependency descriptor according to given options.
voidoutputReport(ResolveReport report, ResolutionCacheManager cacheMgr, ResolveOptions options)
ResolveReportresolve(File ivySource)
ResolveReportresolve(URL ivySource)
ResolveReportresolve(ModuleRevisionId mrid, ResolveOptions options, boolean changing)
Resolves the module identified by the given mrid with its dependencies if transitive is set to true.
ResolveReportresolve(URL ivySource, ResolveOptions options)
Resolve dependencies of a module described by an ivy file.
ResolveReportresolve(ModuleDescriptor md, ResolveOptions options)
Resolve dependencies of a module described by a module descriptor.
voidsetDictatorResolver(DependencyResolver dictatorResolver)
Sets a dictator resolver, which is used in place of regular dependency resolver for subsequent dependency resolution by this engine.

Constructor Detail

ResolveEngine

public ResolveEngine(ResolveEngineSettings settings, EventManager eventManager, SortEngine sortEngine)
Constructs a ResolveEngine.

Parameters: settings the settings to use to configure the engine. Must not be null. eventManager the event manager to use to send events about the resolution process. Must not be null. sortEngine the sort engine to use to sort modules before producing the dependency resolution report. Must not be null.

Method Detail

download

public ArtifactDownloadReport download(Artifact artifact, DownloadOptions options)
Download an artifact to the cache. Not used internally, useful especially for IDE plugins needing to download artifact one by one (for source or javadoc artifact, for instance).

Downloaded artifact file can be accessed using getLocalFile.

It is possible to track the progression of the download using classical ivy progress monitoring feature (see addTransferListener).

Parameters: artifact the artifact to download

Returns: a report concerning the download

See Also: ResolveEngine

download

public ArtifactDownloadReport download(ArtifactOrigin origin, DownloadOptions options)
Materialize an artifact already located.

Not used internally, useful especially for IDE plugins needing to download artifact one by one (for source or javadoc artifact, for instance).

Materialized artifact file can be accessed using getLocalFile.

It is possible to track the progression of the download using classical ivy progress monitoring feature (see addTransferListener).

Parameters: origin the artifact origin to materialize

Returns: a report concerning the download

See Also: ResolveEngine locate

downloadArtifacts

public void downloadArtifacts(ResolveReport report, Filter artifactFilter, DownloadOptions options)

findModule

public ResolvedModuleRevision findModule(ModuleRevisionId id, ResolveOptions options)

getDependencies

public IvyNode[] getDependencies(URL ivySource, ResolveOptions options)
Resolve the dependencies of a module without downloading corresponding artifacts. The module to resolve is given by its ivy file URL. This method requires appropriate configuration of the ivy instance, especially resolvers.

Parameters: ivySource url of the ivy file to use for dependency resolving confs an array of configuration names to resolve - must not be null nor empty getCache the cache to use - default cache is used if null date the date to which resolution must be done - may be null

Returns: an array of the resolved dependencies

Throws: ParseException if a parsing problem occured in the ivy file IOException if an IO problem was raised during ivy file parsing

getDependencies

public IvyNode[] getDependencies(ModuleDescriptor md, ResolveOptions options, ResolveReport report)
Resolve the dependencies of a module without downloading corresponding artifacts. The module to resolve is given by its module descriptor.This method requires appropriate configuration of the ivy instance, especially resolvers.

Parameters: md the descriptor of the module for which we want to get dependencies - must not be null options the resolve options to use to resolve the dependencies report a resolve report to fill during resolution - may be null

Returns: an array of the resolved Dependencies

getDictatorResolver

public DependencyResolver getDictatorResolver()
Returns the currently configured dictator resolver, which when non null is used in place of any specified resolver in the IvySettings

Returns: the currently configured dictator resolver, may be null.

getEventManager

public EventManager getEventManager()

getSettings

public ResolveEngineSettings getSettings()

getSortEngine

public SortEngine getSortEngine()

locate

public ArtifactOrigin locate(Artifact artifact)
Locates an artifact in dependency resolvers, and return its location if it can be located and actually exists, or an unknown ArtifactOrigin in other cases.

Parameters: artifact the artifact to locate.

Returns: the artifact location, should be tested with isUnknown to check if the artifact has actually been located.

mediate

public DependencyDescriptor mediate(DependencyDescriptor dd, ResolveOptions options)
Mediates the given dependency descriptor according to given options.

The mediated dependency descriptor must return the actually requested module revision id when the method getDependencyRevisionId is called.

Parameters: dd the dependency descriptor for which the requested module revision id should be returned options the resolve options to use

Returns: the mediated DependencyDescriptor.

outputReport

public void outputReport(ResolveReport report, ResolutionCacheManager cacheMgr, ResolveOptions options)

resolve

public ResolveReport resolve(File ivySource)

resolve

public ResolveReport resolve(URL ivySource)

resolve

public ResolveReport resolve(ModuleRevisionId mrid, ResolveOptions options, boolean changing)
Resolves the module identified by the given mrid with its dependencies if transitive is set to true.

resolve

public ResolveReport resolve(URL ivySource, ResolveOptions options)
Resolve dependencies of a module described by an ivy file.

resolve

public ResolveReport resolve(ModuleDescriptor md, ResolveOptions options)
Resolve dependencies of a module described by a module descriptor.

setDictatorResolver

public void setDictatorResolver(DependencyResolver dictatorResolver)
Sets a dictator resolver, which is used in place of regular dependency resolver for subsequent dependency resolution by this engine.

Parameters: dictatorResolver the dictator resolver to use in this engine, null if regular settings should used