Search in sources :

Example 1 with RepositoryManagementEngine

use of org.apache.ivy.core.repository.RepositoryManagementEngine in project ant-ivy by apache.

the class Ivy method bind.

/**
 * This method is used to bind this Ivy instance to required dependencies, i.e. instance of
 * settings, engines, and so on.
 * <p>
 * After this call Ivy is still not configured, which means that the settings object is still
 * empty.
 * </p>
 */
public void bind() {
    pushContext();
    try {
        if (settings == null) {
            settings = new IvySettings();
        }
        if (eventManager == null) {
            eventManager = new EventManager();
        }
        if (sortEngine == null) {
            sortEngine = new SortEngine(settings);
        }
        if (searchEngine == null) {
            searchEngine = new SearchEngine(settings);
        }
        if (resolveEngine == null) {
            resolveEngine = new ResolveEngine(settings, eventManager, sortEngine);
        }
        if (retrieveEngine == null) {
            retrieveEngine = new RetrieveEngine(settings, eventManager);
        }
        if (deliverEngine == null) {
            deliverEngine = new DeliverEngine(settings);
        }
        if (publishEngine == null) {
            publishEngine = new PublishEngine(settings, eventManager);
        }
        if (installEngine == null) {
            installEngine = new InstallEngine(settings, searchEngine, resolveEngine);
        }
        if (repositoryEngine == null) {
            repositoryEngine = new RepositoryManagementEngine(settings, searchEngine, resolveEngine);
        }
        eventManager.addTransferListener(new TransferListener() {

            public void transferProgress(TransferEvent evt) {
                ResolveData resolve;
                switch(evt.getEventType()) {
                    case TransferEvent.TRANSFER_PROGRESS:
                        resolve = IvyContext.getContext().getResolveData();
                        if (resolve == null || !LogOptions.LOG_QUIET.equals(resolve.getOptions().getLog())) {
                            Message.progress();
                        }
                        break;
                    case TransferEvent.TRANSFER_COMPLETED:
                        resolve = IvyContext.getContext().getResolveData();
                        if (resolve == null || !LogOptions.LOG_QUIET.equals(resolve.getOptions().getLog())) {
                            Message.endProgress(" (" + (evt.getTotalLength() / KILO) + "kB)");
                        }
                        break;
                    default:
                        break;
                }
            }
        });
        bound = true;
    } finally {
        popContext();
    }
}
Also used : TransferListener(org.apache.ivy.plugins.repository.TransferListener) EventManager(org.apache.ivy.core.event.EventManager) DeliverEngine(org.apache.ivy.core.deliver.DeliverEngine) TransferEvent(org.apache.ivy.plugins.repository.TransferEvent) IvySettings(org.apache.ivy.core.settings.IvySettings) ResolveEngine(org.apache.ivy.core.resolve.ResolveEngine) RetrieveEngine(org.apache.ivy.core.retrieve.RetrieveEngine) RepositoryManagementEngine(org.apache.ivy.core.repository.RepositoryManagementEngine) SortEngine(org.apache.ivy.core.sort.SortEngine) ResolveData(org.apache.ivy.core.resolve.ResolveData) SearchEngine(org.apache.ivy.core.search.SearchEngine) PublishEngine(org.apache.ivy.core.publish.PublishEngine) InstallEngine(org.apache.ivy.core.install.InstallEngine)

Aggregations

DeliverEngine (org.apache.ivy.core.deliver.DeliverEngine)1 EventManager (org.apache.ivy.core.event.EventManager)1 InstallEngine (org.apache.ivy.core.install.InstallEngine)1 PublishEngine (org.apache.ivy.core.publish.PublishEngine)1 RepositoryManagementEngine (org.apache.ivy.core.repository.RepositoryManagementEngine)1 ResolveData (org.apache.ivy.core.resolve.ResolveData)1 ResolveEngine (org.apache.ivy.core.resolve.ResolveEngine)1 RetrieveEngine (org.apache.ivy.core.retrieve.RetrieveEngine)1 SearchEngine (org.apache.ivy.core.search.SearchEngine)1 IvySettings (org.apache.ivy.core.settings.IvySettings)1 SortEngine (org.apache.ivy.core.sort.SortEngine)1 TransferEvent (org.apache.ivy.plugins.repository.TransferEvent)1 TransferListener (org.apache.ivy.plugins.repository.TransferListener)1