diff --git a/dev/com.ibm.ws.install.featureUtility/src/com/ibm/ws/install/featureUtility/FeatureUtility.java b/dev/com.ibm.ws.install.featureUtility/src/com/ibm/ws/install/featureUtility/FeatureUtility.java index 7ec294b8881..6a6333868ed 100644 --- a/dev/com.ibm.ws.install.featureUtility/src/com/ibm/ws/install/featureUtility/FeatureUtility.java +++ b/dev/com.ibm.ws.install.featureUtility/src/com/ibm/ws/install/featureUtility/FeatureUtility.java @@ -73,6 +73,7 @@ public class FeatureUtility { private final static String WEBSPHERE_LIBERTY_GROUP_ID = "com.ibm.websphere.appserver.features"; private final static String BETA_EDITION = "EARLY_ACCESS"; private static String to; + private boolean isInstallServerFeature = false; private FeatureUtility(FeatureUtilityBuilder builder) throws IOException, InstallException { @@ -135,7 +136,7 @@ private FeatureUtility(FeatureUtilityBuilder builder) throws IOException, Instal overrideEnvMapWithProperties(); fine("additional jsons: " + additionalJsons); - if (!additionalJsons.isEmpty() && additionalJsons != null) { + if (additionalJsons != null && !additionalJsons.isEmpty()) { jsonsRequired.addAll(additionalJsons); map.put("json.provided", true); } @@ -169,6 +170,10 @@ private FeatureUtility(FeatureUtilityBuilder builder) throws IOException, Instal public void setFeatureToExt(Map featureToExt) { this.featureToExt = featureToExt; } + + public void setIsInstallServerFeature(boolean isInstallServerFeature) { + this.isInstallServerFeature = isInstallServerFeature; + } /** * Initialize the Install kernel map. @@ -437,6 +442,7 @@ public void installFeatures() throws InstallException, IOException { if (fromDir != null) { map.put("from.repo", fromDir.toString()); } + map.put("is.install.server.feature", isInstallServerFeature); Collection resolvedFeatures = (Collection) map.get("action.result"); checkResolvedFeatures(resolvedFeatures); boolean upgraded = (boolean) map.get("upgrade.complete"); diff --git a/dev/com.ibm.ws.install.featureUtility/src/com/ibm/ws/install/featureUtility/cli/InstallServerAction.java b/dev/com.ibm.ws.install.featureUtility/src/com/ibm/ws/install/featureUtility/cli/InstallServerAction.java index e0def37092d..b696c775605 100644 --- a/dev/com.ibm.ws.install.featureUtility/src/com/ibm/ws/install/featureUtility/cli/InstallServerAction.java +++ b/dev/com.ibm.ws.install.featureUtility/src/com/ibm/ws/install/featureUtility/cli/InstallServerAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2020 IBM Corporation and others. + * Copyright (c) 2019, 2020, 2021 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -254,6 +254,7 @@ private ExitCode install() { featureUtility = new FeatureUtility.FeatureUtilityBuilder().setFromDir(fromDir) .setFeaturesToInstall(featureNames).setNoCache(noCache).setlicenseAccepted(acceptLicense).setAdditionalJsons(additionalJsons).build(); featureUtility.setFeatureToExt(featureToExt); + featureUtility.setIsInstallServerFeature(true); featureUtility.installFeatures(); } catch (InstallException e) { logger.log(Level.SEVERE, e.getMessage(), e); diff --git a/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/FeatureUtilityToolTest.java b/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/FeatureUtilityToolTest.java index dd35ed0e334..05d4007c915 100644 --- a/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/FeatureUtilityToolTest.java +++ b/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/FeatureUtilityToolTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2020 IBM Corporation and others. + * Copyright (c) 2019, 2020, 2021 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -68,7 +68,7 @@ protected static void setupEnv() throws Exception { unzipDestination = installRoot + "/../featureUtility_fat_wlp/"; // zip up installRoot - minifiedRoot = exportWlp(installRoot, installRoot + "/../temp/wlp.zip", installRoot + "/../featureUtility_fat_wlp/"); + minifiedRoot = exportWlp(installRoot, installRoot + "/../temp/wlp.zip", installRoot + "/../featureUtility_fat_wlp"); Log.info(c, methodName, "minified root: " + minifiedRoot); if(!new File(minifiedRoot).exists()){ diff --git a/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/InstallFeatureTest.java b/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/InstallFeatureTest.java index abbaf47ba4a..e44d55edb30 100644 --- a/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/InstallFeatureTest.java +++ b/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/InstallFeatureTest.java @@ -102,6 +102,46 @@ public void testInstallFeature() throws Exception { String output = po.getStdout(); assertTrue("Should contain jsp-2.3", output.contains("jsp-2.3")); +// deleteFiles(METHOD_NAME, "com.ibm.websphere.appserver.jsp-2.3", fileLists); + Log.exiting(c, METHOD_NAME); + } + + /** + * Test the install of jsp-2.2, jsp-2.3 from maven central. + * Multi-version is not supported with installServerFeature as it cannot be installed to same resource. + * + * @throws Exception + */ + @Test + public void testMultiVersionFeatures() throws Exception { + final String METHOD_NAME = "testMultiVersionFeatures"; + Log.entering(c, METHOD_NAME); + replaceWlpProperties("20.0.0.4"); + copyFileToMinifiedRoot("etc", "../../publish/propertyFiles/publishRepoOverrideProps/featureUtility.properties"); + + copyFileToMinifiedRoot("repo/com/ibm/websphere/appserver/features/features/20.0.0.4", + "../../publish/repo/com/ibm/websphere/appserver/features/features/20.0.0.4/features-20.0.0.4.json"); + + copyFileToMinifiedRoot("repo/io/openliberty/features/features/20.0.0.4", + "../../publish/repo/io/openliberty/features/features/20.0.0.4/features-20.0.0.4.json"); + + copyFileToMinifiedRoot("repo/io/openliberty/features/jsp-2.3/20.0.0.4", + "../../publish/repo/io/openliberty/features/jsp-2.3/20.0.0.4/jsp-2.3-20.0.0.4.esa"); + + copyFileToMinifiedRoot("repo/io/openliberty/features/jsp-2.2/20.0.0.4", + "../../publish/repo/io/openliberty/features/jsp-2.2/20.0.0.4/jsp-2.2-20.0.0.4.esa"); + + + + writeToProps(minifiedRoot+ "/etc/featureUtility.properties", "featureLocalRepo", minifiedRoot + "/repo/"); + + String[] param1s = { "installFeature", "jsp-2.2", "jsp-2.3", "--verbose"}; + ProgramOutput po = runFeatureUtility(METHOD_NAME, param1s); + assertEquals("Exit code should be 0",0, po.getReturnCode()); + String output = po.getStdout(); + assertTrue("Should contain jsp-2.2", output.contains("jsp-2.2")); + assertTrue("Should contain jsp-2.3", output.contains("jsp-2.3")); + // deleteFiles(METHOD_NAME, "com.ibm.websphere.appserver.jsp-2.3", fileLists); Log.exiting(c, METHOD_NAME); } diff --git a/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/InstallServerTest.java b/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/InstallServerTest.java index c3d0b77869f..ecbe4f50be2 100644 --- a/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/InstallServerTest.java +++ b/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/InstallServerTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019 IBM Corporation and others. + * Copyright (c) 2019, 2021 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -168,6 +168,27 @@ public void testInstallAutoFeatureServerXml() throws Exception { Log.exiting(c, METHOD_NAME); } + /** + * Test the install of jsp-2.2, jsp-2.3 from maven central. + * Multi-version is not supported with installServerFeature as it cannot be installed to same resource. + * + * @throws Exception + */ + @Test + public void testInvalidMultiVersionFeatures() throws Exception { + final String METHOD_NAME = "testInvalidMultiVersionFeatures"; + Log.entering(c, METHOD_NAME); + + copyFileToMinifiedRoot("usr/servers/serverX", "../../publish/tmp/multiVersionServerXml/server.xml"); + String[] param1s = { "installServerFeatures", "serverX", "--verbose"}; + ProgramOutput po = runFeatureUtility(METHOD_NAME, param1s); + assertEquals("Exit code should be 21",21, po.getReturnCode()); + String output = po.getStdout(); + assertTrue("Should contain CWWKF1405E", output.contains("CWWKF1405E")); + +// deleteFiles(METHOD_NAME, "com.ibm.websphere.appserver.jsp-2.3", fileLists); + Log.exiting(c, METHOD_NAME); + } } diff --git a/dev/com.ibm.ws.install.featureUtility_fat/publish/repo/io/openliberty/features/jsp-2.2/20.0.0.4/jsp-2.2-20.0.0.4.esa b/dev/com.ibm.ws.install.featureUtility_fat/publish/repo/io/openliberty/features/jsp-2.2/20.0.0.4/jsp-2.2-20.0.0.4.esa new file mode 100644 index 00000000000..dec22fe5037 Binary files /dev/null and b/dev/com.ibm.ws.install.featureUtility_fat/publish/repo/io/openliberty/features/jsp-2.2/20.0.0.4/jsp-2.2-20.0.0.4.esa differ diff --git a/dev/com.ibm.ws.install.featureUtility_fat/publish/tmp/multiVersionServerXml/server.xml b/dev/com.ibm.ws.install.featureUtility_fat/publish/tmp/multiVersionServerXml/server.xml new file mode 100644 index 00000000000..9fd98f79562 --- /dev/null +++ b/dev/com.ibm.ws.install.featureUtility_fat/publish/tmp/multiVersionServerXml/server.xml @@ -0,0 +1,10 @@ + + + + + + jsp-2.2 + jsp-2.3 + + + diff --git a/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/InstallKernelMap.java b/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/InstallKernelMap.java index 2dc4d2816bb..bda6f95661c 100755 --- a/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/InstallKernelMap.java +++ b/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/InstallKernelMap.java @@ -145,6 +145,7 @@ public class InstallKernelMap implements Map { private static final String GENERATE_JSON_GROUP_ID_MAP = "generate.json.group.id.map"; private static final String TARGET_JSON_DIR = "target.json.dir"; private static final String LOCALLY_PRESENT_JSONS = "locally.present.jsons"; + private static final String IS_INSTALL_SERVER_FEATURE = "is.install.server.feature"; //Headers in Manifest File private static final String SHORTNAME_HEADER_NAME = "IBM-ShortName"; @@ -306,6 +307,12 @@ public Object get(Object key) { } else { return data.get(IS_FEATURE_UTILITY); } + } else if (IS_INSTALL_SERVER_FEATURE.equals(key)) { + if (data.get(IS_INSTALL_SERVER_FEATURE) == null) { + return false; + } else { + return data.get(IS_INSTALL_SERVER_FEATURE); + } } else if (JSON_PROVIDED.equals(key)) { if (data.get(JSON_PROVIDED) == null) { return false; @@ -506,6 +513,12 @@ public Object put(Object key, Object value) { } else { throw new IllegalArgumentException(); } + } else if (IS_INSTALL_SERVER_FEATURE.equals(key)) { + if (value instanceof Boolean) { + data.put(IS_INSTALL_SERVER_FEATURE, value); + } else { + throw new IllegalArgumentException(); + } } else if (DOWNLOAD_FILETYPE.equals(key)) { if (value instanceof String) { data.put(DOWNLOAD_FILETYPE, value); @@ -869,6 +882,7 @@ public Collection singleFileResolve() { int alreadyInstalled = 0; Collection featureToInstall = (Collection) data.get(FEATURES_TO_RESOLVE); + if (data.get(INSTALL_INDIVIDUAL_ESAS) != null) { try { if (data.get(INSTALL_INDIVIDUAL_ESAS).equals(Boolean.TRUE)) { @@ -931,7 +945,12 @@ public Collection singleFileResolve() { } } resolver = new RepositoryResolver(productDefinitions, installedFeatures, Collections. emptySet(), repoList); - resolveResult = resolver.resolveAsSet((Collection) data.get(FEATURES_TO_RESOLVE)); + boolean isInstallServerFeature = (Boolean) this.get(IS_INSTALL_SERVER_FEATURE); + if (!isInstallServerFeature) { + resolveResult = resolver.resolve((Collection) data.get(FEATURES_TO_RESOLVE)); + } else { + resolveResult = resolver.resolveAsSet((Collection) data.get(FEATURES_TO_RESOLVE)); + } ResolveDirector.resolveAutoFeatures(resolveResult, new RepositoryResolver(productDefinitions, installedFeatures, Collections. emptySet(), repoList)); if (!resolveResult.isEmpty()) {