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 3, 2023
1 parent ca5b976 commit 42348ed
Show file tree
Hide file tree
Showing 25 changed files with 216 additions and 199 deletions.
6 changes: 3 additions & 3 deletions p2-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.director</artifactId>
<version>2.6.100</version>
<version>2.6.200-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
Expand All @@ -52,7 +52,7 @@
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.metadata</artifactId>
<version>2.7.100</version>
<version>2.8.0-SNAPSHOT</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-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
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
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@
<clean-plugin.version>3.3.2</clean-plugin.version>
<surefire-plugin.version>${surefire-version}</surefire-plugin.version>
</properties>
<repositories>
<repository>
<id>Eclipse-SNAPSHOTS</id>
<url>https://repo.eclipse.org/content/repositories/eclipse-snapshots</url>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
Expand Down Expand Up @@ -297,7 +303,7 @@
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.repository</artifactId>
<version>2.7.100</version>
<version>2.8.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
Expand Down
2 changes: 1 addition & 1 deletion tycho-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.metadata</artifactId>
<version>2.7.100</version>
<version>2.8.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
Expand Down
4 changes: 2 additions & 2 deletions tycho-build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.p2.metadata</artifactId>
<version>2.7.100</version>
<version>2.8.0-SNAPSHOT</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-SNAPSHOT</version>
</dependency>


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 @@ -124,6 +124,7 @@ private static void addRootFeatures(ExpandedProduct product, List<DependencySeed
}
}

//TODO: Remove this anonymous extension once https://github.com/eclipse-equinox/p2/pull/353 is available
private static IProductDescriptor loadProductFile(File productFile) throws IllegalArgumentException {
try {
return new ProductFile(productFile.getAbsolutePath());
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.director.QueryableArray;
import org.eclipse.equinox.internal.p2.metadata.RequiredCapability;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
Expand All @@ -30,7 +31,6 @@
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.tycho.core.shared.MavenLogger;
import org.eclipse.tycho.p2.publisher.FeatureDependenciesAction;
import org.eclipse.tycho.p2.repository.QueryableCollection;

public class DependencyCollector extends AbstractResolutionStrategy {

Expand All @@ -51,7 +51,7 @@ public Collection<IInstallableUnit> resolve(Map<String, String> properties, IPro

result.addAll(data.getRootIUs());

QueryableCollection availableUIsQueryable = new QueryableCollection(data.getAvailableIUs());
IQueryable<IInstallableUnit> availableUIsQueryable = new QueryableArray(data.getAvailableIUs());
for (IInstallableUnit iu : data.getRootIUs()) {
collectIncludedIUs(availableUIsQueryable, result, errors, iu, true, monitor);
}
Expand Down
Loading

0 comments on commit 42348ed

Please sign in to comment.