Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backport] Fail on missing plugin product requirement #3395

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected Set<IRequirement> getRequiredCapabilities() {
}
if (type == ProductContentType.BUNDLES || type == ProductContentType.MIXED) {
for (FeatureEntry plugin : ((ProductFile) product).getProductEntries()) {
addRequiredCapability(required, plugin.getId(), Version.parseVersion(plugin.getVersion()), null, true);
addRequiredCapability(required, plugin.getId(), Version.parseVersion(plugin.getVersion()), null, false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,45 @@
public class TargetPlatformConfigurationMojo extends AbstractMojo {

/**
* <p>
* Target environments (os/ws/arch) to consider.
* </p>
* Example:
*
* <pre>
*&lt;environments&gt;
* &lt;environment&gt;
* &lt;os&gt;linux&lt;/os&gt;
* &lt;ws&gt;gtk&lt;/ws&gt;
* &lt;arch&gt;x86_64&lt;/arch&gt;
* &lt;/environment&gt;
* &lt;environment&gt;
* &lt;os&gt;linux&lt;/os&gt;
* &lt;ws&gt;gtk&lt;/ws&gt;
* &lt;arch&gt;ppc64le&lt;/arch&gt;
* &lt;/environment&gt;
* &lt;environment&gt;
* &lt;os&gt;linux&lt;/os&gt;
* &lt;ws&gt;gtk&lt;/ws&gt;
* &lt;arch&gt;aarch64&lt;/arch&gt;
* &lt;/environment&gt;
* &lt;environment&gt;
* &lt;os&gt;win32&lt;/os&gt;
* &lt;ws&gt;win32&lt;/ws&gt;
* &lt;arch&gt;x86_64&lt;/arch&gt;
* &lt;/environment&gt;
* &lt;environment&gt;
* &lt;os&gt;macosx&lt;/os&gt;
* &lt;ws&gt;cocoa&lt;/ws&gt;
* &lt;arch&gt;x86_64&lt;/arch&gt;
* &lt;/environment&gt;
* &lt;environment&gt;
* &lt;os&gt;macosx&lt;/os&gt;
* &lt;ws&gt;cocoa&lt;/ws&gt;
* &lt;arch&gt;aarch64&lt;/arch&gt;
* &lt;/environment&gt;
*&lt;/environments&gt;
* </pre>
*/
@Parameter(name = DefaultTargetPlatformConfigurationReader.ENVIRONMENTS)
private TargetEnvironment[] environments;
Expand Down Expand Up @@ -208,8 +246,9 @@ public class TargetPlatformConfigurationMojo extends AbstractMojo {
private IncludeSourceMode targetDefinionIncludeSource;

/**
* Configures if referenced repositories should be included when fetching repositories.
* The default is <code>ignore</code>. To specify to use referenced repositories, pass <code>include</code>.
* Configures if referenced repositories should be included when fetching repositories. The
* default is <code>ignore</code>. To specify to use referenced repositories, pass
* <code>include</code>.
*/
@Parameter(name = DefaultTargetPlatformConfigurationReader.REFERENCED_REPOSITORY_MODE)
private ReferencedRepositoryMode referencedRepositoryMode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void beforeProjectLifecycleExecution(ProjectExecutionEvent event) throws
+ " with context " + resolverException.getSelectionContext()
+ System.lineSeparator() + resolverException.explanations()
.map(exp -> " " + exp.toString()).collect(Collectors.joining("\n")),
null, mavenProject);
null, mavenProject, resolverException);
}
}
TychoProject tychoProject = projectManager.getTychoProject(mavenProject).orElse(null);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
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;
import org.eclipse.equinox.internal.p2.metadata.RequiredPropertiesMatch;
Expand All @@ -48,6 +47,7 @@
import org.eclipse.tycho.core.shared.MavenLogger;
import org.eclipse.tycho.core.shared.StatusTool;
import org.eclipse.tycho.p2.resolver.ResolverException;
import org.eclipse.tycho.p2tools.copiedfromp2.Slicer;

abstract class AbstractSlicerResolutionStrategy extends AbstractResolutionStrategy {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@
import org.eclipse.tycho.p2.publisher.DownloadStatsAdvice;
import org.eclipse.tycho.p2.publisher.FeatureDependenciesAction;
import org.eclipse.tycho.p2.publisher.P2Artifact;
import org.eclipse.tycho.p2.publisher.ProductDependenciesAction;
import org.eclipse.tycho.p2.publisher.TransientArtifactRepository;
import org.eclipse.tycho.p2.publisher.rootfiles.FeatureRootAdvice;
import org.eclipse.tycho.p2.repository.ArtifactsIO;
import org.eclipse.tycho.p2.repository.MetadataIO;
import org.eclipse.tycho.p2maven.actions.CategoryDependenciesAction;
import org.eclipse.tycho.p2maven.actions.ProductDependenciesAction;
import org.eclipse.tycho.p2maven.actions.ProductFile2;
import org.osgi.framework.BundleException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.apache.felix.resolver.util.CopyOnWriteSet;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.internal.p2.director.QueryableArray;
import org.eclipse.equinox.internal.p2.director.Slicer;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IProvidedCapability;
Expand Down Expand Up @@ -76,6 +75,7 @@
import org.eclipse.tycho.p2.resolver.ResolverException;
import org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub;
import org.eclipse.tycho.p2.target.facade.TargetPlatformFactory;
import org.eclipse.tycho.p2tools.copiedfromp2.Slicer;
import org.eclipse.tycho.targetplatform.P2TargetPlatform;

public class P2ResolverImpl implements P2Resolver {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,25 @@
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.director.Explanation;
import org.eclipse.equinox.internal.p2.director.Projector;
import org.eclipse.equinox.internal.p2.director.QueryableArray;
import org.eclipse.equinox.internal.p2.director.SimplePlanner;
import org.eclipse.equinox.internal.p2.director.Slicer;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IRequirement;
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.query.QueryUtil;
import org.eclipse.tycho.core.shared.MavenLogger;
import org.eclipse.tycho.core.shared.StatusTool;
import org.eclipse.tycho.p2.resolver.ResolverException;
import org.eclipse.tycho.p2tools.copiedfromp2.Projector;
import org.eclipse.tycho.p2tools.copiedfromp2.Slicer;

public class ProjectorResolutionStrategy extends AbstractSlicerResolutionStrategy {

Expand Down Expand Up @@ -79,9 +81,32 @@ public Collection<IInstallableUnit> resolve(Map<String, String> properties, IPro
// force profile UIs to be used during resolution
seedUnits.addAll(data.getEEResolutionHints().getMandatoryUnits());
seedRequires.addAll(data.getEEResolutionHints().getMandatoryRequires());

Projector projector = new Projector(slice(properties, generatedUnits, monitor), selectionContext,
new HashSet<>(), false);
new HashSet<>(), false) {
IQueryable<IInstallableUnit> units;

@Override
protected Collection<IRequirement> getRequiredCapabilities(IInstallableUnit iu) {
Collection<IRequirement> requiredCapabilities = super.getRequiredCapabilities(iu);
if (QueryUtil.isProduct(iu)) {
if (units == null) {
units = data.units();
}
return requiredCapabilities.stream().filter(requirement -> {
IQuery<IInstallableUnit> query = QueryUtil.createMatchQuery(requirement.getMatches());
IQueryResult<IInstallableUnit> result = units.query(query, null);
if (result.isEmpty()) {
//this must fail the resolve so we need to include the requirement
return true;
}
//If none of the results are applicable this means they are filtered and need not to be considered
//this happens in plugin based products that include native fragments from different platforms
return result.stream().anyMatch(matchIu -> isApplicable(matchIu));
}).toList();
}
return requiredCapabilities;
}
};
projector.encode(createUnitRequiring("tycho", seedUnits, seedRequires),
EMPTY_IU_ARRAY /* alreadyExistingRoots */,
new QueryableArray(List.of()) /* installedIUs */, seedUnits /* newRoots */, monitor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@

import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IRequirement;
import org.eclipse.equinox.p2.query.CollectionResult;
import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.tycho.ExecutionEnvironmentResolutionHints;
import org.eclipse.tycho.p2maven.ListQueryable;

public interface ResolutionData {

Expand All @@ -42,4 +44,14 @@ public interface ResolutionData {
Predicate<IInstallableUnit> getIInstallableUnitAcceptor();

IQueryable<IInstallableUnit> getAdditionalUnitStore();

default IQueryable<IInstallableUnit> units() {
ListQueryable<IInstallableUnit> listQueryable = new ListQueryable<>();
listQueryable.add(new CollectionResult<>(getAvailableIUs()));
IQueryable<IInstallableUnit> unitStore = getAdditionalUnitStore();
if (unitStore != null) {
listQueryable.add(unitStore);
}
return listQueryable;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.equinox.internal.p2.director.PermissiveSlicer;
import org.eclipse.equinox.internal.p2.director.Slicer;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.tycho.TargetEnvironment;
import org.eclipse.tycho.core.shared.MavenLogger;
import org.eclipse.tycho.p2.resolver.ResolverException;
import org.eclipse.tycho.p2tools.copiedfromp2.PermissiveSlicer;
import org.eclipse.tycho.p2tools.copiedfromp2.Slicer;

public class SlicerResolutionStrategy extends AbstractSlicerResolutionStrategy {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*******************************************************************************
* Copyright (c) 2006, 2017 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.tycho.p2tools.copiedfromp2;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ProgressMonitorWrapper;

/**
* This class provides a simulation of progress. This is useful for situations where computing the
* amount of work to do in advance is too costly. The monitor will accept any number of calls to
* {@link #worked(int)}, and will scale the actual reported work appropriately so that the progress
* never quite completes.
*/
class InfiniteProgress extends ProgressMonitorWrapper {
/*
* Fields for progress monitoring algorithm. Initially, give progress for every 4 resources,
* double this value at halfway point, then reset halfway point to be half of remaining work.
* (this gives an infinite series that converges at total work after an infinite number of
* resources).
*/
private int totalWork;
private int currentIncrement = 4;
private int halfWay;
private int nextProgress = currentIncrement;
private int worked = 0;

protected InfiniteProgress(IProgressMonitor monitor) {
super(monitor);
}

@Override
public void beginTask(String name, int work) {
super.beginTask(name, work);
this.totalWork = work;
this.halfWay = totalWork / 2;
}

@Override
public void worked(int work) {
if (--nextProgress <= 0) {
//we have exhausted the current increment, so report progress
super.worked(1);
worked++;
if (worked >= halfWay) {
//we have passed the current halfway point, so double the
//increment and reset the halfway point.
currentIncrement *= 2;
halfWay += (totalWork - halfWay) / 2;
}
//reset the progress counter to another full increment
nextProgress = currentIncrement;
}
}

}
Loading
Loading