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
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCallback used to execute a set of Ivy related methods within anIvyContext. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionIvy()The default constructor of Ivy allows to create an instance of Ivy with none of its dependencies (engines, settings, ...) created. -
Method Summary
Modifier and TypeMethodDescriptionvoidbind()This method is used to bind this Ivy instance to required dependencies, i.e.booleanvoidCheck if the current operation has been interrupted, and if it is the case, throw a runtime exceptionvoidvoidvoidvoidConfigures Ivy with 1.4 compatible default settingsvoiddeliver(String revision, String destIvyPattern, DeliverOptions options) voiddeliver(ModuleRevisionId mrid, String revision, String destIvyPattern) 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));execute(Ivy.IvyCallback callback) Executes the given callback in the context of this Ivy instance.findModule(ModuleRevisionId mrid) static StringReturns the date at which this version of Ivy has been built.static StringReturns the URL at which Ivy web site can be found.static StringReturns the current version of Ivy, as displayed on the console when Ivy is initialized.getVariable(String name) static Stringinstall(ModuleRevisionId mrid, String from, String to, InstallOptions options) voidInterrupts the current running operation, no later than interruptTimeout milliseconds after the callvoidInterrupts the current running operation in the given operating thread, no later than interruptTimeout milliseconds after the callbooleanString[]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 Ivystatic IvynewInstance(IvySettings settings) voidPops the current Ivy context.publish(ModuleRevisionId mrid, Collection<String> srcArtifactPattern, String resolverName, PublishOptions options) voidPushes 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) intretrieve(ModuleRevisionId mrid, String destFilePattern, RetrieveOptions options) Deprecated.retrieve(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(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 theDateUtilutility 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:
ParseExceptionIOException
-
configure
- Throws:
ParseExceptionIOException
-
configureDefault
- Throws:
ParseExceptionIOException
-
configureDefault14
Configures Ivy with 1.4 compatible default settings- Throws:
ParseException- if something goes wrongIOException- if something goes wrong
-
check
-
resolve
- Throws:
ParseExceptionIOException
-
resolve
- Throws:
ParseExceptionIOException
-
resolve
public ResolveReport resolve(ModuleRevisionId mrid, ResolveOptions options, boolean changing) throws ParseException, IOException - Throws:
ParseExceptionIOException
-
resolve
public ResolveReport resolve(URL ivySource, ResolveOptions options) throws ParseException, IOException - Throws:
ParseExceptionIOException
-
resolve
public ResolveReport resolve(File ivySource, ResolveOptions options) throws ParseException, IOException - Throws:
ParseExceptionIOException
-
resolve
public ResolveReport resolve(ModuleDescriptor md, ResolveOptions options) throws ParseException, IOException - Throws:
ParseExceptionIOException
-
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:
IOExceptionParseException
-
deliver
public void deliver(String revision, String destIvyPattern, DeliverOptions options) throws IOException, ParseException - Throws:
IOExceptionParseException
-
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
-
DateUtilutility class instead.