Skip to content

Commit

Permalink
Merge pull request #450 from cbridgha/VersionlessFeatureSupport
Browse files Browse the repository at this point in the history
Start parsing platforms, along with features in featureManager node
  • Loading branch information
cherylking authored Sep 12, 2024
2 parents e22ec0b + 8806dff commit cd06f94
Show file tree
Hide file tree
Showing 10 changed files with 228 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import com.sun.nio.file.SensitivityWatchEventModifier;

import io.openliberty.tools.ant.ServerTask;
import io.openliberty.tools.common.plugins.util.ServerFeatureUtil.FeaturesPlatforms;

import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
Expand Down Expand Up @@ -5749,22 +5750,28 @@ private boolean serverFeaturesModified() {

if (generateFeatures) {
// generateFeatures scenario: check if a generated feature has been manually added to other config files
generatedFeatureSet = servUtil.getServerXmlFeatures(null, serverDirectory,
generatedFeaturesFile, null, null);
FeaturesPlatforms fp = servUtil.getServerXmlFeatures(new FeaturesPlatforms(), serverDirectory,
generatedFeaturesFile, null, null);
if (fp != null)
generatedFeatureSet = fp.getFeatures();
Set<String> generatedFiles = new HashSet<String>();
generatedFiles.add(generatedFeaturesFile.getName());
// if serverXmlFile is null, getServerFeatures will use the default server.xml
// in the configDirectory
featuresExcludingGenerated = servUtil.getServerFeatures(configDirectory, serverXmlFile,
fp = servUtil.getServerFeatures(configDirectory, serverXmlFile,
new HashMap<String, File>(), generatedFiles);
if (fp != null)
featuresExcludingGenerated = fp.getFeatures();
if (featuresExcludingGenerated != null && generatedFeatureSet != null
&& !Collections.disjoint(featuresExcludingGenerated, generatedFeatureSet)) {
// indicates a generated feature has been manually added to other config files
return true;
}
} else {
featuresExcludingGenerated = servUtil.getServerFeatures(configDirectory, serverXmlFile,
FeaturesPlatforms fp = servUtil.getServerFeatures(configDirectory, serverXmlFile,
new HashMap<String, File>(), null);
if (fp != null)
featuresExcludingGenerated = fp.getFeatures();
}

// compare current feature list to existing feature list
Expand All @@ -5790,10 +5797,9 @@ private boolean generatedFeaturesModified() {
// returns the features specified in the generated-features.xml file
private Set<String> getGeneratedFeatures() {
ServerFeatureUtil servUtil = getServerFeatureUtilObj();
Set<String> genFeatSet = new HashSet<String>();
servUtil.getServerXmlFeatures(genFeatSet, configDirectory,
FeaturesPlatforms fp = servUtil.getServerXmlFeatures(new FeaturesPlatforms(), configDirectory,
generatedFeaturesFile, null, null);
return genFeatSet;
return fp!=null ? fp.getFeatures() : new HashSet<String>();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ public void copyUserFeature(Set<String> pluginListedEsas, File installDirectory
* installed
*/
@SuppressWarnings("unchecked")
public void installFeatures(boolean isAcceptLicense, List<String> featuresList)
public void installFeatures(boolean isAcceptLicense, List<String> featuresList, List<String> platformsList)
throws PluginExecutionException {

Map<String, String> featureToExtMap = new HashMap<String, String>();
Expand Down Expand Up @@ -727,7 +727,7 @@ public void installFeatures(boolean isAcceptLicense, List<String> featuresList)
mapBasedInstallKernel = createMapBasedInstallKernelInstance(bundle, installDirectory);


Collection<?> resolvedFeatures = resolveFeatures(featuresToInstall, jsonRepos, acceptLicenseMapValue, pluginListedEsas);
Collection<?> resolvedFeatures = resolveFeatures(featuresToInstall, platformsList,jsonRepos, acceptLicenseMapValue, pluginListedEsas);
if(resolvedFeatures == null || resolvedFeatures.isEmpty()) {
return;
}
Expand Down Expand Up @@ -816,13 +816,14 @@ public void installFeatures(boolean isAcceptLicense, List<String> featuresList)
* @return Collection of resolved features
* @throws PluginExecutionException
*/
private Collection<?> resolveFeatures(List<String> featuresToInstall, List<File> jsonRepos,
private Collection<?> resolveFeatures(List<String> featuresToInstall,List<String> platforms, List<File> jsonRepos,
boolean acceptLicenseMapValue, Set<String> localESA) throws PluginExecutionException {
info("Resolving features... " );

mapBasedInstallKernel.put("install.local.esa", true);
mapBasedInstallKernel.put("single.json.file", jsonRepos);
mapBasedInstallKernel.put("features.to.resolve", featuresToInstall);
mapBasedInstallKernel.put("platforms", platforms);
mapBasedInstallKernel.put("license.accept", acceptLicenseMapValue);
mapBasedInstallKernel.put("is.install.server.feature", true);
if(!localESA.isEmpty()) {
Expand Down
Loading

0 comments on commit cd06f94

Please sign in to comment.