Search in sources :

Example 11 with EventManager

use of org.apache.ivy.core.event.EventManager in project ant-ivy by apache.

the class WarnCircularDependencyStrategyTest method setResolveContext.

private void setResolveContext(String resolveId) {
    IvySettings settings = new IvySettings();
    IvyContext.getContext().setResolveData(new ResolveData(new ResolveEngine(settings, new EventManager(), new SortEngine(settings)), new ResolveOptions().setResolveId(resolveId)));
}
Also used : ResolveEngine(org.apache.ivy.core.resolve.ResolveEngine) ResolveData(org.apache.ivy.core.resolve.ResolveData) SortEngine(org.apache.ivy.core.sort.SortEngine) EventManager(org.apache.ivy.core.event.EventManager) IvySettings(org.apache.ivy.core.settings.IvySettings) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions)

Example 12 with EventManager

use of org.apache.ivy.core.event.EventManager in project ant-ivy by apache.

the class OBRResolver method init.

@Override
protected void init() {
    if (repoXmlFile != null && repoXmlURL != null) {
        throw new RuntimeException("The OBR repository resolver " + getName() + " couldn't be configured: repoXmlFile and repoXmlUrl cannot be set both");
    }
    if (repoXmlFile != null) {
        File f = new File(repoXmlFile);
        loadRepoFromFile(f.getParentFile().toURI(), f, repoXmlFile);
    } else if (repoXmlURL != null) {
        final URL url;
        try {
            url = new URL(repoXmlURL);
        } catch (MalformedURLException e) {
            throw new RuntimeException("The OBR repository resolver " + getName() + " couldn't be configured: repoXmlURL '" + repoXmlURL + "' is not an URL");
        }
        ArtifactDownloadReport report;
        EventManager eventManager = getEventManager();
        try {
            if (eventManager != null) {
                getRepository().addTransferListener(eventManager);
            }
            final Resource obrResource = new URLResource(url, this.getTimeoutConstraint());
            CacheResourceOptions options = new CacheResourceOptions();
            if (metadataTtl != null) {
                options.setTtl(metadataTtl);
            }
            if (forceMetadataUpdate != null) {
                options.setForce(forceMetadataUpdate);
            }
            report = getRepositoryCacheManager().downloadRepositoryResource(obrResource, "obr", "obr", "xml", options, getRepository());
        } finally {
            if (eventManager != null) {
                getRepository().removeTransferListener(eventManager);
            }
        }
        URI baseURI;
        try {
            baseURI = new URI(repoXmlURL);
        } catch (URISyntaxException e) {
            throw new RuntimeException("illegal uri");
        }
        loadRepoFromFile(baseURI, report.getLocalFile(), repoXmlURL);
    } else {
        throw new RuntimeException("The OBR repository resolver " + getName() + " couldn't be configured: repoXmlFile or repoXmlUrl is missing");
    }
}
Also used : URLResource(org.apache.ivy.plugins.repository.url.URLResource) MalformedURLException(java.net.MalformedURLException) EventManager(org.apache.ivy.core.event.EventManager) Resource(org.apache.ivy.plugins.repository.Resource) URLResource(org.apache.ivy.plugins.repository.url.URLResource) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) CacheResourceOptions(org.apache.ivy.core.cache.CacheResourceOptions) URISyntaxException(java.net.URISyntaxException) File(java.io.File) URI(java.net.URI) URL(java.net.URL)

Example 13 with EventManager

use of org.apache.ivy.core.event.EventManager 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)

Example 14 with EventManager

use of org.apache.ivy.core.event.EventManager in project ant-ivy by apache.

the class ChainResolverTest method setUp.

@Before
public void setUp() {
    settings = new IvySettings();
    engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings));
    TestHelper.createCache();
    data = new ResolveData(engine, new ResolveOptions());
    settings.setDefaultCache(TestHelper.cache);
}
Also used : ResolveEngine(org.apache.ivy.core.resolve.ResolveEngine) SortEngine(org.apache.ivy.core.sort.SortEngine) ResolveData(org.apache.ivy.core.resolve.ResolveData) EventManager(org.apache.ivy.core.event.EventManager) IvySettings(org.apache.ivy.core.settings.IvySettings) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) Before(org.junit.Before)

Example 15 with EventManager

use of org.apache.ivy.core.event.EventManager in project ant-ivy by apache.

the class DualResolverTest method setUp.

@Before
public void setUp() {
    settings = new IvySettings();
    engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings));
    cache = new File("build/cache");
    data = new ResolveData(engine, new ResolveOptions());
    cache.mkdirs();
    settings.setDefaultCache(cache);
}
Also used : ResolveEngine(org.apache.ivy.core.resolve.ResolveEngine) SortEngine(org.apache.ivy.core.sort.SortEngine) ResolveData(org.apache.ivy.core.resolve.ResolveData) EventManager(org.apache.ivy.core.event.EventManager) IvySettings(org.apache.ivy.core.settings.IvySettings) File(java.io.File) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) Before(org.junit.Before)

Aggregations

EventManager (org.apache.ivy.core.event.EventManager)19 ResolveEngine (org.apache.ivy.core.resolve.ResolveEngine)15 IvySettings (org.apache.ivy.core.settings.IvySettings)15 SortEngine (org.apache.ivy.core.sort.SortEngine)14 ResolveData (org.apache.ivy.core.resolve.ResolveData)13 ResolveOptions (org.apache.ivy.core.resolve.ResolveOptions)12 Before (org.junit.Before)12 File (java.io.File)7 IOException (java.io.IOException)2 CacheResourceOptions (org.apache.ivy.core.cache.CacheResourceOptions)2 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)2 SearchEngine (org.apache.ivy.core.search.SearchEngine)2 Resource (org.apache.ivy.plugins.repository.Resource)2 URLResource (org.apache.ivy.plugins.repository.url.URLResource)2 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 TestFixture (org.apache.ivy.TestFixture)1 IvyAntSettings (org.apache.ivy.ant.IvyAntSettings)1