Class Ivy
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 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(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
Modifier and TypeClassDescriptionstatic interface
Callback used to execute a set of Ivy related methods within anIvyContext
. -
Field Summary
-
Constructor Summary
ConstructorDescriptionIvy()
The default constructor of Ivy allows to create an instance of Ivy with none of its dependencies (engines, settings, ...) created. -
Method Summary
Modifier and TypeMethodDescriptionvoid
bind()
This method is used to bind this Ivy instance to required dependencies, i.e.boolean
void
Check if the current operation has been interrupted, and if it is the case, throw a runtime exceptionvoid
void
void
void
Configures Ivy with 1.4 compatible default settingsvoid
deliver
(String revision, String destIvyPattern, DeliverOptions options) void
deliver
(ModuleRevisionId mrid, String revision, String destIvyPattern) 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));execute
(Ivy.IvyCallback callback) Executes the given callback in the context of this Ivy instance.findModule
(ModuleRevisionId mrid) static String
Returns the date at which this version of Ivy has been built.static String
Returns the URL at which Ivy web site can be found.static String
Returns the current version of Ivy, as displayed on the console when Ivy is initialized.getVariable
(String name) static String
install
(ModuleRevisionId mrid, String from, String to, InstallOptions options) void
Interrupts the current running operation, no later than interruptTimeout milliseconds after the callvoid
Interrupts the current running operation in the given operating thread, no later than interruptTimeout milliseconds after the callboolean
String[]
listModules
(String org) ModuleId[]
listModules
(ModuleId criteria, PatternMatcher matcher) listModules
(ModuleRevisionId criteria, PatternMatcher matcher) String[]
listRevisionEntries
(ModuleEntry module) String[]
listRevisions
(String org, String module) String[]
listTokenValues
(String token, Map<String, Object> otherTokenValues) static Ivy
static Ivy
newInstance
(IvySettings settings) void
Pops the current Ivy context.publish
(ModuleRevisionId mrid, Collection<String> srcArtifactPattern, String resolverName, PublishOptions options) void
Pushes a new IvyContext bound to this Ivy instance if the current context is not already bound to this Ivy instance.resolve
(File ivySource, ResolveOptions options) resolve
(URL ivySource, ResolveOptions options) resolve
(ModuleDescriptor md, ResolveOptions options) resolve
(ModuleRevisionId mrid, ResolveOptions options, boolean changing) int
retrieve
(ModuleRevisionId mrid, String destFilePattern, RetrieveOptions options) Deprecated.retrieve
(ModuleRevisionId mrid, RetrieveOptions options) void
setCheckEngine
(CheckEngine checkEngine) void
setDeliverEngine
(DeliverEngine deliverEngine) void
setEventManager
(EventManager eventManager) void
setInstallEngine
(InstallEngine installEngine) void
setPublishEngine
(PublishEngine publishEngine) void
setRepositoryEngine
(RepositoryManagementEngine repositoryEngine) void
setResolveEngine
(ResolveEngine resolveEngine) void
setRetrieveEngine
(RetrieveEngine retrieveEngine) void
setSearchEngine
(SearchEngine searchEngine) void
setSettings
(IvySettings settings) void
setSortEngine
(SortEngine sortEngine) void
setVariable
(String varName, String value) sortModuleDescriptors
(Collection<ModuleDescriptor> moduleDescriptors, SortOptions options) Sorts the given ModuleDescriptors from the less dependent to the more dependent.sortNodes
(Collection<IvyNode> nodes, SortOptions options) Sorts the collection of IvyNode from the less dependent to the more dependentsubstitute
(String str)
-
Field Details
-
DATE_FORMAT
Deprecated.Use theDateUtil
utility class instead.
-
-
Constructor Details
-
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 Details
-
getIvyVersion
Returns the current version of Ivy, as displayed on the console when Ivy is initialized.- Returns:
- the current version of Ivy
-
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
Returns the URL at which Ivy web site can be found.- Returns:
- the URL at which Ivy web site can be found
-
newInstance
-
newInstance
-
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
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
- Throws:
ParseException
IOException
-
configure
- Throws:
ParseException
IOException
-
configureDefault
- Throws:
ParseException
IOException
-
configureDefault14
Configures Ivy with 1.4 compatible default settings- Throws:
ParseException
- if something goes wrongIOException
- if something goes wrong
-
check
-
resolve
- Throws:
ParseException
IOException
-
resolve
- Throws:
ParseException
IOException
-
resolve
public ResolveReport resolve(ModuleRevisionId mrid, ResolveOptions options, boolean changing) throws ParseException, IOException - Throws:
ParseException
IOException
-
resolve
public ResolveReport resolve(URL ivySource, ResolveOptions options) throws ParseException, IOException - Throws:
ParseException
IOException
-
resolve
public ResolveReport resolve(File ivySource, ResolveOptions options) throws ParseException, IOException - Throws:
ParseException
IOException
-
resolve
public ResolveReport resolve(ModuleDescriptor md, ResolveOptions options) throws ParseException, IOException - Throws:
ParseException
IOException
-
install
public ResolveReport install(ModuleRevisionId mrid, String from, String to, InstallOptions options) throws IOException - Throws:
IOException
-
retrieve
@Deprecated public int retrieve(ModuleRevisionId mrid, String destFilePattern, RetrieveOptions options) throws IOException Deprecated.- Throws:
IOException
-
retrieve
- Throws:
IOException
-
deliver
public void deliver(ModuleRevisionId mrid, String revision, String destIvyPattern) throws IOException, ParseException - Throws:
IOException
ParseException
-
deliver
public void deliver(String revision, String destIvyPattern, DeliverOptions options) throws IOException, ParseException - Throws:
IOException
ParseException
-
deliver
public void deliver(ModuleRevisionId mrid, String revision, String destIvyPattern, DeliverOptions options) throws IOException, 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:
IOException
- if something goes wrongParseException
- if something goes wrong
-
publish
public Collection<Artifact> publish(ModuleRevisionId mrid, Collection<String> srcArtifactPattern, String resolverName, PublishOptions options) throws IOException - Throws:
IOException
-
sortNodes
Sorts the collection of IvyNode from the less dependent to the more dependent- Parameters:
nodes
- Collection<IvyNode>options
- SortOptions- Returns:
- List<IvyNode>
-
sortModuleDescriptors
public List<ModuleDescriptor> sortModuleDescriptors(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
-
listModuleEntries
-
listModules
-
listModules
-
listModules
-
listOrganisationEntries
-
listOrganisations
-
listRevisionEntries
-
listRevisions
-
listTokenValues
-
interrupt
public void interrupt()Interrupts the current running operation, no later than interruptTimeout milliseconds after the call -
interrupt
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
-
getResolutionCacheManager
-
getVariable
-
substitute
-
setVariable
-
getSettings
-
getEventManager
-
getCheckEngine
-
setCheckEngine
-
getDeliverEngine
-
setDeliverEngine
-
getInstallEngine
-
setInstallEngine
-
getPublishEngine
-
setPublishEngine
-
getResolveEngine
-
setResolveEngine
-
getRetrieveEngine
-
setRetrieveEngine
-
getSearchEngine
-
setSearchEngine
-
getSortEngine
-
setSortEngine
-
getRepositoryEngine
-
setRepositoryEngine
-
setEventManager
-
setSettings
-
getLoggerEngine
-
DateUtil
utility class instead.