Class InstallFeatureUtil
- java.lang.Object
-
- io.openliberty.tools.common.plugins.util.AbstractContainerSupportUtil
-
- io.openliberty.tools.common.plugins.util.ServerFeatureUtil
-
- io.openliberty.tools.common.plugins.util.InstallFeatureUtil
-
- All Implemented Interfaces:
CommonLoggerI
public abstract class InstallFeatureUtil extends ServerFeatureUtil
Utility class to install features from Maven repositories.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classInstallFeatureUtil.ProductProperties
-
Field Summary
Fields Modifier and Type Field Description static StringANY_CONFLICTstatic StringCONFLICTstatic StringCONFLICT_MESSAGEstatic PatternconflictPatternstatic StringDIFF_MODEL_CONFLICTstatic StringEE_CONFLICTstatic StringINCOMPATIBLE_SINGLETONstatic StringINSTALL_MAP_ARTIFACT_IDstatic StringMISSING_MULTIPLE_DEPENDENTstatic StringOPEN_LIBERTY_GROUP_IDstatic StringREPOSITORY_RESOLVER_ARTIFACT_IDstatic StringSAME_INDIRECT_MODEL_CONFLICTstatic StringSAME_MODEL_CONFLICT-
Fields inherited from class io.openliberty.tools.common.plugins.util.ServerFeatureUtil
SERVER_CONFIG_DIR, SHARED_APP_DIR, SHARED_CONFIG_DIR, SHARED_RESOURCES_DIR, SHARED_STACKGROUP_DIR, suppressLogs, USR_EXTENSION_DIR, WLP_INSTALL_DIR, WLP_USER_DIR
-
-
Constructor Summary
Constructors Constructor Description InstallFeatureUtil(File installDirectory, File buildDirectory, String from, String to, Set<String> pluginListedEsas, List<InstallFeatureUtil.ProductProperties> propertiesList, String openLibertyVersion, String containerName, List<String> additionalJsons)Initialize the utility and check for unsupported scenarios.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Set<String>combineToSet(Collection<String>... collections)Combine the given String collections into a set using case-insensitive matching.static booleancontainsIgnoreCase(Collection<String> reference, Collection<String> target)Returns whether the reference collection contains all of the strings in the target collection, ignoring case.voidcopyUserFeature(Set<String> pluginListedEsas, File installDirectory)abstract voiddebug(String msg)Log debugabstract voiddebug(String msg, Throwable e)Log debugabstract voiddebug(Throwable e)Log debugabstract FiledownloadArtifact(String groupId, String artifactId, String type, String version)Download the artifact from the specified Maven coordinates, or retrieve it from the cache if it already exists.abstract voiderror(String msg)Log errorabstract voiderror(String msg, Throwable e)Log errorstatic StringextractSymbolicName(File jar)Extracts the bundle symbolic name from the jar manifest.static FilegetMapBasedInstallKernelJar(File dir)Find latest install map jar from specified directorystatic StringgetNextProductVersion(String version)Gets the next product version number.static Set<String>getOpenLibertyFeatureSet(Set<File> jsons)Gets the set of all Open Liberty features by scanning the product JSONs.static StringgetOpenLibertyVersion(List<InstallFeatureUtil.ProductProperties> propList)StringgetOverrideBundleDescriptor(String groupId, String artifactId)Download the override bundle from the repository with the given groupId and artifactId, corresponding to the latest version in the range between the current Open Liberty version (inclusive) and the next version (exclusive).abstract voidinfo(String msg)Log infovoidinstallFeatures(boolean isAcceptLicense, List<String> featuresList)Resolve, download, and install features from a Maven repository.static booleanisClosedLiberty(List<InstallFeatureUtil.ProductProperties> propList)abstract booleanisDebugEnabled()Returns whether debug is enabled by the current loggerstatic booleanisOpenLibertyBetaVersion(String olVersion)static List<InstallFeatureUtil.ProductProperties>loadProperties(File installDir)static StringproductInfo(File installDirectory, String action)Runs the productInfo command and returns the output Made public static for tests to use in LMP/LGPabstract voidwarn(String msg)Log warning-
Methods inherited from class io.openliberty.tools.common.plugins.util.ServerFeatureUtil
getLibertyDirectoryPropertyFiles, getServerFeatures, getServerFeatures, getServerFeatures, getServerXmlFeatures, getUserExtensionPath, setLibertyDirectoryPropertyFiles, setLowerCaseFeatures, setSuppressLogs
-
Methods inherited from class io.openliberty.tools.common.plugins.util.AbstractContainerSupportUtil
execDockerCmd, readStdOut
-
-
-
-
Field Detail
-
OPEN_LIBERTY_GROUP_ID
public static final String OPEN_LIBERTY_GROUP_ID
- See Also:
- Constant Field Values
-
REPOSITORY_RESOLVER_ARTIFACT_ID
public static final String REPOSITORY_RESOLVER_ARTIFACT_ID
- See Also:
- Constant Field Values
-
INSTALL_MAP_ARTIFACT_ID
public static final String INSTALL_MAP_ARTIFACT_ID
- See Also:
- Constant Field Values
-
CONFLICT
public static final String CONFLICT
- See Also:
- Constant Field Values
-
INCOMPATIBLE_SINGLETON
public static final String INCOMPATIBLE_SINGLETON
- See Also:
- Constant Field Values
-
MISSING_MULTIPLE_DEPENDENT
public static final String MISSING_MULTIPLE_DEPENDENT
- See Also:
- Constant Field Values
-
SAME_MODEL_CONFLICT
public static final String SAME_MODEL_CONFLICT
- See Also:
- Constant Field Values
-
DIFF_MODEL_CONFLICT
public static final String DIFF_MODEL_CONFLICT
- See Also:
- Constant Field Values
-
SAME_INDIRECT_MODEL_CONFLICT
public static final String SAME_INDIRECT_MODEL_CONFLICT
- See Also:
- Constant Field Values
-
EE_CONFLICT
public static final String EE_CONFLICT
- See Also:
- Constant Field Values
-
ANY_CONFLICT
public static final String ANY_CONFLICT
- See Also:
- Constant Field Values
-
conflictPattern
public static final Pattern conflictPattern
-
CONFLICT_MESSAGE
public static final String CONFLICT_MESSAGE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
InstallFeatureUtil
public InstallFeatureUtil(File installDirectory, File buildDirectory, String from, String to, Set<String> pluginListedEsas, List<InstallFeatureUtil.ProductProperties> propertiesList, String openLibertyVersion, String containerName, List<String> additionalJsons) throws PluginScenarioException, PluginExecutionException
Initialize the utility and check for unsupported scenarios.- Parameters:
installDirectory- The install directoryfrom- The "from" parameter specified in the plugin configuration, or null if not specifiedto- The "to" parameter specified in the plugin configuration, or null if not specifiedpluginListedEsas- The list of ESAs specified in the plugin configuration, or null if not specifiedpropertiesList- The list of product properties installed with the Open Liberty runtimeopenLibertyVersion- The version of the Open Liberty runtimecontainerName- The container name if the features should be installed in a container. Otherwise null.additionalJsons- The list of additional JSONS to search for features from- Throws:
PluginScenarioException- If the current scenario is not supportedPluginExecutionException- If properties files cannot be found in the installDirectory/lib/versions
-
-
Method Detail
-
debug
public abstract void debug(String msg)
Log debug- Specified by:
debugin interfaceCommonLoggerI- Specified by:
debugin classServerFeatureUtil- Parameters:
msg-
-
debug
public abstract void debug(String msg, Throwable e)
Log debug- Specified by:
debugin interfaceCommonLoggerI- Specified by:
debugin classServerFeatureUtil- Parameters:
msg-e-
-
debug
public abstract void debug(Throwable e)
Log debug- Specified by:
debugin interfaceCommonLoggerI- Specified by:
debugin classServerFeatureUtil- Parameters:
e-
-
warn
public abstract void warn(String msg)
Log warning- Specified by:
warnin interfaceCommonLoggerI- Specified by:
warnin classServerFeatureUtil- Parameters:
msg-
-
info
public abstract void info(String msg)
Log info- Specified by:
infoin interfaceCommonLoggerI- Specified by:
infoin classServerFeatureUtil- Parameters:
msg-
-
error
public abstract void error(String msg)
Log error- Specified by:
errorin interfaceCommonLoggerI- Specified by:
errorin classServerFeatureUtil- Parameters:
msg-
-
error
public abstract void error(String msg, Throwable e)
Log error- Specified by:
errorin classServerFeatureUtil- Parameters:
msg-e-
-
isDebugEnabled
public abstract boolean isDebugEnabled()
Returns whether debug is enabled by the current logger- Specified by:
isDebugEnabledin interfaceCommonLoggerI- Specified by:
isDebugEnabledin classServerFeatureUtil- Returns:
- whether debug is enabled
-
downloadArtifact
public abstract File downloadArtifact(String groupId, String artifactId, String type, String version) throws PluginExecutionException
Download the artifact from the specified Maven coordinates, or retrieve it from the cache if it already exists.- Parameters:
groupId- The group IDartifactId- The artifact IDtype- The type e.g. esaversion- The version- Returns:
- The file corresponding to the downloaded artifact
- Throws:
PluginExecutionException- If the artifact could not be downloaded
-
combineToSet
public Set<String> combineToSet(Collection<String>... collections)
Combine the given String collections into a set using case-insensitive matching. If there are multiple instances of the same string but with different capitalization, only the first one found will be included.- Parameters:
collections- a collection of strings- Returns:
- the combined set of strings, ignoring case
-
loadProperties
public static List<InstallFeatureUtil.ProductProperties> loadProperties(File installDir) throws PluginExecutionException
- Throws:
PluginExecutionException
-
getOpenLibertyVersion
public static String getOpenLibertyVersion(List<InstallFeatureUtil.ProductProperties> propList)
-
isClosedLiberty
public static boolean isClosedLiberty(List<InstallFeatureUtil.ProductProperties> propList)
-
isOpenLibertyBetaVersion
public static boolean isOpenLibertyBetaVersion(String olVersion)
-
getOpenLibertyFeatureSet
public static Set<String> getOpenLibertyFeatureSet(Set<File> jsons) throws PluginExecutionException
Gets the set of all Open Liberty features by scanning the product JSONs.- Parameters:
jsons- The set of product JSON files to scan- Returns:
- set of all Open Liberty features
- Throws:
PluginExecutionException- if any of the JSONs could not be found
-
containsIgnoreCase
public static boolean containsIgnoreCase(Collection<String> reference, Collection<String> target)
Returns whether the reference collection contains all of the strings in the target collection, ignoring case.- Parameters:
reference- The reference collectiontarget- The target collection- Returns:
- true if reference contains all Strings from target, ignoring case
-
copyUserFeature
public void copyUserFeature(Set<String> pluginListedEsas, File installDirectory) throws PluginExecutionException
- Throws:
PluginExecutionException
-
installFeatures
public void installFeatures(boolean isAcceptLicense, List<String> featuresList) throws PluginExecutionExceptionResolve, download, and install features from a Maven repository. This method calls the resolver with the given JSONs and feature list, downloads the ESAs corresponding to the resolved features, then installs those features. If user listed feature esa and installUtility/featureUtility is not available to install user feature esa, then copy esa feature manually to Liberty install.- Parameters:
isAcceptLicense- flag for accepting the license termsfeaturesList- The list of features to install.- Throws:
PluginExecutionException- if any of the features could not be installed
-
getOverrideBundleDescriptor
public String getOverrideBundleDescriptor(String groupId, String artifactId) throws PluginExecutionException
Download the override bundle from the repository with the given groupId and artifactId, corresponding to the latest version in the range between the current Open Liberty version (inclusive) and the next version (exclusive). Returns a string in the format "filepath;BundleName" where BundleName is the bundle symbolic name from its manifest.- Parameters:
groupId- the groupId of the bundle to downloadartifactId- the artifactId of the bundle to download- Returns:
- a String representing the bundle in filepath;BundleName format
- Throws:
PluginExecutionException
-
getNextProductVersion
public static String getNextProductVersion(String version) throws PluginExecutionException
Gets the next product version number.- Parameters:
version- the product version- Returns:
- the String representation of the next product version
- Throws:
PluginExecutionException
-
extractSymbolicName
public static String extractSymbolicName(File jar) throws PluginExecutionException
Extracts the bundle symbolic name from the jar manifest.- Parameters:
jar- the jar from which the symbolic name will be extracted- Returns:
- the Bundle-SymbolicName
- Throws:
PluginExecutionException
-
getMapBasedInstallKernelJar
public static File getMapBasedInstallKernelJar(File dir)
Find latest install map jar from specified directory- Returns:
- the install map jar file
-
productInfo
public static String productInfo(File installDirectory, String action) throws PluginExecutionException
Runs the productInfo command and returns the output Made public static for tests to use in LMP/LGP- Parameters:
installDirectory- The directory of the installed runtimeaction- The action to perform for the productInfo command- Returns:
- The command output
- Throws:
PluginExecutionException- if the exit value of the command was not 0
-
-