Search in sources :

Example 56 with IInstallableUnit

use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project tycho by eclipse.

the class AbstractSiteDependenciesAction method getRequirement.

// This is roughly inspired from org.eclipse.equinox.internal.p2.updatesite.SiteXMLAction
private IRequirement getRequirement(SiteIU iu) {
    String id = iu.getID();
    String range = iu.getRange();
    String type = iu.getQueryType();
    String expression = iu.getQueryExpression();
    String[] params = iu.getQueryParams();
    if (id != null) {
        VersionRange vRange = new VersionRange(range);
        return MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, id, vRange, null, false, false);
    } else if ("match".equals(type)) {
        IMatchExpression<IInstallableUnit> iuMatcher = ExpressionUtil.getFactory().<IInstallableUnit>matchExpression(ExpressionUtil.parse(expression), params);
        return MetadataFactory.createRequirement(iuMatcher, null, 0, 1, true);
    } else if ("context".equals(type)) {
        throw new IllegalStateException("Context iu queries are not supported in Tycho. Faulty expression is " + expression);
    }
    return null;
}
Also used : VersionRange(org.eclipse.equinox.p2.metadata.VersionRange) IMatchExpression(org.eclipse.equinox.p2.metadata.expression.IMatchExpression)

Example 57 with IInstallableUnit

use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project tycho by eclipse.

the class P2ResolverImpl method resolveMetadata.

@Override
public P2ResolutionResult resolveMetadata(TargetPlatformConfigurationStub tpConfiguration, String eeName) {
    P2TargetPlatform contextImpl = targetPlatformFactory.createTargetPlatform(tpConfiguration, new ExecutionEnvironmentConfigurationStub(eeName), null, null);
    ResolutionDataImpl data = new ResolutionDataImpl(contextImpl.getEEResolutionHints());
    data.setAvailableIUs(contextImpl.getInstallableUnits());
    data.setRootIUs(new HashSet<IInstallableUnit>());
    data.setAdditionalRequirements(additionalRequirements);
    ProjectorResolutionStrategy strategy = new ProjectorResolutionStrategy(logger);
    strategy.setData(data);
    MetadataOnlyP2ResolutionResult result = new MetadataOnlyP2ResolutionResult();
    try {
        for (IInstallableUnit iu : strategy.multiPlatformResolve(environments, monitor)) {
            result.addArtifact(ArtifactType.TYPE_INSTALLABLE_UNIT, iu.getId(), iu.getVersion().toString(), iu);
        }
    } catch (ResolverException e) {
        logger.error("Resolution failed:");
        new MultiLineLogger(logger).error(e.getDetails(), "  ");
        throw new RuntimeException(e);
    }
    return result;
}
Also used : ExecutionEnvironmentConfigurationStub(org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfigurationStub) ResolverException(org.eclipse.tycho.p2.util.resolution.ResolverException) ResolutionDataImpl(org.eclipse.tycho.p2.util.resolution.ResolutionDataImpl) P2TargetPlatform(org.eclipse.tycho.p2.target.P2TargetPlatform) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) ProjectorResolutionStrategy(org.eclipse.tycho.p2.util.resolution.ProjectorResolutionStrategy) MultiLineLogger(org.eclipse.tycho.core.shared.MultiLineLogger)

Example 58 with IInstallableUnit

use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project tycho by eclipse.

the class P2ResolverImpl method getTargetPlatformAsResolutionResult.

// TODO 412416 make this obsolete by adding appropriate getters in TargetPlatform interface
@Override
public P2ResolutionResult getTargetPlatformAsResolutionResult(TargetPlatformConfigurationStub tpConfiguration, String eeName) {
    P2TargetPlatform targetPlatform = targetPlatformFactory.createTargetPlatform(tpConfiguration, new ExecutionEnvironmentConfigurationStub(eeName), null, null);
    MetadataOnlyP2ResolutionResult result = new MetadataOnlyP2ResolutionResult();
    for (IInstallableUnit iu : targetPlatform.getInstallableUnits()) {
        result.addArtifact(ArtifactType.TYPE_INSTALLABLE_UNIT, iu.getId(), iu.getVersion().toString(), iu);
    }
    return result;
}
Also used : ExecutionEnvironmentConfigurationStub(org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfigurationStub) P2TargetPlatform(org.eclipse.tycho.p2.target.P2TargetPlatform) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 59 with IInstallableUnit

use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project tycho by eclipse.

the class P2ResolverImpl method resolveDependencies.

@SuppressWarnings("unchecked")
protected P2ResolutionResult resolveDependencies(ReactorProject project, AbstractResolutionStrategy strategy, TargetEnvironment environment) {
    ResolutionDataImpl data = new ResolutionDataImpl(context.getEEResolutionHints());
    Set<IInstallableUnit> availableUnits = context.getInstallableUnits();
    if (project != null) {
        data.setRootIUs((Set<IInstallableUnit>) project.getDependencyMetadata(true));
        Collection<IInstallableUnit> projectSecondaryIUs = (Collection<IInstallableUnit>) project.getDependencyMetadata(false);
        if (!projectSecondaryIUs.isEmpty()) {
            availableUnits = new LinkedHashSet<>(availableUnits);
            availableUnits.addAll(projectSecondaryIUs);
        }
    } else {
        data.setRootIUs(Collections.<IInstallableUnit>emptySet());
    }
    data.setAdditionalRequirements(additionalRequirements);
    data.setAvailableIUs(availableUnits);
    data.setAdditionalFilterProperties(additionalFilterProperties);
    strategy.setData(data);
    Collection<IInstallableUnit> newState;
    try {
        newState = strategy.resolve(environment, monitor);
    } catch (ResolverException e) {
        logger.info(e.getSelectionContext());
        logger.error("Cannot resolve project dependencies:");
        new MultiLineLogger(logger).error(e.getDetails(), "  ");
        logger.error("");
        logger.error("See http://wiki.eclipse.org/Tycho/Dependency_Resolution_Troubleshooting for help.");
        throw new DependencyResolutionException("Cannot resolve dependencies of " + project, e);
    }
    if (usedTargetPlatformUnits != null) {
        usedTargetPlatformUnits.addAll(newState);
    }
    return toResolutionResult(newState, project);
}
Also used : ResolverException(org.eclipse.tycho.p2.util.resolution.ResolverException) ResolutionDataImpl(org.eclipse.tycho.p2.util.resolution.ResolutionDataImpl) Collection(java.util.Collection) QueryableCollection(org.eclipse.tycho.repository.p2base.metadata.QueryableCollection) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) DependencyResolutionException(org.eclipse.tycho.artifacts.DependencyResolutionException) MultiLineLogger(org.eclipse.tycho.core.shared.MultiLineLogger)

Example 60 with IInstallableUnit

use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project tycho by eclipse.

the class DuplicateReactorIUsException method toString.

private static String toString(Map<IInstallableUnit, Set<File>> duplicateReactorUIs) {
    StringBuilder sb = new StringBuilder("Duplicate reactor project IUs.\n");
    for (Map.Entry<IInstallableUnit, Set<File>> entry : duplicateReactorUIs.entrySet()) {
        IInstallableUnit iu = entry.getKey();
        Set<File> locations = entry.getValue();
        sb.append(iu.toString()).append(" => [");
        for (Iterator<File> locationIter = locations.iterator(); locationIter.hasNext(); ) {
            File location = locationIter.next();
            sb.append(location.getAbsolutePath());
            if (locationIter.hasNext()) {
                sb.append(", ");
            }
        }
        sb.append("]\n");
    }
    return sb.toString();
}
Also used : Set(java.util.Set) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Map(java.util.Map) File(java.io.File)

Aggregations

IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)153 Test (org.junit.Test)58 ArrayList (java.util.ArrayList)44 File (java.io.File)38 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)25 HashSet (java.util.HashSet)18 IStatus (org.eclipse.core.runtime.IStatus)18 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)16 IMetadataRepository (org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)15 HashMap (java.util.HashMap)13 LinkedHashSet (java.util.LinkedHashSet)11 CoreException (org.eclipse.core.runtime.CoreException)11 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)11 ResourceUtil.resourceFile (org.eclipse.tycho.p2.tools.test.util.ResourceUtil.resourceFile)11 URI (java.net.URI)10 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)9 SubMonitor (org.eclipse.core.runtime.SubMonitor)9 ArtifactMock (org.eclipse.tycho.p2.impl.test.ArtifactMock)9 Status (org.eclipse.core.runtime.Status)8 IRequiredCapability (org.eclipse.equinox.internal.p2.metadata.IRequiredCapability)8