Search in sources :

Example 11 with ProvisionException

use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.

the class Activator method createProvisioningAgent.

public static IProvisioningAgent createProvisioningAgent(final URI targetLocation) throws ProvisionException {
    if (targetLocation == null)
        throw new IllegalArgumentException("Creating the default agent is not supported");
    BundleContext context = getContext();
    ServiceReference<IProvisioningAgentProvider> agentFactoryReference = context.getServiceReference(IProvisioningAgentProvider.class);
    IProvisioningAgentProvider agentFactory = context.getService(agentFactoryReference);
    try {
        return agentFactory.createAgent(targetLocation);
    } finally {
        context.ungetService(agentFactoryReference);
    }
}
Also used : IProvisioningAgentProvider(org.eclipse.equinox.p2.core.IProvisioningAgentProvider) BundleContext(org.osgi.framework.BundleContext)

Example 12 with ProvisionException

use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.

the class Activator method newProvisioningAgent.

/**
 * @deprecated This method potentially creates multiple agent instances with the default
 *             location. This leads to concurrent file system access with undefined outcome.
 */
@Deprecated
public static IProvisioningAgent newProvisioningAgent() throws ProvisionException {
    BundleContext context = getContext();
    ServiceReference<IProvisioningAgentProvider> agentFactoryReference = context.getServiceReference(IProvisioningAgentProvider.class);
    IProvisioningAgentProvider agentFactory = context.getService(agentFactoryReference);
    try {
        // null == currently running system
        return agentFactory.createAgent(null);
    } finally {
        context.ungetService(agentFactoryReference);
    }
}
Also used : IProvisioningAgentProvider(org.eclipse.equinox.p2.core.IProvisioningAgentProvider) BundleContext(org.osgi.framework.BundleContext)

Example 13 with ProvisionException

use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.

the class P2ResolverFactoryImpl method getTargetPlatformFactory.

@Override
public TargetPlatformFactoryImpl getTargetPlatformFactory() {
    try {
        // TODO don't synchronize twice
        LocalMetadataRepository localMetadataRepo = getLocalMetadataRepository(mavenContext, localRepoIndices);
        LocalArtifactRepository localArtifactRepo = getLocalArtifactRepository(mavenContext, localRepoIndices);
        return new TargetPlatformFactoryImpl(mavenContext, remoteAgentManager.getProvisioningAgent(), localArtifactRepo, localMetadataRepo, targetDefinitionResolverService);
    } catch (ProvisionException e) {
        throw new RuntimeException(e);
    }
}
Also used : LocalArtifactRepository(org.eclipse.tycho.repository.local.LocalArtifactRepository) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) LocalMetadataRepository(org.eclipse.tycho.repository.local.LocalMetadataRepository) TargetPlatformFactoryImpl(org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl)

Example 14 with ProvisionException

use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.

the class DependencyCollector method resolve.

@Override
public Collection<IInstallableUnit> resolve(Map<String, String> properties, IProgressMonitor monitor) {
    Set<IInstallableUnit> result = new LinkedHashSet<>();
    LinkedHashSet<IStatus> errors = new LinkedHashSet<>();
    if (logger.isExtendedDebugEnabled()) {
        logger.debug("Available IUs:\n" + ResolverDebugUtils.toDebugString(data.getAvailableIUs(), false));
        logger.debug("Root IUs:\n" + ResolverDebugUtils.toDebugString(data.getRootIUs(), true));
    }
    result.addAll(data.getRootIUs());
    QueryableCollection availableUIsQueryable = new QueryableCollection(data.getAvailableIUs());
    for (IInstallableUnit iu : data.getRootIUs()) {
        collectIncludedIUs(availableUIsQueryable, result, errors, iu, true, monitor);
    }
    if (logger.isExtendedDebugEnabled()) {
        logger.debug("Collected IUs:\n" + ResolverDebugUtils.toDebugString(result, false));
    }
    if (!errors.isEmpty()) {
        MultiStatus status = new MultiStatus(Activator.PLUGIN_ID, 0, errors.toArray(new IStatus[errors.size()]), "Missing dependencies", null);
        throw new RuntimeException(status.toString(), new ProvisionException(status));
    }
    return result;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IStatus(org.eclipse.core.runtime.IStatus) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) QueryableCollection(org.eclipse.tycho.repository.p2base.metadata.QueryableCollection) MultiStatus(org.eclipse.core.runtime.MultiStatus) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 15 with ProvisionException

use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.

the class P2MirrorDisablingArtifactRepositoryManager method createRepository.

// disable mirrors in returned repositories
@Override
public IArtifactRepository createRepository(URI location, String name, String type, Map<String, String> properties) throws ProvisionException {
    IArtifactRepository repository = delegate.createRepository(location, name, type, properties);
    disableMirrors(repository, mavenLogger);
    return repository;
}
Also used : IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository)

Aggregations

ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)29 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)14 IStatus (org.eclipse.core.runtime.IStatus)13 IMetadataRepository (org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)10 Test (org.junit.Test)9 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)8 IArtifactRepository (org.eclipse.equinox.p2.repository.artifact.IArtifactRepository)8 IMetadataRepositoryManager (org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager)8 URI (java.net.URI)7 ArrayList (java.util.ArrayList)7 File (java.io.File)6 Status (org.eclipse.core.runtime.Status)6 IOException (java.io.IOException)5 IProvisioningAgent (org.eclipse.equinox.p2.core.IProvisioningAgent)5 IProvisioningAgentProvider (org.eclipse.equinox.p2.core.IProvisioningAgentProvider)5 OutputStream (java.io.OutputStream)4 HashSet (java.util.HashSet)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 ProvisioningSession (org.eclipse.equinox.p2.operations.ProvisioningSession)4 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)4