Class Ivy
- java.lang.Object
-
- org.apache.ivy.Ivy
-
public class Ivy extends java.lang.ObjectIvy 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:
- resolve dependencies
- retrieve artifacts to a local location
- deliver and publish modules
- repository search and listing
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
Ivyclass are not flexible enough and you want to use Ivy engines directly, you need to call the methods within a singleIvyContextassociated to theIvyinstance you use.To do so, it is recommended to use the
execute(org.apache.ivy.Ivy.IvyCallback)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
Nested Classes Modifier and Type Class Description static interfaceIvy.IvyCallbackCallback used to execute a set of Ivy related methods within anIvyContext.
-
Field Summary
Fields Modifier and Type Field Description private booleanboundTrue if this instance of Ivy has already been bound to its dependencies, false otherwise.private CheckEnginecheckEnginestatic java.text.SimpleDateFormatDATE_FORMATDeprecated.Use theDateUtilutility class instead.private DeliverEnginedeliverEngineprivate EventManagereventManagerprivate InstallEngineinstallEngineprivate booleaninterruptedTrue if the current processing has been requested to be interrupted, false otherwiseprivate static java.lang.StringIVY_DATEthe date at which this version of Ivy has been built.private static java.lang.StringIVY_VERSIONthe current version of Ivy, as displayed on the console when Ivy is initializedprivate static intKILOprivate MessageLoggerEngineloggerEngineThe logger engine to use to log messages when using this Ivy instance.private PublishEnginepublishEngineprivate RepositoryManagementEnginerepositoryEngineprivate ResolveEngineresolveEngineprivate RetrieveEngineretrieveEngineprivate SearchEnginesearchEngineprivate IvySettingssettingsprivate SortEnginesortEngine
-
Constructor Summary
Constructors Constructor Description Ivy()The default constructor of Ivy allows to create an instance of Ivy with none of its dependencies (engines, settings, ...) created.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private voidassertBound()voidbind()This method is used to bind this Ivy instance to required dependencies, i.e.booleancheck(java.net.URL ivyFile, java.lang.String resolvername)voidcheckInterrupted()Check if the current operation has been interrupted, and if it is the case, throw a runtime exceptionvoidconfigure(java.io.File settingsFile)voidconfigure(java.net.URL settingsURL)voidconfigureDefault()voidconfigureDefault14()Configures Ivy with 1.4 compatible default settingsvoiddeliver(java.lang.String revision, java.lang.String destIvyPattern, DeliverOptions options)voiddeliver(ModuleRevisionId mrid, java.lang.String revision, java.lang.String destIvyPattern)voiddeliver(ModuleRevisionId mrid, java.lang.String revision, java.lang.String destIvyPattern, DeliverOptions options)Example of use: deliver(mrid, "1.5", "target/ivy/ivy-[revision].xml", DeliverOptions.newInstance(settings).setStatus("release").setValidate(false));java.lang.Objectexecute(Ivy.IvyCallback callback)Executes the given callback in the context of this Ivy instance.ResolvedModuleRevisionfindModule(ModuleRevisionId mrid)CheckEnginegetCheckEngine()DeliverEnginegetDeliverEngine()EventManagergetEventManager()InstallEnginegetInstallEngine()static java.lang.StringgetIvyDate()Returns the date at which this version of Ivy has been built.static java.lang.StringgetIvyHomeURL()Returns the URL at which Ivy web site can be found.static java.lang.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()java.lang.StringgetVariable(java.lang.String name)static java.lang.StringgetWorkingRevision()ResolveReportinstall(ModuleRevisionId mrid, java.lang.String from, java.lang.String to, InstallOptions options)voidinterrupt()Interrupts the current running operation, no later than interruptTimeout milliseconds after the callvoidinterrupt(java.lang.Thread operatingThread)Interrupts the current running operation in the given operating thread, no later than interruptTimeout milliseconds after the callbooleanisInterrupted()ModuleEntry[]listModuleEntries(OrganisationEntry org)java.lang.String[]listModules(java.lang.String org)ModuleId[]listModules(ModuleId criteria, PatternMatcher matcher)ModuleRevisionId[]listModules(ModuleRevisionId criteria, PatternMatcher matcher)OrganisationEntry[]listOrganisationEntries()java.lang.String[]listOrganisations()RevisionEntry[]listRevisionEntries(ModuleEntry module)java.lang.String[]listRevisions(java.lang.String org, java.lang.String module)java.lang.String[]listTokenValues(java.lang.String token, java.util.Map<java.lang.String,java.lang.Object> otherTokenValues)static IvynewInstance()static IvynewInstance(IvySettings settings)voidpopContext()Pops the current Ivy context.private voidpostConfigure()java.util.Collection<Artifact>publish(ModuleRevisionId mrid, java.util.Collection<java.lang.String> srcArtifactPattern, java.lang.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(java.io.File ivySource)ResolveReportresolve(java.io.File ivySource, ResolveOptions options)ResolveReportresolve(java.net.URL ivySource)ResolveReportresolve(java.net.URL ivySource, ResolveOptions options)ResolveReportresolve(ModuleDescriptor md, ResolveOptions options)ResolveReportresolve(ModuleRevisionId mrid, ResolveOptions options, boolean changing)intretrieve(ModuleRevisionId mrid, java.lang.String destFilePattern, RetrieveOptions options)Deprecated.RetrieveReportretrieve(ModuleRevisionId mrid, 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(java.lang.String varName, java.lang.String value)java.util.List<ModuleDescriptor>sortModuleDescriptors(java.util.Collection<ModuleDescriptor> moduleDescriptors, SortOptions options)Sorts the given ModuleDescriptors from the less dependent to the more dependent.java.util.List<IvyNode>sortNodes(java.util.Collection<IvyNode> nodes, SortOptions options)Sorts the collection of IvyNode from the less dependent to the more dependentjava.lang.Stringsubstitute(java.lang.String str)
-
-
-
Field Detail
-
KILO
private static final int KILO
- See Also:
- Constant Field Values
-
DATE_FORMAT
@Deprecated public static final java.text.SimpleDateFormat DATE_FORMAT
Deprecated.Use theDateUtilutility class instead.
-
IVY_VERSION
private static final java.lang.String IVY_VERSION
the current version of Ivy, as displayed on the console when Ivy is initialized
-
IVY_DATE
private static final java.lang.String IVY_DATE
the date at which this version of Ivy has been built. May be empty if unknown.
-
interrupted
private boolean interrupted
True if the current processing has been requested to be interrupted, false otherwise
-
bound
private boolean bound
True if this instance of Ivy has already been bound to its dependencies, false otherwise.- See Also:
bind()
-
settings
private IvySettings settings
-
eventManager
private EventManager eventManager
-
sortEngine
private SortEngine sortEngine
-
searchEngine
private SearchEngine searchEngine
-
checkEngine
private CheckEngine checkEngine
-
resolveEngine
private ResolveEngine resolveEngine
-
retrieveEngine
private RetrieveEngine retrieveEngine
-
deliverEngine
private DeliverEngine deliverEngine
-
publishEngine
private PublishEngine publishEngine
-
installEngine
private InstallEngine installEngine
-
repositoryEngine
private RepositoryManagementEngine repositoryEngine
-
loggerEngine
private MessageLoggerEngine loggerEngine
The logger engine to use to log messages when using this Ivy instance.
-
-
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
-
getIvyVersion
public static java.lang.String getIvyVersion()
Returns the current version of Ivy, as displayed on the console when Ivy is initialized.- Returns:
- the current version of Ivy
-
getIvyDate
public static java.lang.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 java.lang.String getIvyHomeURL()
Returns the URL at which Ivy web site can be found.- Returns:
- the URL at which Ivy web site can be found
-
newInstance
public static Ivy newInstance()
-
newInstance
public static Ivy newInstance(IvySettings settings)
-
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.
-
execute
public java.lang.Object execute(Ivy.IvyCallback callback)
Executes the given callback in the context of this Ivy instance.Alternatively you can use the
pushContext()andpopContext()methods, but this is not recommended:Object result = null; pushContext(); try { result = callback.doInIvyContext(this, IvyContext.getContext()); } finally { popContext(); } doSomethingWithResult(result);- Parameters:
callback- IvyCallback- Returns:
- Object
-
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 callpopContext()when you're done.Alternatively, you can use the
execute(org.apache.ivy.Ivy.IvyCallback)method which takes care of everything for you.
-
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(org.apache.ivy.Ivy.IvyCallback)method which takes care of everything for you.
-
configure
public void configure(java.io.File settingsFile) throws java.text.ParseException, java.io.IOException- Throws:
java.text.ParseExceptionjava.io.IOException
-
configure
public void configure(java.net.URL settingsURL) throws java.text.ParseException, java.io.IOException- Throws:
java.text.ParseExceptionjava.io.IOException
-
configureDefault
public void configureDefault() throws java.text.ParseException, java.io.IOException- Throws:
java.text.ParseExceptionjava.io.IOException
-
configureDefault14
public void configureDefault14() throws java.text.ParseException, java.io.IOExceptionConfigures Ivy with 1.4 compatible default settings- Throws:
java.text.ParseException- if something goes wrongjava.io.IOException- if something goes wrong
-
check
public boolean check(java.net.URL ivyFile, java.lang.String resolvername)
-
resolve
public ResolveReport resolve(java.io.File ivySource) throws java.text.ParseException, java.io.IOException
- Throws:
java.text.ParseExceptionjava.io.IOException
-
resolve
public ResolveReport resolve(java.net.URL ivySource) throws java.text.ParseException, java.io.IOException
- Throws:
java.text.ParseExceptionjava.io.IOException
-
resolve
public ResolveReport resolve(ModuleRevisionId mrid, ResolveOptions options, boolean changing) throws java.text.ParseException, java.io.IOException
- Throws:
java.text.ParseExceptionjava.io.IOException
-
resolve
public ResolveReport resolve(java.net.URL ivySource, ResolveOptions options) throws java.text.ParseException, java.io.IOException
- Throws:
java.text.ParseExceptionjava.io.IOException
-
resolve
public ResolveReport resolve(java.io.File ivySource, ResolveOptions options) throws java.text.ParseException, java.io.IOException
- Throws:
java.text.ParseExceptionjava.io.IOException
-
resolve
public ResolveReport resolve(ModuleDescriptor md, ResolveOptions options) throws java.text.ParseException, java.io.IOException
- Throws:
java.text.ParseExceptionjava.io.IOException
-
install
public ResolveReport install(ModuleRevisionId mrid, java.lang.String from, java.lang.String to, InstallOptions options) throws java.io.IOException
- Throws:
java.io.IOException
-
retrieve
@Deprecated public int retrieve(ModuleRevisionId mrid, java.lang.String destFilePattern, RetrieveOptions options) throws java.io.IOException
Deprecated.- Throws:
java.io.IOException
-
retrieve
public RetrieveReport retrieve(ModuleRevisionId mrid, RetrieveOptions options) throws java.io.IOException
- Throws:
java.io.IOException
-
deliver
public void deliver(ModuleRevisionId mrid, java.lang.String revision, java.lang.String destIvyPattern) throws java.io.IOException, java.text.ParseException
- Throws:
java.io.IOExceptionjava.text.ParseException
-
deliver
public void deliver(java.lang.String revision, java.lang.String destIvyPattern, DeliverOptions options) throws java.io.IOException, java.text.ParseException- Throws:
java.io.IOExceptionjava.text.ParseException
-
deliver
public void deliver(ModuleRevisionId mrid, java.lang.String revision, java.lang.String destIvyPattern, DeliverOptions options) throws java.io.IOException, java.text.ParseException
Example of use: deliver(mrid, "1.5", "target/ivy/ivy-[revision].xml", DeliverOptions.newInstance(settings).setStatus("release").setValidate(false));- Parameters:
mrid- ModuleRevisionIdrevision- StringdestIvyPattern- Stringoptions- DeliverOptions- Throws:
java.io.IOException- if something goes wrongjava.text.ParseException- if something goes wrong
-
publish
public java.util.Collection<Artifact> publish(ModuleRevisionId mrid, java.util.Collection<java.lang.String> srcArtifactPattern, java.lang.String resolverName, PublishOptions options) throws java.io.IOException
- Throws:
java.io.IOException
-
sortNodes
public java.util.List<IvyNode> sortNodes(java.util.Collection<IvyNode> nodes, SortOptions options)
Sorts the collection of IvyNode from the less dependent to the more dependent- Parameters:
nodes- Collection<IvyNode>options- SortOptions- Returns:
- List<IvyNode>
-
sortModuleDescriptors
public java.util.List<ModuleDescriptor> sortModuleDescriptors(java.util.Collection<ModuleDescriptor> 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 sortoptions- 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
-
findModule
public ResolvedModuleRevision findModule(ModuleRevisionId mrid)
-
listModuleEntries
public ModuleEntry[] listModuleEntries(OrganisationEntry org)
-
listModules
public ModuleId[] listModules(ModuleId criteria, PatternMatcher matcher)
-
listModules
public ModuleRevisionId[] listModules(ModuleRevisionId criteria, PatternMatcher matcher)
-
listModules
public java.lang.String[] listModules(java.lang.String org)
-
listOrganisationEntries
public OrganisationEntry[] listOrganisationEntries()
-
listOrganisations
public java.lang.String[] listOrganisations()
-
listRevisionEntries
public RevisionEntry[] listRevisionEntries(ModuleEntry module)
-
listRevisions
public java.lang.String[] listRevisions(java.lang.String org, java.lang.String module)
-
listTokenValues
public java.lang.String[] listTokenValues(java.lang.String token, java.util.Map<java.lang.String,java.lang.Object> otherTokenValues)
-
interrupt
public void interrupt()
Interrupts the current running operation, no later than interruptTimeout milliseconds after the call
-
interrupt
public void interrupt(java.lang.Thread operatingThread)
Interrupts the current running operation in the given operating thread, no later than interruptTimeout milliseconds after the call- Parameters:
operatingThread- Thread
-
isInterrupted
public boolean isInterrupted()
-
checkInterrupted
public void checkInterrupted()
Check if the current operation has been interrupted, and if it is the case, throw a runtime exception
-
getWorkingRevision
public static java.lang.String getWorkingRevision()
-
getResolutionCacheManager
public ResolutionCacheManager getResolutionCacheManager()
-
assertBound
private void assertBound()
-
postConfigure
private void postConfigure()
-
getVariable
public java.lang.String getVariable(java.lang.String name)
-
substitute
public java.lang.String substitute(java.lang.String str)
-
setVariable
public void setVariable(java.lang.String varName, java.lang.String value)
-
getSettings
public IvySettings getSettings()
-
getEventManager
public EventManager getEventManager()
-
getCheckEngine
public CheckEngine getCheckEngine()
-
setCheckEngine
public void setCheckEngine(CheckEngine checkEngine)
-
getDeliverEngine
public DeliverEngine getDeliverEngine()
-
setDeliverEngine
public void setDeliverEngine(DeliverEngine deliverEngine)
-
getInstallEngine
public InstallEngine getInstallEngine()
-
setInstallEngine
public void setInstallEngine(InstallEngine installEngine)
-
getPublishEngine
public PublishEngine getPublishEngine()
-
setPublishEngine
public void setPublishEngine(PublishEngine publishEngine)
-
getResolveEngine
public ResolveEngine getResolveEngine()
-
setResolveEngine
public void setResolveEngine(ResolveEngine resolveEngine)
-
getRetrieveEngine
public RetrieveEngine getRetrieveEngine()
-
setRetrieveEngine
public void setRetrieveEngine(RetrieveEngine retrieveEngine)
-
getSearchEngine
public SearchEngine getSearchEngine()
-
setSearchEngine
public void setSearchEngine(SearchEngine searchEngine)
-
getSortEngine
public SortEngine getSortEngine()
-
setSortEngine
public void setSortEngine(SortEngine sortEngine)
-
getRepositoryEngine
public RepositoryManagementEngine getRepositoryEngine()
-
setRepositoryEngine
public void setRepositoryEngine(RepositoryManagementEngine repositoryEngine)
-
setEventManager
public void setEventManager(EventManager eventManager)
-
setSettings
public void setSettings(IvySettings settings)
-
getLoggerEngine
public MessageLoggerEngine getLoggerEngine()
-
-