diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index c15afc6d2..f1cefc2b9 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -22,7 +22,7 @@ jobs: matrix: # test against latest update of each major Java version, as well as specific updates of LTS versions: RUNTIME: [ol, wlp] - RUNTIME_VERSION: [24.0.0.6] + RUNTIME_VERSION: [24.0.0.9] java: [21, 17, 11, 8] exclude: - java: 8 @@ -80,7 +80,7 @@ jobs: matrix: # test against latest update of each major Java version, as well as specific updates of LTS versions: RUNTIME: [ol, wlp] - RUNTIME_VERSION: [24.0.0.6] + RUNTIME_VERSION: [24.0.0.9] java: [21, 17, 11, 8] exclude: - java: 8 diff --git a/liberty-maven-plugin/src/it/server-config-props-it/src/test/java/net/wasdev/wlp/test/servlet/it/ServerConfigPropertiesTest.java b/liberty-maven-plugin/src/it/server-config-props-it/src/test/java/net/wasdev/wlp/test/servlet/it/ServerConfigPropertiesTest.java index 7400b82ca..9b10fd8f8 100644 --- a/liberty-maven-plugin/src/it/server-config-props-it/src/test/java/net/wasdev/wlp/test/servlet/it/ServerConfigPropertiesTest.java +++ b/liberty-maven-plugin/src/it/server-config-props-it/src/test/java/net/wasdev/wlp/test/servlet/it/ServerConfigPropertiesTest.java @@ -1,4 +1,4 @@ -package net.wasdev.wlp.maven.test.servlet.it; +package net.wasdev.wlp.test.servlet.it; import java.io.BufferedWriter; import java.io.File; @@ -125,7 +125,7 @@ public void checkMessagesLogForIncludes() throws Exception { } catch (Exception e) { e.printStackTrace(); } finally { - s.close(); + if (s != null) s.close(); } //Check app name/appsDir resolved correctly during create, deploy, and start diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/InstallFeatureSupport.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/InstallFeatureSupport.java index 0e78d800f..fa5c1855b 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/InstallFeatureSupport.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/InstallFeatureSupport.java @@ -30,6 +30,7 @@ import io.openliberty.tools.ant.FeatureManagerTask.Feature; import io.openliberty.tools.common.plugins.util.InstallFeatureUtil; import io.openliberty.tools.common.plugins.util.InstallFeatureUtil.ProductProperties; +import io.openliberty.tools.common.plugins.util.ServerFeatureUtil.FeaturesPlatforms; import io.openliberty.tools.common.plugins.util.PluginExecutionException; import io.openliberty.tools.common.plugins.util.PluginScenarioException; import io.openliberty.tools.maven.server.types.Features; @@ -211,7 +212,7 @@ protected boolean initialize() throws MojoExecutionException { * @param containerName The container name if the features should be installed in a container. Otherwise null. * @return Set of Strings containing the specified Liberty features */ - protected Set getSpecifiedFeatures(String containerName) throws PluginExecutionException { + protected FeaturesPlatforms getSpecifiedFeatures(String containerName) throws PluginExecutionException { Set pluginListedFeatures = getPluginListedFeatures(false); if (util == null) { @@ -221,19 +222,26 @@ protected Set getSpecifiedFeatures(String containerName) throws PluginEx if (util == null && noFeaturesSection) { //No features were installed because acceptLicense parameter was not configured - return new HashSet(); + return new FeaturesPlatforms(); } else if (util == null && !noFeaturesSection) { Set featuresToInstall = new HashSet(); for (Feature feature : features.getFeatures()) { featuresToInstall.add(feature.toString()); } - return featuresToInstall; + return new FeaturesPlatforms(featuresToInstall, new HashSet()); } else { Set dependencyFeatures = getDependencyFeatures(); - Set serverFeatures = serverDirectory.exists() ? util.getServerFeatures(serverDirectory, getLibertyDirectoryPropertyFiles()) : null; - return util.combineToSet(pluginListedFeatures, dependencyFeatures, serverFeatures); + Set serverFeatures = new HashSet(); + Set serverPlatforms = new HashSet(); + FeaturesPlatforms getServerResult = serverDirectory.exists() ? util.getServerFeatures(serverDirectory, getLibertyDirectoryPropertyFiles()) : null; + if (getServerResult != null) { + serverFeatures = getServerResult.getFeatures(); + serverPlatforms = getServerResult.getPlatforms(); + } + + return new FeaturesPlatforms(util.combineToSet(pluginListedFeatures, dependencyFeatures, serverFeatures),serverPlatforms); } } diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/jsp/CompileJspMojo.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/jsp/CompileJspMojo.java index 1db2b1237..5c5d24a58 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/jsp/CompileJspMojo.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/jsp/CompileJspMojo.java @@ -17,6 +17,7 @@ import java.io.File; import java.text.MessageFormat; +import java.util.HashSet; import java.util.List; import java.util.Properties; import java.util.Set; @@ -33,6 +34,7 @@ import io.openliberty.tools.ant.jsp.CompileJSPs; import io.openliberty.tools.common.plugins.util.PluginExecutionException; +import io.openliberty.tools.common.plugins.util.ServerFeatureUtil.FeaturesPlatforms; import io.openliberty.tools.maven.InstallFeatureSupport; /** @@ -166,9 +168,11 @@ private void doCompileJsps() throws MojoExecutionException { compile.setClasspath(classpathStr); if(initialize()) { - Set installedFeatures; + Set installedFeatures = new HashSet(); try { - installedFeatures = getSpecifiedFeatures(null); + FeaturesPlatforms fp = getSpecifiedFeatures(null); + if (fp!=null) + installedFeatures = fp.getFeatures(); } catch (PluginExecutionException e) { throw new MojoExecutionException("Error getting the list of specified features.", e); } diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java index 9a519707d..2fb569b54 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java @@ -72,6 +72,7 @@ import io.openliberty.tools.common.plugins.util.PluginScenarioException; import io.openliberty.tools.common.plugins.util.ProjectModule; import io.openliberty.tools.common.plugins.util.ServerFeatureUtil; +import io.openliberty.tools.common.plugins.util.ServerFeatureUtil.FeaturesPlatforms; import io.openliberty.tools.common.plugins.util.ServerStatusUtil; import io.openliberty.tools.maven.BasicSupport; import io.openliberty.tools.maven.applications.DeployMojoSupport; @@ -340,6 +341,7 @@ protected List getResourceDirectories(MavenProject project, File outputDir private class DevMojoUtil extends DevUtil { Set existingFeatures; + Set existingPlatforms; Map libertyDirPropertyFiles = new HashMap(); List upstreamMavenProjects; @@ -359,8 +361,12 @@ public DevMojoUtil(File installDir, File userDir, File serverDirectory, File sou this.libertyDirPropertyFiles = BasicSupport.getLibertyDirectoryPropertyFiles(installDir, userDir, serverDirectory); - ServerFeatureUtil servUtil = getServerFeatureUtil(true, libertyDirPropertyFiles); - this.existingFeatures = servUtil.getServerFeatures(serverDirectory, libertyDirPropertyFiles); + ServerFeatureUtil servUtil = getServerFeatureUtil(true, libertyDirPropertyFiles); + FeaturesPlatforms fp = servUtil.getServerFeatures(serverDirectory, libertyDirPropertyFiles); + if (fp != null) { + this.existingFeatures = fp.getFeatures(); + this.existingPlatforms = fp.getPlatforms(); + } this.upstreamMavenProjects = upstreamMavenProjects; setContainerEngine(this); @@ -1174,7 +1180,11 @@ private void libertyDependencyWarning(boolean generateFeatures, Exception e) { public void installFeatures(File configFile, File serverDir, boolean generateFeatures) { try { ServerFeatureUtil servUtil = getServerFeatureUtil(true, libertyDirPropertyFiles); - Set features = servUtil.getServerFeatures(serverDir, libertyDirPropertyFiles); + FeaturesPlatforms fp = servUtil.getServerFeatures(serverDir, libertyDirPropertyFiles); + Set features = null; + if (fp != null) { + features = fp.getFeatures(); + } if (features != null) { Set featuresCopy = new HashSet(features); @@ -1221,8 +1231,15 @@ public Set getExistingFeatures() { @Override public void updateExistingFeatures() { ServerFeatureUtil servUtil = getServerFeatureUtil(true, libertyDirPropertyFiles); - Set features = servUtil.getServerFeatures(serverDirectory, libertyDirPropertyFiles); + FeaturesPlatforms fp = servUtil.getServerFeatures(serverDirectory, libertyDirPropertyFiles); + Set features = new HashSet(); + Set platforms = new HashSet(); + if (fp != null) { + features = fp.getFeatures(); + platforms = fp.getPlatforms(); + } existingFeatures = features; + existingPlatforms = platforms; } @Override diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/GenerateFeaturesMojo.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/GenerateFeaturesMojo.java index 82c51bc65..cefc8be81 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/GenerateFeaturesMojo.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/GenerateFeaturesMojo.java @@ -43,6 +43,7 @@ import static io.openliberty.tools.common.plugins.util.BinaryScannerUtil.*; import io.openliberty.tools.common.plugins.util.PluginExecutionException; import io.openliberty.tools.common.plugins.util.ServerFeatureUtil; +import io.openliberty.tools.common.plugins.util.ServerFeatureUtil.FeaturesPlatforms; import io.openliberty.tools.maven.ServerFeatureSupport; /** @@ -266,9 +267,9 @@ private void generateFeatures() throws MojoExecutionException, PluginExecutionEx servUtil.setLowerCaseFeatures(false); // get set of user defined features so they can be omitted from the generated // file that will be written - Set userDefinedFeatures = optimize ? existingFeatures - : servUtil.getServerFeatures(configDirectory, serverXmlFile, new HashMap(), - generatedFiles); + FeaturesPlatforms fp = servUtil.getServerFeatures(configDirectory, serverXmlFile, new HashMap(), + generatedFiles); + Set userDefinedFeatures = optimize ? existingFeatures : (fp !=null) ? fp.getFeatures(): new HashSet(); getLog().debug("User defined features:" + userDefinedFeatures); servUtil.setLowerCaseFeatures(true); if (userDefinedFeatures != null) { @@ -331,23 +332,26 @@ private Set getServerFeatures(ServerFeatureUtil servUtil, Set ge servUtil.setLowerCaseFeatures(false); // if optimizing, ignore generated files when passing in existing features to // binary scanner - Set existingFeatures = servUtil.getServerFeatures(configDirectory, serverXmlFile, + FeaturesPlatforms fp = servUtil.getServerFeatures(configDirectory, serverXmlFile, new HashMap(), excludeGenerated ? generatedFiles : null); // pass generatedFiles to exclude them - if (existingFeatures == null) { - existingFeatures = new HashSet(); - } servUtil.setLowerCaseFeatures(true); - return existingFeatures; + if (fp == null) { + return new HashSet(); + } + return fp.getFeatures(); } // 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, configDirectory, + FeaturesPlatforms result = servUtil.getServerXmlFeatures(new FeaturesPlatforms(), configDirectory, generatedFeaturesFile, null, null); servUtil.setLowerCaseFeatures(true); - return genFeatSet; + Set features = new HashSet(); + if (result != null) { + features = result.getFeatures(); + } + return features; } /** diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/InstallFeatureMojo.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/InstallFeatureMojo.java index d651d5c81..aeb4f4b86 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/InstallFeatureMojo.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/InstallFeatureMojo.java @@ -19,6 +19,7 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -33,6 +34,7 @@ import io.openliberty.tools.common.plugins.util.DevUtil; import io.openliberty.tools.common.plugins.util.InstallFeatureUtil; import io.openliberty.tools.common.plugins.util.PluginExecutionException; +import io.openliberty.tools.common.plugins.util.ServerFeatureUtil.FeaturesPlatforms; import io.openliberty.tools.common.plugins.util.InstallFeatureUtil.ProductProperties; /** @@ -103,8 +105,13 @@ private void installFeatures() throws PluginExecutionException { List additionalJsons = getAdditionalJsonList(); Collection> keyMap = getKeyMap(); util = getInstallFeatureUtil(pluginListedEsas, propertiesList, openLibertyVersion, containerName, additionalJsons, keyMap); - Set featuresToInstall = getSpecifiedFeatures(containerName); - + FeaturesPlatforms fp = getSpecifiedFeatures(containerName); + Set featuresToInstall = new HashSet(); + Set platformsToInstall = new HashSet(); + if (fp != null) { + featuresToInstall = fp.getFeatures(); + platformsToInstall = fp.getPlatforms(); + } if(!pluginListedEsas.isEmpty() && isClosedLiberty) { installFromAnt = true; } @@ -112,7 +119,7 @@ private void installFeatures() throws PluginExecutionException { if(installFromAnt) { installFeaturesFromAnt(features.getFeatures()); } else if(util != null) { - util.installFeatures(features.isAcceptLicense(), new ArrayList(featuresToInstall)); + util.installFeatures(features.isAcceptLicense(), new ArrayList(featuresToInstall), new ArrayList(platformsToInstall)); } }