From b6ad00462be2dbaa99c72c41da9109bd12713337 Mon Sep 17 00:00:00 2001 From: Cheryl King Date: Tue, 10 Sep 2024 20:22:08 -0500 Subject: [PATCH] Couple more fixes --- .../tools/gradle/tasks/AbstractFeatureTask.groovy | 8 ++------ .../tools/gradle/tasks/GenerateFeaturesTask.groovy | 13 +++++++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/groovy/io/openliberty/tools/gradle/tasks/AbstractFeatureTask.groovy b/src/main/groovy/io/openliberty/tools/gradle/tasks/AbstractFeatureTask.groovy index 4588e916..8b0e7384 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/tasks/AbstractFeatureTask.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/tasks/AbstractFeatureTask.groovy @@ -223,14 +223,10 @@ public class AbstractFeatureTask extends AbstractServerTask { FeaturesPlatforms getServerFeaturesResult = new FeaturesPlatforms() // if createNewInstallFeatureUtil failed to create a new InstallFeatureUtil instance, then features are installed via ant if (installFeaturesFromAnt) { - Set featuresInstalledFromAnt if (server.features.name != null) { - featuresInstalledFromAnt = new HashSet(server.features.name) - return new FeaturesPlatforms(featuresInstalledFromAnt, new HashSet()) - } else { - featuresInstalledFromAnt = new HashSet() - return getServerFeaturesResult + getServerFeaturesResult.getFeatures().addAll(server.features.name) } + return getServerFeaturesResult } def pluginListedFeatures = getPluginListedFeatures(false) diff --git a/src/main/groovy/io/openliberty/tools/gradle/tasks/GenerateFeaturesTask.groovy b/src/main/groovy/io/openliberty/tools/gradle/tasks/GenerateFeaturesTask.groovy index 6a57fb4a..c7e1b5c5 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/tasks/GenerateFeaturesTask.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/tasks/GenerateFeaturesTask.groovy @@ -175,8 +175,13 @@ class GenerateFeaturesTask extends AbstractFeatureTask { servUtil.setLowerCaseFeatures(false); // get set of user defined features so they can be omitted from the generated file that will be written - FeaturesPlatforms fp = optimize ? existingFeatures : servUtil.getServerFeatures(server.configDirectory, server.serverXmlFile, new HashMap(), generatedFiles); - Set userDefinedFeatures = fp == null ? new HashSet() : fp.getFeatures(); + Set userDefinedFeatures = optimize ? existingFeatures : new HashSet(); + if (!optimize) { + FeaturesPlatforms fp = servUtil.getServerFeatures(server.configDirectory, server.serverXmlFile, new HashMap(), generatedFiles); + if (fp != null) { + userDefinedFeatures = fp.getFeatures(); + } + } logger.debug("User defined features:" + userDefinedFeatures); servUtil.setLowerCaseFeatures(true); if (!userDefinedFeatures.isEmpty()) { @@ -245,9 +250,9 @@ class GenerateFeaturesTask extends AbstractFeatureTask { // returns the features specified in the generated-features.xml file private Set getGeneratedFeatures(ServerFeatureUtil servUtil, File generatedFeaturesFile) { servUtil.setLowerCaseFeatures(false); - Set genFeatSet = new HashSet(); - servUtil.getServerXmlFeatures(genFeatSet, server.configDirectory, + FeaturesPlatforms fp = servUtil.getServerXmlFeatures(new FeaturesPlatforms(), server.configDirectory, generatedFeaturesFile, null, null); + Set genFeatSet = fp == null ? new HashSet() : fp.getFeatures(); servUtil.setLowerCaseFeatures(true); return genFeatSet; }