Search in sources :

Example 1 with IvyAntSettings

use of org.apache.ivy.ant.IvyAntSettings in project build-info by JFrogDev.

the class ArtifactoryBuildListener method getEventManager.

/**
 * Retrieves all the event managers of all the ivy settings of the project.
 *
 * @param task the task we need to attach listeners to
 * @return the list of event manager for this task
 */
private List<EventManager> getEventManager(Task task) {
    List<EventManager> results = new ArrayList<EventManager>();
    Project project = task.getProject();
    Enumeration<Object> elements = project.getReferences().elements();
    // Iterate the project elements, search for ivy:settings and return them:
    while (elements.hasMoreElements()) {
        Object element = elements.nextElement();
        if (element instanceof UnknownElement) {
            UnknownElement unknown = (UnknownElement) element;
            element = unknown.getRealThing();
            if (element == null) {
                unknown.maybeConfigure();
                element = unknown.getRealThing();
            }
        }
        if (element instanceof IvyAntSettings) {
            results.add(((IvyAntSettings) element).getConfiguredIvyInstance(task).getResolveEngine().getEventManager());
        }
    }
    // If no ivy:settings were found (the ivy script might not include them), return the resolve engine:
    if (results.isEmpty()) {
        ResolveEngine engine = IvyAntSettings.getDefaultInstance(task).getConfiguredIvyInstance(task).getResolveEngine();
        results.add(engine.getEventManager());
    }
    return results;
}
Also used : ResolveEngine(org.apache.ivy.core.resolve.ResolveEngine) EventManager(org.apache.ivy.core.event.EventManager) IvyAntSettings(org.apache.ivy.ant.IvyAntSettings)

Aggregations

IvyAntSettings (org.apache.ivy.ant.IvyAntSettings)1 EventManager (org.apache.ivy.core.event.EventManager)1 ResolveEngine (org.apache.ivy.core.resolve.ResolveEngine)1