diff --git a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/actions/ProductDependenciesAction.java b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/actions/ProductDependenciesAction.java index 3058dbc170..dbdf4e85eb 100644 --- a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/actions/ProductDependenciesAction.java +++ b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/actions/ProductDependenciesAction.java @@ -61,7 +61,7 @@ protected Set 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); } } diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/TychoProjectExecutionListener.java b/tycho-core/src/main/java/org/eclipse/tycho/core/maven/TychoProjectExecutionListener.java index bc0b33fbd2..48a3c39aed 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/TychoProjectExecutionListener.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/maven/TychoProjectExecutionListener.java @@ -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); diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/ProjectorResolutionStrategy.java b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/ProjectorResolutionStrategy.java index b731c55662..8bc48e5be9 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/ProjectorResolutionStrategy.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/ProjectorResolutionStrategy.java @@ -27,15 +27,18 @@ 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.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 { @@ -78,9 +81,32 @@ public Collection resolve(Map 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 units; + + @Override + protected Collection getRequiredCapabilities(IInstallableUnit iu) { + Collection requiredCapabilities = super.getRequiredCapabilities(iu); + if (QueryUtil.isProduct(iu)) { + if (units == null) { + units = data.units(); + } + return requiredCapabilities.stream().filter(requirement -> { + IQuery query = QueryUtil.createMatchQuery(requirement.getMatches()); + IQueryResult 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); diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/ResolutionData.java b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/ResolutionData.java index dfb308b19a..c08738713d 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/ResolutionData.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/ResolutionData.java @@ -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 { @@ -42,4 +44,14 @@ public interface ResolutionData { Predicate getIInstallableUnitAcceptor(); IQueryable getAdditionalUnitStore(); + + default IQueryable units() { + ListQueryable listQueryable = new ListQueryable<>(); + listQueryable.add(new CollectionResult<>(getAvailableIUs())); + IQueryable unitStore = getAdditionalUnitStore(); + if (unitStore != null) { + listQueryable.add(unitStore); + } + return listQueryable; + } } diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2tools/copiedfromp2/Projector.java b/tycho-core/src/main/java/org/eclipse/tycho/p2tools/copiedfromp2/Projector.java index f87d606149..7a642c20a1 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2tools/copiedfromp2/Projector.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2tools/copiedfromp2/Projector.java @@ -379,12 +379,12 @@ private void createNegation(IInstallableUnit iu, IRequirement req) throws Contra } // Check whether the requirement is applicable - private boolean isApplicable(IRequirement req) { + protected boolean isApplicable(IRequirement req) { IMatchExpression filter = req.getFilter(); return filter == null || filter.isMatch(selectionContext); } - private boolean isApplicable(IInstallableUnit iu) { + protected boolean isApplicable(IInstallableUnit iu) { IMatchExpression filter = iu.getFilter(); return filter == null || filter.isMatch(selectionContext); } @@ -536,7 +536,7 @@ public void processIU(IInstallableUnit iu, boolean isRootIU) throws Contradictio } } - private Collection getRequiredCapabilities(IInstallableUnit iu) { + protected Collection getRequiredCapabilities(IInstallableUnit iu) { boolean isFragment = iu instanceof IInstallableUnitFragment; //Short-circuit for the case of an IInstallableUnit if ((!isFragment) && iu.getMetaRequirements().size() == 0) diff --git a/tycho-core/src/test/java/org/eclipse/tycho/test/util/InstallableUnitUtil.java b/tycho-core/src/test/java/org/eclipse/tycho/test/util/InstallableUnitUtil.java index c20baadc87..9236e3837b 100644 --- a/tycho-core/src/test/java/org/eclipse/tycho/test/util/InstallableUnitUtil.java +++ b/tycho-core/src/test/java/org/eclipse/tycho/test/util/InstallableUnitUtil.java @@ -26,13 +26,14 @@ import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription; import org.eclipse.equinox.p2.metadata.Version; import org.eclipse.equinox.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; public class InstallableUnitUtil { - static final String IU_CAPABILITY_NS = "org.eclipse.equinox.p2.iu"; // see IInstallableUnit.NAMESPACE_IU_ID; - static final String BUNDLE_CAPABILITY_NS = "osgi.bundle"; // see BundlesAction.CAPABILITY_NS_OSGI_BUNDLE - static final String PRODUCT_TYPE_PROPERTY = "org.eclipse.equinox.p2.type.product"; // see InstallableUnitDescription.PROP_TYPE_PRODUCT; - static final String FEATURE_TYPE_PROPERTY = "org.eclipse.equinox.p2.type.group"; // see InstallableUnitDescription.PROP_TYPE_GROUP; + static final String IU_CAPABILITY_NS = IInstallableUnit.NAMESPACE_IU_ID; + static final String BUNDLE_CAPABILITY_NS = BundlesAction.CAPABILITY_NS_OSGI_BUNDLE; + static final String PRODUCT_TYPE_PROPERTY = InstallableUnitDescription.PROP_TYPE_PRODUCT; + static final String FEATURE_TYPE_PROPERTY = InstallableUnitDescription.PROP_TYPE_GROUP; public static String DEFAULT_VERSION = "0.0.20"; diff --git a/tycho-its/projects/tycho-p2-director-plugin/product-with-native-fragments/pom.xml b/tycho-its/projects/tycho-p2-director-plugin/product-with-native-fragments/pom.xml index f83bff9ad6..2f166e6e25 100644 --- a/tycho-its/projects/tycho-p2-director-plugin/product-with-native-fragments/pom.xml +++ b/tycho-its/projects/tycho-p2-director-plugin/product-with-native-fragments/pom.xml @@ -40,13 +40,6 @@ target-platform-configuration ${tycho-version} - - - org.eclipse - eclipse-sdk-prereqs - 4.31.0-SNAPSHOT - - linux