resolvedPlatforms;
+
/**
* List of requirements which couldn't be resolved but for which we found a solution that applied to the wrong product
*
@@ -136,6 +141,15 @@ public class RepositoryResolver {
* List of all the missing requirements we've found so far
*/
List missingRequirements;
+ /**
+ * List of all the missing platforms after resolution
+ */
+ Set missingPlatforms;
+
+ /**
+ * Indicates if an issue was found resolving versionless features and platforms
+ */
+ boolean hasVersionlessIssue;
/**
*
@@ -378,6 +392,19 @@ public Collection> resolveAsSet(Collection toRe
return resolve(toResolve, null, ResolutionMode.DETECT_CONFLICTS);
}
+ protected boolean hasRequestedVersionlessFeatures(Collection featureList, KernelResolverRepository repo) {
+ for (String s : featureList) {
+ ProvisioningFeatureDefinition feature = repo.getFeature(s);
+ if (feature == null)
+ //Can't find the feature of that name - just skip for now....
+ continue;
+ if (feature.isVersionless()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Takes a list of feature names that the user wants to install and returns a minimal set of the {@link RepositoryResource}s that should be installed to allow those features to
* start together in one server.
@@ -472,6 +499,9 @@ void initResolve() {
missingRequirements = new ArrayList<>();
resolverRepository = null;
featureConflicts = new HashMap<>();
+ resolvedPlatforms = new HashSet<>();
+ missingPlatforms = new HashSet<>();
+ hasVersionlessIssue = false;
}
/**
@@ -536,6 +566,8 @@ void resolveFeaturesAsSet() {
Result result = resolver.resolve(resolverRepository, kernelFeatures, featureNamesToResolve, Collections. emptySet(), false, requestedPlatformNames);
featureConflicts.putAll(result.getConflicts());
+ if (hasRequestedVersionlessFeatures(featureNamesToResolve, resolverRepository))
+ recordVersionless(result);
for (String name : result.getResolvedFeatures()) {
ProvisioningFeatureDefinition feature = resolverRepository.getFeature(name);
@@ -547,6 +579,21 @@ void resolveFeaturesAsSet() {
}
}
+ /**
+ * Record Versionless Messages and Issues
+ *
+ * @param result
+ * @param requestedFeatures
+ */
+ private void recordVersionless(Result result) {
+
+ resolvedPlatforms = result.getResolvedPlatforms();
+ missingPlatforms = result.getMissingPlatforms();
+ if (resolvedPlatforms.isEmpty() || !missingPlatforms.isEmpty())
+ hasVersionlessIssue = true;
+
+ }
+
/**
* Resolves {@link #featureNamesToResolve} using a simple traversal of the dependency tree
*
@@ -956,7 +1003,7 @@ private EsaResource getResource(ProvisioningFeatureDefinition feature) {
* @throws RepositoryResolutionException if any errors occurred during resolution
*/
private void reportErrors() throws RepositoryResolutionException {
- if (resourcesWrongProduct.isEmpty() && missingTopLevelRequirements.isEmpty() && missingRequirements.isEmpty() && featureConflicts.isEmpty()) {
+ if (resourcesWrongProduct.isEmpty() && missingTopLevelRequirements.isEmpty() && missingRequirements.isEmpty() && featureConflicts.isEmpty() && !hasVersionlessIssue()) {
// Everything went fine!
return;
}
@@ -987,7 +1034,19 @@ private void reportErrors() throws RepositoryResolutionException {
missingRequirementNames.add(req.getRequirementName());
}
- throw new RepositoryResolutionException(null, missingTopLevelRequirements, missingRequirementNames, missingProductInformation, missingRequirements, featureConflicts);
+ if (hasVersionlessIssue())
+ throw new RepositoryResolutionException(null, missingTopLevelRequirements, missingRequirementNames, missingProductInformation, missingRequirements, featureConflicts,
+ resolvedPlatforms, missingPlatforms);
+ else
+ throw new RepositoryResolutionException(null, missingTopLevelRequirements, missingRequirementNames, missingProductInformation, missingRequirements, featureConflicts);
+ }
+
+ /**
+ * @return
+ */
+ protected boolean hasVersionlessIssue() {
+
+ return hasVersionlessIssue;
}
static class NameAndVersion {
From b25aec3ae12a8b05ee5090331df6a87d37c4208c Mon Sep 17 00:00:00 2001
From: Chuck Bridgham
Date: Fri, 12 Jul 2024 21:33:53 -0400
Subject: [PATCH 5/8] Forwarding Result data
---
.../RepositoryResolutionException.java | 37 +++++-----
.../resolver/RepositoryResolver.java | 29 ++++++--
.../kernel/KernelResolverRepository.java | 67 +++++++++++++++++++
3 files changed, 109 insertions(+), 24 deletions(-)
diff --git a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolutionException.java b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolutionException.java
index 6ef662fc8d7..440ed0ec55c 100755
--- a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolutionException.java
+++ b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolutionException.java
@@ -15,6 +15,7 @@
import java.util.Collection;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
@@ -44,6 +45,7 @@ public class RepositoryResolutionException extends RepositoryException {
private Set resolvedPlatforms;
private Set missingPlatforms;
private boolean hasVersionlessIssue;
+ private List missingBasePlatforms;
/**
* @param cause
@@ -68,15 +70,17 @@ public RepositoryResolutionException(ResolutionException cause, Collectionnull
+ * @param allRequirementsResourcesNotFound The {@link MissingRequirement} objects that were not found. Must not be null
.
+ * @param featureConflicts the details of any feature conflicts which occurred during feature resolution, as returned from {@link Result#getConflicts()}
* @param resolvedPlatforms
- * @param missingPlatforms
+ * @param missingPlatforms Unknown platform names
+ * @param missingBasePlatforms unresolved versionless features needing platforms defined
*/
public RepositoryResolutionException(ResolutionException cause, Collection topLevelFeaturesNotResolved, Collection allRequirementsNotFound,
Collection missingProductInformation, Collection allRequirementsResourcesNotFound,
- Map> featureConflicts, Set resolvedPlatforms, Set missingPlatforms) {
+ Map> featureConflicts, Set resolvedPlatforms, Set missingPlatforms,
+ List missingBasePlatforms) {
super(cause);
this.topLevelFeaturesNotResolved = topLevelFeaturesNotResolved;
this.allRequirementsNotFound = allRequirementsNotFound;
@@ -85,7 +89,8 @@ public RepositoryResolutionException(ResolutionException cause, Collection> getFeatureConflicts() {
public String getMessage() {
StringBuilder sb = new StringBuilder();
- if (hasVersionlessIssue()) {
- if (!getMissingPlatforms().isEmpty()) {
- for (String missing : getMissingPlatforms()) {
- sb.append("Platform: ").append(missing).append(" couldn't be found, no versionless features will be resolved").append("\n");
- }
- }
- if (getResolvedPlatforms().isEmpty() && getMissingPlatforms().isEmpty()) {
- sb.append("Platform couldn't be determined, no versionless features will be resolved").append("\n");
+ if (!getMissingPlatforms().isEmpty()) {
+ for (String missing : getMissingPlatforms()) {
+ sb.append("Platform: ").append(missing).append(" couldn't be found, no versionless features will be resolved").append("\n");
}
}
+ if (getResolvedPlatforms().isEmpty() && getMissingPlatforms().isEmpty()) {
+ sb.append("Platform couldn't be determined, no versionless features will be resolved").append("\n");
+ }
for (String missing : getTopLevelFeaturesNotResolved()) {
sb.append("Top level feature not resolved: resource=").append(missing).append("\n");
@@ -384,10 +387,10 @@ public Set getMissingPlatforms() {
}
/**
- * @return the hasVersionlessIssue
+ * @return the missingBasePlatforms
*/
- public boolean hasVersionlessIssue() {
- return hasVersionlessIssue;
+ public List getMissingBasePlatforms() {
+ return missingBasePlatforms;
}
}
diff --git a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolver.java b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolver.java
index c79fabd0377..56b44028e8c 100755
--- a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolver.java
+++ b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolver.java
@@ -32,6 +32,7 @@
import com.ibm.ws.kernel.feature.provisioning.ProvisioningFeatureDefinition;
import com.ibm.ws.kernel.feature.resolver.FeatureResolver;
import com.ibm.ws.kernel.feature.resolver.FeatureResolver.Chain;
+import com.ibm.ws.kernel.feature.resolver.FeatureResolver.Repository;
import com.ibm.ws.kernel.feature.resolver.FeatureResolver.Result;
import com.ibm.ws.kernel.productinfo.ProductInfo;
import com.ibm.ws.product.utility.extension.IFixUtils;
@@ -567,7 +568,7 @@ void resolveFeaturesAsSet() {
featureConflicts.putAll(result.getConflicts());
if (hasRequestedVersionlessFeatures(featureNamesToResolve, resolverRepository))
- recordVersionless(result);
+ recordVersionless(result, resolverRepository);
for (String name : result.getResolvedFeatures()) {
ProvisioningFeatureDefinition feature = resolverRepository.getFeature(name);
@@ -583,9 +584,10 @@ void resolveFeaturesAsSet() {
* Record Versionless Messages and Issues
*
* @param result
+ * @param resolverRepo
* @param requestedFeatures
*/
- private void recordVersionless(Result result) {
+ private void recordVersionless(Result result, Repository resolverRepo) {
resolvedPlatforms = result.getResolvedPlatforms();
missingPlatforms = result.getMissingPlatforms();
@@ -1008,6 +1010,22 @@ private void reportErrors() throws RepositoryResolutionException {
return;
}
+ List missingBasePlatforms = new ArrayList();
+
+ // Versionless feature issues
+ if (!missingTopLevelRequirements.isEmpty()) {
+ for (String name : missingTopLevelRequirements) {
+ ProvisioningFeatureDefinition feature = resolverRepository.getFeature(name);
+ if (feature != null && feature.isVersionless()) {
+ ProvisioningFeatureDefinition firstChild = resolverRepository.findAllPossibleVersions(feature).get(0);
+ String plat = firstChild.getPlatformName();
+ if (plat != null && plat.indexOf("-") != -1) {
+ missingBasePlatforms.add(resolverRepository.getFeatureBaseName(plat));
+ }
+ }
+ }
+ }
+
Set missingProductInformation = new HashSet<>();
for (ApplicableToProduct esa : resourcesWrongProduct) {
@@ -1034,11 +1052,8 @@ private void reportErrors() throws RepositoryResolutionException {
missingRequirementNames.add(req.getRequirementName());
}
- if (hasVersionlessIssue())
- throw new RepositoryResolutionException(null, missingTopLevelRequirements, missingRequirementNames, missingProductInformation, missingRequirements, featureConflicts,
- resolvedPlatforms, missingPlatforms);
- else
- throw new RepositoryResolutionException(null, missingTopLevelRequirements, missingRequirementNames, missingProductInformation, missingRequirements, featureConflicts);
+ throw new RepositoryResolutionException(null, missingTopLevelRequirements, missingRequirementNames, missingProductInformation, missingRequirements, featureConflicts,
+ resolvedPlatforms, missingPlatforms, missingBasePlatforms);
}
/**
diff --git a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverRepository.java b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverRepository.java
index 911d9d42b8b..fe3fc5c78fa 100644
--- a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverRepository.java
+++ b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverRepository.java
@@ -24,7 +24,9 @@
import org.osgi.framework.Version;
import com.ibm.ws.kernel.feature.Visibility;
+import com.ibm.ws.kernel.feature.provisioning.FeatureResource;
import com.ibm.ws.kernel.feature.provisioning.ProvisioningFeatureDefinition;
+import com.ibm.ws.kernel.feature.provisioning.SubsystemContentType;
import com.ibm.ws.kernel.feature.resolver.FeatureResolver;
import com.ibm.ws.repository.common.enums.FilterableAttribute;
import com.ibm.ws.repository.common.enums.ResourceType;
@@ -244,6 +246,71 @@ public ProvisioningFeatureDefinition getFeature(String featureName) {
return feature;
}
+ /**
+ * Answer the list of public versioned features derived from the passed versionless feature or empty List if doesn't exist.
+ *
+ * @return List
+ */
+ public List findAllPossibleVersions(ProvisioningFeatureDefinition versionlessFeature) {
+ List result = new ArrayList<>();
+ for (FeatureResource dependency : versionlessFeature.getConstituents(SubsystemContentType.FEATURE_TYPE)) {
+ result.add(getVersionedFeature(dependency.getSymbolicName()));
+
+ String baseName = getFeatureBaseName(dependency.getSymbolicName());
+ List tolerates = dependency.getTolerates();
+ if (tolerates != null) {
+ for (String toleratedVersion : tolerates) {
+ String featureName = baseName + toleratedVersion;
+ result.add(getVersionedFeature(featureName));
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ *
+ * Answer the public versioned feature based on the internal versionless linking feature
+ *
+ * @param versionlessLinkingFeatureName
+ * @return ProvisioningFeatureDefinition
+ */
+ private ProvisioningFeatureDefinition getVersionedFeature(String versionlessLinkingFeatureName) {
+ ProvisioningFeatureDefinition result = null;
+ ProvisioningFeatureDefinition feature = getFeature(versionlessLinkingFeatureName);
+ if (feature != null) {
+ //This is the versionless linking feature pointing to a public versioned feature
+ for (FeatureResource versionedFeature : feature.getConstituents(SubsystemContentType.FEATURE_TYPE)) {
+ //Find the right public feature (should only be one) - set the result
+ ProvisioningFeatureDefinition versionedFeatureDef = getFeature(versionedFeature.getSymbolicName());
+ if (versionedFeatureDef.getVisibility() != Visibility.PUBLIC) {
+ continue;
+ }
+ result = versionedFeatureDef;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Removes the version from the end of a feature symbolic name
+ *
+ * The version is presumed to start after the last dash character in the name.
+ *
+ * E.g. {@code getFeatureBaseName("com.example.featureA-1.0")} returns {@code "com.example.featureA-"}
+ *
+ * @param nameAndVersion the feature symbolic name
+ * @return the feature symbolic name with any version stripped
+ */
+ public String getFeatureBaseName(String nameAndVersion) {
+ int dashPosition = nameAndVersion.lastIndexOf('-');
+ if (dashPosition != -1) {
+ return nameAndVersion.substring(0, dashPosition + 1);
+ } else {
+ return nameAndVersion;
+ }
+ }
+
/**
* Get a feature by name, but without going and checking the remote repository if we don't know about it
*
From eb96f630c06308f83a54d32e990774a0a9da7b0b Mon Sep 17 00:00:00 2001
From: Chuck Bridgham
Date: Mon, 15 Jul 2024 12:21:44 -0400
Subject: [PATCH 6/8] Add fixes from suggestions, and cleanup comments
---
.../resolver/RepositoryResolver.java | 18 ++++++++----------
.../internal/kernel/KernelResolverEsa.java | 2 +-
.../kernel/KernelResolverRepository.java | 9 +++++----
3 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolver.java b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolver.java
index 56b44028e8c..f0ccc794935 100755
--- a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolver.java
+++ b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolver.java
@@ -1012,16 +1012,14 @@ private void reportErrors() throws RepositoryResolutionException {
List missingBasePlatforms = new ArrayList();
- // Versionless feature issues
- if (!missingTopLevelRequirements.isEmpty()) {
- for (String name : missingTopLevelRequirements) {
- ProvisioningFeatureDefinition feature = resolverRepository.getFeature(name);
- if (feature != null && feature.isVersionless()) {
- ProvisioningFeatureDefinition firstChild = resolverRepository.findAllPossibleVersions(feature).get(0);
- String plat = firstChild.getPlatformName();
- if (plat != null && plat.indexOf("-") != -1) {
- missingBasePlatforms.add(resolverRepository.getFeatureBaseName(plat));
- }
+ // Versionless feature issues will appear in missingTopLevelRequirements, and this will gather the associated platform unable to target.
+ for (String name : missingTopLevelRequirements) {
+ ProvisioningFeatureDefinition feature = resolverRepository.getFeature(name);
+ if (feature != null && feature.isVersionless()) {
+ ProvisioningFeatureDefinition firstChild = resolverRepository.findAllPossibleVersions(feature).get(0);
+ String plat = firstChild.getPlatformName();
+ if (plat != null) {//This will add just the platform name without version
+ missingBasePlatforms.add(resolverRepository.getFeatureBaseName(plat));
}
}
}
diff --git a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverEsa.java b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverEsa.java
index 8a9ed9294b4..857b965f55e 100644
--- a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverEsa.java
+++ b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverEsa.java
@@ -283,7 +283,7 @@ public boolean isConvenience() {
*
* - private
* - do not have a short name
- * - contain ".eeCompatible-" or ".mpCompatible-" in their symbolic name.
+ * - has a platform value
*
*
* @return True or false telling if this is a versionless feature.
diff --git a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverRepository.java b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverRepository.java
index fe3fc5c78fa..47cd993efc0 100644
--- a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverRepository.java
+++ b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverRepository.java
@@ -21,8 +21,6 @@
import java.util.Map;
import java.util.Map.Entry;
-import org.osgi.framework.Version;
-
import com.ibm.ws.kernel.feature.Visibility;
import com.ibm.ws.kernel.feature.provisioning.FeatureResource;
import com.ibm.ws.kernel.feature.provisioning.ProvisioningFeatureDefinition;
@@ -38,6 +36,8 @@
import com.ibm.ws.repository.resources.RepositoryResource;
import com.ibm.ws.repository.resources.internal.RepositoryResourceImpl;
+import junit.runner.Version;
+
/**
* Implementation of {@link FeatureResolver.Repository} which is backed by a collection of {@link EsaResource}s.
*/
@@ -283,10 +283,11 @@ private ProvisioningFeatureDefinition getVersionedFeature(String versionlessLink
for (FeatureResource versionedFeature : feature.getConstituents(SubsystemContentType.FEATURE_TYPE)) {
//Find the right public feature (should only be one) - set the result
ProvisioningFeatureDefinition versionedFeatureDef = getFeature(versionedFeature.getSymbolicName());
- if (versionedFeatureDef.getVisibility() != Visibility.PUBLIC) {
- continue;
+ if (versionedFeatureDef.getVisibility() == Visibility.PUBLIC) {
+ return versionedFeatureDef;
}
result = versionedFeatureDef;
+ break;
}
}
return result;
From c8e60d8fa72848df11478d9b60f84225f38d6c75 Mon Sep 17 00:00:00 2001
From: Chuck Bridgham
Date: Mon, 15 Jul 2024 20:43:40 -0400
Subject: [PATCH 7/8] restructure,check for null
---
.../kernel/KernelResolverRepository.java | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverRepository.java b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverRepository.java
index 47cd993efc0..f56f2a0c90d 100644
--- a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverRepository.java
+++ b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverRepository.java
@@ -21,6 +21,8 @@
import java.util.Map;
import java.util.Map.Entry;
+import org.osgi.framework.Version;
+
import com.ibm.ws.kernel.feature.Visibility;
import com.ibm.ws.kernel.feature.provisioning.FeatureResource;
import com.ibm.ws.kernel.feature.provisioning.ProvisioningFeatureDefinition;
@@ -36,8 +38,6 @@
import com.ibm.ws.repository.resources.RepositoryResource;
import com.ibm.ws.repository.resources.internal.RepositoryResourceImpl;
-import junit.runner.Version;
-
/**
* Implementation of {@link FeatureResolver.Repository} which is backed by a collection of {@link EsaResource}s.
*/
@@ -252,16 +252,21 @@ public ProvisioningFeatureDefinition getFeature(String featureName) {
* @return List
*/
public List findAllPossibleVersions(ProvisioningFeatureDefinition versionlessFeature) {
+ ProvisioningFeatureDefinition publicFeature = null;
List result = new ArrayList<>();
for (FeatureResource dependency : versionlessFeature.getConstituents(SubsystemContentType.FEATURE_TYPE)) {
- result.add(getVersionedFeature(dependency.getSymbolicName()));
-
+ publicFeature = getVersionedFeature(dependency.getSymbolicName());
+ if (publicFeature != null)
+ result.add(publicFeature);
+
String baseName = getFeatureBaseName(dependency.getSymbolicName());
List tolerates = dependency.getTolerates();
if (tolerates != null) {
for (String toleratedVersion : tolerates) {
String featureName = baseName + toleratedVersion;
- result.add(getVersionedFeature(featureName));
+ publicFeature = getVersionedFeature(featureName);
+ if (publicFeature != null)
+ result.add(publicFeature);
}
}
}
@@ -286,11 +291,9 @@ private ProvisioningFeatureDefinition getVersionedFeature(String versionlessLink
if (versionedFeatureDef.getVisibility() == Visibility.PUBLIC) {
return versionedFeatureDef;
}
- result = versionedFeatureDef;
- break;
}
}
- return result;
+ return null;
}
/**
From 9576b50171cab3af65b9b30471a3072dade7ffa9 Mon Sep 17 00:00:00 2001
From: Chuck Bridgham
Date: Tue, 16 Jul 2024 11:50:04 -0400
Subject: [PATCH 8/8] Fixup syntax and javadoc based on comments
---
.../RepositoryResolutionException.java | 6 +-
.../resolver/RepositoryResolver.java | 66 ++++++++-----------
.../internal/kernel/KernelResolverEsa.java | 9 ++-
.../kernel/KernelResolverRepository.java | 6 +-
4 files changed, 37 insertions(+), 50 deletions(-)
diff --git a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolutionException.java b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolutionException.java
index 440ed0ec55c..a1d37a2b289 100755
--- a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolutionException.java
+++ b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolutionException.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014, 2019 IBM Corporation and others.
+ * Copyright (c) 2014, 2024 IBM Corporation and others.
* All rights reserved. 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
@@ -44,7 +44,6 @@ public class RepositoryResolutionException extends RepositoryException {
private final Map> featureConflicts;
private Set resolvedPlatforms;
private Set missingPlatforms;
- private boolean hasVersionlessIssue;
private List missingBasePlatforms;
/**
@@ -373,6 +372,7 @@ private String getResourceName(RepositoryResource resource) {
}
/**
+ * This states the target platforms that were used during the resolution
* @return the resolvedPlatforms
*/
public Set getResolvedPlatforms() {
@@ -380,6 +380,7 @@ public Set getResolvedPlatforms() {
}
/**
+ * This describes missspelled or unknown platform names, official names are collected by the feature metadata
* @return the missingPlatforms
*/
public Set getMissingPlatforms() {
@@ -387,6 +388,7 @@ public Set getMissingPlatforms() {
}
/**
+ * This describes base platforms like "jakartaee" that are not derived, either by passed platform values, or by other included versioned features
* @return the missingBasePlatforms
*/
public List getMissingBasePlatforms() {
diff --git a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolver.java b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolver.java
index f0ccc794935..8d823ad7b5a 100755
--- a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolver.java
+++ b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolver.java
@@ -32,7 +32,6 @@
import com.ibm.ws.kernel.feature.provisioning.ProvisioningFeatureDefinition;
import com.ibm.ws.kernel.feature.resolver.FeatureResolver;
import com.ibm.ws.kernel.feature.resolver.FeatureResolver.Chain;
-import com.ibm.ws.kernel.feature.resolver.FeatureResolver.Repository;
import com.ibm.ws.kernel.feature.resolver.FeatureResolver.Result;
import com.ibm.ws.kernel.productinfo.ProductInfo;
import com.ibm.ws.product.utility.extension.IFixUtils;
@@ -146,11 +145,10 @@ public class RepositoryResolver {
* List of all the missing platforms after resolution
*/
Set missingPlatforms;
-
/**
- * Indicates if an issue was found resolving versionless features and platforms
+ * returns if versionless features are part of the resolution - used to skip extra processing
*/
- boolean hasVersionlessIssue;
+ boolean includesVersionless;
/**
*
@@ -367,6 +365,8 @@ public Collection> resolve(String toResolve) throws Rep
* For example, if {@code ejbLite-3.2} is already installed and {@code resolve(Arrays.asList("cdi-2.0"))} is called, it will not return the autofeature which would be required
* for {@code cdi-2.0} and {@code ejbLite-3.2} to work together.
*
+ * @deprecated - calling this method should be replaced by passing the platform list, required to support versionless features.
+ *
* @param toResolve A collection of the identifiers of the resources to resolve. It should be in the form:
* {name}/{version}
* Where the {name}
can be either the symbolic name, short name or lower case short name of the resource and /{version}
is
@@ -389,6 +389,7 @@ public Collection> resolve(String toResolve) throws Rep
*
* @throws RepositoryResolutionException If the resource cannot be resolved
*/
+ @Deprecated
public Collection> resolveAsSet(Collection toResolve) throws RepositoryResolutionException {
return resolve(toResolve, null, ResolutionMode.DETECT_CONFLICTS);
}
@@ -502,7 +503,7 @@ void initResolve() {
featureConflicts = new HashMap<>();
resolvedPlatforms = new HashSet<>();
missingPlatforms = new HashSet<>();
- hasVersionlessIssue = false;
+ includesVersionless = false;
}
/**
@@ -567,8 +568,11 @@ void resolveFeaturesAsSet() {
Result result = resolver.resolve(resolverRepository, kernelFeatures, featureNamesToResolve, Collections. emptySet(), false, requestedPlatformNames);
featureConflicts.putAll(result.getConflicts());
- if (hasRequestedVersionlessFeatures(featureNamesToResolve, resolverRepository))
- recordVersionless(result, resolverRepository);
+ if (hasRequestedVersionlessFeatures(featureNamesToResolve, resolverRepository)) {
+ includesVersionless = true;
+ resolvedPlatforms = result.getResolvedPlatforms();
+ missingPlatforms = result.getMissingPlatforms();
+ }
for (String name : result.getResolvedFeatures()) {
ProvisioningFeatureDefinition feature = resolverRepository.getFeature(name);
@@ -580,22 +584,6 @@ void resolveFeaturesAsSet() {
}
}
- /**
- * Record Versionless Messages and Issues
- *
- * @param result
- * @param resolverRepo
- * @param requestedFeatures
- */
- private void recordVersionless(Result result, Repository resolverRepo) {
-
- resolvedPlatforms = result.getResolvedPlatforms();
- missingPlatforms = result.getMissingPlatforms();
- if (resolvedPlatforms.isEmpty() || !missingPlatforms.isEmpty())
- hasVersionlessIssue = true;
-
- }
-
/**
* Resolves {@link #featureNamesToResolve} using a simple traversal of the dependency tree
*
@@ -1005,21 +993,27 @@ private EsaResource getResource(ProvisioningFeatureDefinition feature) {
* @throws RepositoryResolutionException if any errors occurred during resolution
*/
private void reportErrors() throws RepositoryResolutionException {
- if (resourcesWrongProduct.isEmpty() && missingTopLevelRequirements.isEmpty() && missingRequirements.isEmpty() && featureConflicts.isEmpty() && !hasVersionlessIssue()) {
+ if (resourcesWrongProduct.isEmpty() && missingTopLevelRequirements.isEmpty() && missingRequirements.isEmpty() && featureConflicts.isEmpty()
+ && (!includesVersionless || ((!resolvedPlatforms.isEmpty()) && (missingPlatforms.isEmpty())))) {
// Everything went fine!
return;
}
List missingBasePlatforms = new ArrayList();
- // Versionless feature issues will appear in missingTopLevelRequirements, and this will gather the associated platform unable to target.
- for (String name : missingTopLevelRequirements) {
- ProvisioningFeatureDefinition feature = resolverRepository.getFeature(name);
- if (feature != null && feature.isVersionless()) {
- ProvisioningFeatureDefinition firstChild = resolverRepository.findAllPossibleVersions(feature).get(0);
- String plat = firstChild.getPlatformName();
- if (plat != null) {//This will add just the platform name without version
- missingBasePlatforms.add(resolverRepository.getFeatureBaseName(plat));
+ // Versionless features can't be resolved if a corresponding platform is not derived, making the choice ambiguous, and the feature won't be included in the resolved list. - will gather the associated platform unable to target.
+ if (includesVersionless) {
+ for (String name : missingTopLevelRequirements) {
+ ProvisioningFeatureDefinition feature = resolverRepository.getFeature(name);
+ if (feature != null && feature.isVersionless()) {
+ List featureChildren = resolverRepository.findAllPossibleVersions(feature);
+ if (!featureChildren.isEmpty()) {
+ ProvisioningFeatureDefinition firstChild = featureChildren.get(0);
+ String plat = firstChild.getPlatformName();
+ if (plat != null) {//This will add just the platform name without version
+ missingBasePlatforms.add(resolverRepository.getFeatureBaseName(plat));
+ }
+ }
}
}
}
@@ -1054,14 +1048,6 @@ private void reportErrors() throws RepositoryResolutionException {
resolvedPlatforms, missingPlatforms, missingBasePlatforms);
}
- /**
- * @return
- */
- protected boolean hasVersionlessIssue() {
-
- return hasVersionlessIssue;
- }
-
static class NameAndVersion {
public NameAndVersion(String name, String version) {
diff --git a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverEsa.java b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverEsa.java
index 857b965f55e..f1cd8c9c496 100644
--- a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverEsa.java
+++ b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverEsa.java
@@ -264,13 +264,12 @@ public boolean isVersionless() {
return false;
}
- if (getSymbolicName().indexOf(".versionless.") == -1) {
- return false;
- } else if (getSymbolicName().indexOf(".internal.versionless.") != -1) {
+ if (getSymbolicName().contains(".versionless.")
+ && !getSymbolicName().contains(".internal.")) {
+ return true;
+ } else {
return false;
}
-
- return true;
}
@Override
diff --git a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverRepository.java b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverRepository.java
index f56f2a0c90d..422c245bdd3 100644
--- a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverRepository.java
+++ b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/internal/kernel/KernelResolverRepository.java
@@ -258,7 +258,7 @@ public List findAllPossibleVersions(ProvisioningF
publicFeature = getVersionedFeature(dependency.getSymbolicName());
if (publicFeature != null)
result.add(publicFeature);
-
+
String baseName = getFeatureBaseName(dependency.getSymbolicName());
List tolerates = dependency.getTolerates();
if (tolerates != null) {
@@ -275,13 +275,13 @@ public List findAllPossibleVersions(ProvisioningF
/**
*
- * Answer the public versioned feature based on the internal versionless linking feature
+ * Answer the public versioned feature based on the internal versionless linking feature, or null if can't be found
*
* @param versionlessLinkingFeatureName
* @return ProvisioningFeatureDefinition
*/
private ProvisioningFeatureDefinition getVersionedFeature(String versionlessLinkingFeatureName) {
- ProvisioningFeatureDefinition result = null;
+
ProvisioningFeatureDefinition feature = getFeature(versionlessLinkingFeatureName);
if (feature != null) {
//This is the versionless linking feature pointing to a public versioned feature