org.apache.ivy

Class Ivy

public class Ivy extends Object

Ivy is a free java based dependency manager.

This class is the main class of Ivy, which acts as a Facade to all services offered by Ivy:

Here is one typical usage:
 Ivy ivy = Ivy.newInstance();
 ivy.configure(new URL("ivysettings.xml"));
 ivy.resolve(new URL("ivy.xml"));
 

Using Ivy engines directly

If the methods offered by the Ivy class are not flexible enough and you want to use Ivy engines directly, you need to call the methods within a single IvyContext associated to the Ivy instance you use.
To do so, it is recommended to use the execute method like this:

 Ivy ivy = Ivy.newInstance();
 ivy.execute(new IvyCallback() {
     public Object doInIvyContext(Ivy ivy, IvyContext context) {
         // obviously we can use regular Ivy methods in the callback 
         ivy.configure(new URL("ivysettings.xml"));
         // and we can safely use Ivy engines too
         ivy.getResolveEngine().resolve(new URL("ivy.xml"));
         return null;
     }
 });
 

Nested Class Summary
static interfaceIvy.IvyCallback
Callback used to execute a set of Ivy related methods within an IvyContext.
Field Summary
static SimpleDateFormatDATE_FORMAT
Constructor Summary
Ivy()
The default constructor of Ivy allows to create an instance of Ivy with none of its dependencies (engines, settings, ...) created.
Method Summary
voidbind()
This method is used to bind this Ivy instance to required dependencies, i.e. instance of settings, engines, and so on.
booleancheck(URL ivyFile, String resolvername)
voidcheckInterrupted()
Check if the current operation has been interrupted, and if it is the case, throw a runtime exception
voidconfigure(File settingsFile)
voidconfigure(URL settingsURL)
voidconfigureDefault()
voidconfigureDefault14()
Configures Ivy with 1.4 compatible default settings
voiddeliver(ModuleRevisionId mrid, String revision, String destIvyPattern)
voiddeliver(String revision, String destIvyPattern, DeliverOptions options)
voiddeliver(ModuleRevisionId mrid, String revision, String destIvyPattern, DeliverOptions options)
Example of use: deliver(mrid, "1.5", "target/ivy/ivy-[revision].xml", DeliverOptions.newInstance(settings).setStatus("release").setValidate(false));
Objectexecute(Ivy.IvyCallback callback)
Executes the given callback in the context of this Ivy instance.
ResolvedModuleRevisionfindModule(ModuleRevisionId mrid)
CheckEnginegetCheckEngine()
DeliverEnginegetDeliverEngine()
EventManagergetEventManager()
InstallEnginegetInstallEngine()
static StringgetIvyDate()
Returns the date at which this version of Ivy has been built.
static StringgetIvyHomeURL()
Returns the URL at which Ivy web site can be found.
static StringgetIvyVersion()
Returns the current version of Ivy, as displayed on the console when Ivy is initialized.
MessageLoggerEnginegetLoggerEngine()
PublishEnginegetPublishEngine()
RepositoryManagementEnginegetRepositoryEngine()
ResolutionCacheManagergetResolutionCacheManager()
ResolveEnginegetResolveEngine()
RetrieveEnginegetRetrieveEngine()
SearchEnginegetSearchEngine()
IvySettingsgetSettings()
SortEnginegetSortEngine()
StringgetVariable(String name)
static StringgetWorkingRevision()
ResolveReportinstall(ModuleRevisionId mrid, String from, String to, InstallOptions options)
voidinterrupt()
Interrupts the current running operation, no later than interruptTimeout milliseconds after the call
voidinterrupt(Thread operatingThread)
Interrupts the current running operation in the given operating thread, no later than interruptTimeout milliseconds after the call
booleanisInterrupted()
ModuleEntry[]listModuleEntries(OrganisationEntry org)
ModuleId[]listModules(ModuleId criteria, PatternMatcher matcher)
ModuleRevisionId[]listModules(ModuleRevisionId criteria, PatternMatcher matcher)
String[]listModules(String org)
OrganisationEntry[]listOrganisationEntries()
String[]listOrganisations()
RevisionEntry[]listRevisionEntries(ModuleEntry module)
String[]listRevisions(String org, String module)
String[]listTokenValues(String token, Map otherTokenValues)
static IvynewInstance()
static IvynewInstance(IvySettings settings)
voidpopContext()
Pops the current Ivy context.
Collectionpublish(ModuleRevisionId mrid, Collection srcArtifactPattern, String resolverName, PublishOptions options)
voidpushContext()
Pushes a new IvyContext bound to this Ivy instance if the current context is not already bound to this Ivy instance.
ResolveReportresolve(File ivySource)
ResolveReportresolve(URL ivySource)
ResolveReportresolve(ModuleRevisionId mrid, ResolveOptions options, boolean changing)
ResolveReportresolve(URL ivySource, ResolveOptions options)
ResolveReportresolve(ModuleDescriptor md, ResolveOptions options)
intretrieve(ModuleRevisionId mrid, String destFilePattern, RetrieveOptions options)
voidsetCheckEngine(CheckEngine checkEngine)
voidsetDeliverEngine(DeliverEngine deliverEngine)
voidsetEventManager(EventManager eventManager)
voidsetInstallEngine(InstallEngine installEngine)
voidsetPublishEngine(PublishEngine publishEngine)
voidsetRepositoryEngine(RepositoryManagementEngine repositoryEngine)
voidsetResolveEngine(ResolveEngine resolveEngine)
voidsetRetrieveEngine(RetrieveEngine retrieveEngine)
voidsetSearchEngine(SearchEngine searchEngine)
voidsetSettings(IvySettings settings)
voidsetSortEngine(SortEngine sortEngine)
voidsetVariable(String varName, String value)
ListsortModuleDescriptors(Collection moduleDescriptors, SortOptions options)
Sorts the given ModuleDescriptors from the less dependent to the more dependent.
ListsortNodes(Collection nodes, SortOptions options)
Sorts the collection of IvyNode from the less dependent to the more dependent
Stringsubstitute(String str)

Field Detail

DATE_FORMAT

public static final SimpleDateFormat DATE_FORMAT

Constructor Detail

Ivy

public Ivy()
The default constructor of Ivy allows to create an instance of Ivy with none of its dependencies (engines, settings, ...) created. If you use this constructor, it's your responsibility to set the dependencies of Ivy using the appropriate setters (setResolveEngine, ...). You can also call the bind method to set all the dependencies except those that you have provided using the setters. If you want to get an instance ready to use, prefer the use of Ivy.newInstance().

Method Detail

bind

public void bind()
This method is used to bind this Ivy instance to required dependencies, i.e. instance of settings, engines, and so on.

After this call Ivy is still not configured, which means that the settings object is still empty.

check

public boolean check(URL ivyFile, String resolvername)

checkInterrupted

public void checkInterrupted()
Check if the current operation has been interrupted, and if it is the case, throw a runtime exception

configure

public void configure(File settingsFile)

configure

public void configure(URL settingsURL)

configureDefault

public void configureDefault()

configureDefault14

public void configureDefault14()
Configures Ivy with 1.4 compatible default settings

deliver

public void deliver(ModuleRevisionId mrid, String revision, String destIvyPattern)

deliver

public void deliver(String revision, String destIvyPattern, DeliverOptions options)

deliver

public void deliver(ModuleRevisionId mrid, String revision, String destIvyPattern, DeliverOptions options)
Example of use: deliver(mrid, "1.5", "target/ivy/ivy-[revision].xml", DeliverOptions.newInstance(settings).setStatus("release").setValidate(false));

Parameters: mrid revision destIvyPattern options

Throws: IOException ParseException

execute

public Object execute(Ivy.IvyCallback callback)
Executes the given callback in the context of this Ivy instance.

Alternatively you can use the pushContext and popContext methods, but this is not recommended:

 Object result = null;
 pushContext();
 try {
     result = callback.doInIvyContext(this, IvyContext.getContext());
 } finally {
     popContext();
 }
 doSomethingWithResult(result);
 

Parameters: callback

Returns:

findModule

public ResolvedModuleRevision findModule(ModuleRevisionId mrid)

getCheckEngine

public CheckEngine getCheckEngine()

getDeliverEngine

public DeliverEngine getDeliverEngine()

getEventManager

public EventManager getEventManager()

getInstallEngine

public InstallEngine getInstallEngine()

getIvyDate

public static String getIvyDate()
Returns the date at which this version of Ivy has been built.

May be empty if unknown.

Returns: the date at which this version of Ivy has been built

getIvyHomeURL

public static String getIvyHomeURL()
Returns the URL at which Ivy web site can be found.

Returns: the URL at which Ivy web site can be found

getIvyVersion

public static String getIvyVersion()
Returns the current version of Ivy, as displayed on the console when Ivy is initialized.

Returns: the current version of Ivy

getLoggerEngine

public MessageLoggerEngine getLoggerEngine()

getPublishEngine

public PublishEngine getPublishEngine()

getRepositoryEngine

public RepositoryManagementEngine getRepositoryEngine()

getResolutionCacheManager

public ResolutionCacheManager getResolutionCacheManager()

getResolveEngine

public ResolveEngine getResolveEngine()

getRetrieveEngine

public RetrieveEngine getRetrieveEngine()

getSearchEngine

public SearchEngine getSearchEngine()

getSettings

public IvySettings getSettings()

getSortEngine

public SortEngine getSortEngine()

getVariable

public String getVariable(String name)

getWorkingRevision

public static String getWorkingRevision()

install

public ResolveReport install(ModuleRevisionId mrid, String from, String to, InstallOptions options)

interrupt

public void interrupt()
Interrupts the current running operation, no later than interruptTimeout milliseconds after the call

interrupt

public void interrupt(Thread operatingThread)
Interrupts the current running operation in the given operating thread, no later than interruptTimeout milliseconds after the call

isInterrupted

public boolean isInterrupted()

listModuleEntries

public ModuleEntry[] listModuleEntries(OrganisationEntry org)

listModules

public ModuleId[] listModules(ModuleId criteria, PatternMatcher matcher)

listModules

public ModuleRevisionId[] listModules(ModuleRevisionId criteria, PatternMatcher matcher)

listModules

public String[] listModules(String org)

listOrganisationEntries

public OrganisationEntry[] listOrganisationEntries()

listOrganisations

public String[] listOrganisations()

listRevisionEntries

public RevisionEntry[] listRevisionEntries(ModuleEntry module)

listRevisions

public String[] listRevisions(String org, String module)

listTokenValues

public String[] listTokenValues(String token, Map otherTokenValues)

newInstance

public static Ivy newInstance()

newInstance

public static Ivy newInstance(IvySettings settings)

popContext

public void popContext()
Pops the current Ivy context.

You must call this method once and only once for each call to pushContext, when you're done with the your Ivy related work.

Alternatively, you can use the execute method which takes care of everything for you.

publish

public Collection publish(ModuleRevisionId mrid, Collection srcArtifactPattern, String resolverName, PublishOptions options)

pushContext

public void pushContext()
Pushes a new IvyContext bound to this Ivy instance if the current context is not already bound to this Ivy instance. If the current context is already bound to this Ivy instance, it pushes the current context on the context stack, so that you can (and must) always call popContext when you're done.

Alternatively, you can use the execute method which takes care of everything for you.

resolve

public ResolveReport resolve(File ivySource)

resolve

public ResolveReport resolve(URL ivySource)

resolve

public ResolveReport resolve(ModuleRevisionId mrid, ResolveOptions options, boolean changing)

resolve

public ResolveReport resolve(URL ivySource, ResolveOptions options)

resolve

public ResolveReport resolve(ModuleDescriptor md, ResolveOptions options)

retrieve

public int retrieve(ModuleRevisionId mrid, String destFilePattern, RetrieveOptions options)

setCheckEngine

public void setCheckEngine(CheckEngine checkEngine)

setDeliverEngine

public void setDeliverEngine(DeliverEngine deliverEngine)

setEventManager

public void setEventManager(EventManager eventManager)

setInstallEngine

public void setInstallEngine(InstallEngine installEngine)

setPublishEngine

public void setPublishEngine(PublishEngine publishEngine)

setRepositoryEngine

public void setRepositoryEngine(RepositoryManagementEngine repositoryEngine)

setResolveEngine

public void setResolveEngine(ResolveEngine resolveEngine)

setRetrieveEngine

public void setRetrieveEngine(RetrieveEngine retrieveEngine)

setSearchEngine

public void setSearchEngine(SearchEngine searchEngine)

setSettings

public void setSettings(IvySettings settings)

setSortEngine

public void setSortEngine(SortEngine sortEngine)

setVariable

public void setVariable(String varName, String value)

sortModuleDescriptors

public List sortModuleDescriptors(Collection moduleDescriptors, SortOptions options)
Sorts the given ModuleDescriptors from the less dependent to the more dependent. This sort ensures that a ModuleDescriptor is always found in the list before all ModuleDescriptors depending directly on it.

Parameters: moduleDescriptors a Collection of ModuleDescriptor to sort options Options to use to sort the descriptors.

Returns: a List of sorted ModuleDescriptors

Throws: CircularDependencyException if a circular dependency exists and circular dependency strategy decide to throw an exception

sortNodes

public List sortNodes(Collection nodes, SortOptions options)
Sorts the collection of IvyNode from the less dependent to the more dependent

substitute

public String substitute(String str)