Skip to content

Commit

Permalink
Adapt to P2 enhancements in Eclipse 2023-12
Browse files Browse the repository at this point in the history
And add tests for support of Product Update-site names from the
tycho-4.0.x branch.
  • Loading branch information
HannesWell committed Dec 9, 2023
1 parent 23bbf9f commit b5e1228
Show file tree
Hide file tree
Showing 23 changed files with 214 additions and 210 deletions.
16 changes: 8 additions & 8 deletions p2-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.publisher</artifactId>
<version>1.8.100</version>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.director</artifactId>
<version>2.6.100</version>
<version>2.6.200</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.engine</artifactId>
<version>2.8.100</version>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.metadata</artifactId>
<version>2.7.100</version>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
Expand All @@ -66,7 +66,7 @@
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.publisher.eclipse</artifactId>
<version>1.5.100</version>
<version>1.5.200</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
Expand Down Expand Up @@ -97,12 +97,12 @@
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.metadata.repository</artifactId>
<version>1.5.100</version>
<version>1.5.200</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.updatesite</artifactId>
<version>1.3.100</version>
<version>1.3.200</version>
</dependency>
<!-- used API packages from Tycho -->
<dependency>
Expand Down Expand Up @@ -149,7 +149,7 @@
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.repository.tools</artifactId>
<version>2.4.100</version>
<version>2.4.200</version>
</dependency>
<!-- Equinox -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public IQueryResult<IInstallableUnit> computeDependencies(Collection<IInstallabl
IQueryable<IInstallableUnit> avaiableIUs) throws CoreException {
NullProgressMonitor monitor = new NullProgressMonitor();
PermissiveSlicer slicer = new TychoSlicer(avaiableIUs);
IQueryable<IInstallableUnit> slice = slicer.slice(rootIus.toArray(IInstallableUnit[]::new), monitor);
IQueryable<IInstallableUnit> slice = slicer.slice(rootIus, monitor);
IStatus sliceStatus = slicer.getStatus();
if (sliceStatus.matches(IStatus.ERROR)) {
throw new CoreException(sliceStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public Iterator<R> iterator() {
return stream().iterator();
}

private Stream<R> stream() {
@Override
public Stream<R> stream() {
return resultList.stream().flatMap(r -> StreamSupport
.stream(Spliterators.spliteratorUnknownSize(r.iterator(), Spliterator.ORDERED), false));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,7 @@ protected void processPlugin(Attributes attributes) {
if (os != null || ws != null || arch != null) {
entry.setEnvironment(os, ws, arch, null);
}

if (isFragment) {
fragments.add(entry);
} else {
plugins.add(entry);
}
plugins.add(entry);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.repository</artifactId>
<version>2.7.100</version>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
Expand Down
4 changes: 2 additions & 2 deletions tycho-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.metadata</artifactId>
<version>2.7.100</version>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.publisher</artifactId>
<version>1.8.100</version>
<version>1.9.0</version>
</dependency>
</dependencies>
<build>
Expand Down
12 changes: 6 additions & 6 deletions tycho-build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,26 @@
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.publisher</artifactId>
<version>1.8.100</version>
<version>1.9.0</version>
</dependency>

<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.director</artifactId>
<version>2.6.100</version>
<version>2.6.200</version>
</dependency>

<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.engine</artifactId>
<version>2.8.100</version>
<version>2.9.0</version>
</dependency>


<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.metadata</artifactId>
<version>2.7.100</version>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
Expand All @@ -95,7 +95,7 @@
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.publisher.eclipse</artifactId>
<version>1.5.100</version>
<version>1.5.200</version>
</dependency>


Expand Down Expand Up @@ -124,7 +124,7 @@
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.metadata.repository</artifactId>
<version>1.5.100</version>
<version>1.5.200</version>
</dependency>
<dependency>
<groupId>org.eclipse.tycho</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public void addReferences(Collection<? extends IRepositoryReference> references)
// not supported
}

@Override
public boolean removeReferences(Collection<? extends IRepositoryReference> references) {
// not supported
return false;
}

@Override
public Collection<IRepositoryReference> getReferences() {
// not supported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,23 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.director.QueryableArray;
import org.eclipse.equinox.p2.core.IPool;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.repository.IRepositoryReference;
import org.eclipse.equinox.p2.repository.IRunnableWithProgress;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;

public class ImmutableInMemoryMetadataRepository implements IMetadataRepository {

private final QueryableCollection units;
private final IQueryable<IInstallableUnit> units;

public ImmutableInMemoryMetadataRepository(Set<IInstallableUnit> units) {
this.units = new QueryableCollection(units);
this.units = new QueryableArray(units);
}

@Override
Expand Down Expand Up @@ -142,6 +144,11 @@ public void addReferences(Collection<? extends IRepositoryReference> references)
throw new UnsupportedOperationException();
}

@Override
public boolean removeReferences(Collection<? extends IRepositoryReference> references) {
throw new UnsupportedOperationException();
}

@Override
public boolean removeInstallableUnits(Collection<IInstallableUnit> installableUnits) {
throw new UnsupportedOperationException();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,16 @@ public String getVersion() {
}

@Override
public List<IVersionedId> getBundles(boolean includeFragments) {
if (includeFragments == false) {
// currently not needed -> omitted for simplicity
throw new UnsupportedOperationException();
}
public List<IVersionedId> getBundles() {
if (getProductContentType() == ProductContentType.FEATURES) {
// don't expand versions if bundles are not included in the product
// TODO why is this method called anyway?
return defaults.getBundles(includeFragments);
return defaults.getBundles();
}

return expandedBundles;
}

@Override
public List<IVersionedId> getFragments() {
// currently not needed -> omitted for simplicity
throw new UnsupportedOperationException();
}

@Override
public List<IVersionedId> getFeatures() {
return getFeatures(INCLUDED_FEATURES);
Expand All @@ -111,7 +101,7 @@ private void expandVersions() {
ProductVersionExpansionRun resolver = new ProductVersionExpansionRun(targetPlatform, getLocation());
if (contentType != ProductContentType.FEATURES) {
expandedBundles = resolver.resolveReferences("plugin", ArtifactType.TYPE_ECLIPSE_PLUGIN,
defaults.getBundles(true));
defaults.getBundles());
}
if (contentType != ProductContentType.BUNDLES) {
expandedFeatures = resolver.resolveReferences("feature", ArtifactType.TYPE_ECLIPSE_FEATURE,
Expand Down Expand Up @@ -143,9 +133,9 @@ private Map<String, String> expandVariables(Map<String, String> originalMap) {
// delegating methods

@Override
public boolean hasBundles(boolean includeFragments) {
public boolean hasBundles() {
// don't need to expand versions for this check
return defaults.hasBundles(includeFragments);
return defaults.hasBundles();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.equinox.internal.p2.director.QueryableArray;
import org.eclipse.equinox.internal.p2.director.Slicer;
import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.p2.metadata.RequiredCapability;
Expand All @@ -42,12 +43,10 @@
import org.eclipse.equinox.p2.metadata.expression.IExpression;
import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
import org.eclipse.equinox.p2.publisher.actions.JREAction;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.tycho.core.shared.MavenLogger;
import org.eclipse.tycho.core.shared.StatusTool;
import org.eclipse.tycho.p2.repository.QueryableCollection;
import org.eclipse.tycho.p2.resolver.ResolverException;

abstract class AbstractSlicerResolutionStrategy extends AbstractResolutionStrategy {
Expand Down Expand Up @@ -95,23 +94,19 @@ protected final IQueryable<IInstallableUnit> slice(Map<String, String> propertie
seedIUs.add(createUnitRequiring("tycho-ee", null, data.getEEResolutionHints().getMandatoryRequires()));
}

QueryableCollection baseIUCollection = new QueryableCollection(availableIUs);
Slicer slicer = newSlicer(new IQueryable<IInstallableUnit>() {
IQueryable<IInstallableUnit> baseIUCollection = new QueryableArray(availableIUs);
Slicer slicer = newSlicer((query, monitor1) -> {

@Override
public IQueryResult<IInstallableUnit> query(IQuery<IInstallableUnit> query, IProgressMonitor monitor) {

IQueryResult<IInstallableUnit> queryResult = baseIUCollection.query(query, monitor);
if (queryResult.isEmpty()) {
IQueryable<IInstallableUnit> additionalUnitStore = data.getAdditionalUnitStore();
if (additionalUnitStore != null) {
return additionalUnitStore.query(query, monitor);
}
IQueryResult<IInstallableUnit> queryResult = baseIUCollection.query(query, monitor1);
if (queryResult.isEmpty()) {
IQueryable<IInstallableUnit> additionalUnitStore = data.getAdditionalUnitStore();
if (additionalUnitStore != null) {
return additionalUnitStore.query(query, monitor1);
}
return queryResult;
}
return queryResult;
}, properties);
IQueryable<IInstallableUnit> slice = slicer.slice(seedIUs.toArray(EMPTY_IU_ARRAY), monitor);
IQueryable<IInstallableUnit> slice = slicer.slice(seedIUs, monitor);
MultiStatus slicerStatus = slicer.getStatus();
if (slice == null || isSlicerError(slicerStatus)) {
throw new ResolverException(StatusTool.toLogMessage(slicerStatus), properties.toString(),
Expand Down
Loading

0 comments on commit b5e1228

Please sign in to comment.