From de7373a6f90dd3cf7f46d2ff238ef681d8c9b407 Mon Sep 17 00:00:00 2001 From: Paul Gooderham Date: Mon, 1 Jun 2026 15:00:30 -0400 Subject: [PATCH 1/3] Refactor some feature gen variables Co-authored-by-AI: IBM Bob 1.0.2 Signed-off-by: Paul Gooderham --- .../tools/common/plugins/util/DevUtil.java | 18 +- ...ryScannerUtil.java => FeatureGenUtil.java} | 292 +++++++++--------- 2 files changed, 155 insertions(+), 155 deletions(-) rename src/main/java/io/openliberty/tools/common/plugins/util/{BinaryScannerUtil.java => FeatureGenUtil.java} (69%) diff --git a/src/main/java/io/openliberty/tools/common/plugins/util/DevUtil.java b/src/main/java/io/openliberty/tools/common/plugins/util/DevUtil.java index 9e0f8384..5188aa57 100644 --- a/src/main/java/io/openliberty/tools/common/plugins/util/DevUtil.java +++ b/src/main/java/io/openliberty/tools/common/plugins/util/DevUtil.java @@ -560,7 +560,7 @@ public DevUtil(File buildDirectory, File serverDirectory, File sourceDirectory, } this.generateFeatures = generateFeatures; this.generateToSrc = generateToSrc; - this.generateFeaturesTmpDir = new File(buildDirectory, BinaryScannerUtil.GENERATED_FEATURES_TEMP_DIR); + this.generateFeaturesTmpDir = new File(buildDirectory, FeatureGenUtil.GENERATED_FEATURES_TEMP_DIR); initGenerationContext(); this.compileArtifactPaths = compileArtifactPaths; this.testArtifactPaths = testArtifactPaths; @@ -577,7 +577,7 @@ public DevUtil(File buildDirectory, File serverDirectory, File sourceDirectory, private void initGenerationContext() { this.generateFeaturesOutputDir = generateToSrc ? configDirectory : generateFeaturesTmpDir; - this.generateFeaturesFile = new File(generateFeaturesOutputDir, BinaryScannerUtil.GENERATED_FEATURES_FILE_PATH); + this.generateFeaturesFile = new File(generateFeaturesOutputDir, FeatureGenUtil.GENERATED_FEATURES_FILE_PATH); } public void copyGeneratedFeaturesFile(File destinationDir) throws IOException { @@ -1950,8 +1950,8 @@ private void addUserId(List commandElements) { * @param classes class file paths features should be generated for (can be null if no modified classes) * @param optimize if true, generate optimized feature list * @param generateToSrc if true, generate feature list into file in src/main/liberty - * @param useTmpDirOut if true, generate feature file in a hidden directory named in BinaryScannerUtil - * @param useTmpDirIn if true, the hidden directory named in BinaryScannerUtil will be used as the + * @param useTmpDirOut if true, generate feature file in a hidden directory named in FeatureGenUtil + * @param useTmpDirIn if true, the hidden directory named in FeatureGenUtil will be used as the * context or input values to generate features * @return true if feature generation was successful */ @@ -2728,7 +2728,7 @@ private void toggleGenerateToSrc() { private void deleteGenFeaturesFile(File dir) { // N.B. processConfigFileChange() will be called upon deletion of generated features file, it should be ignored - File oldGenFeaturesFile = new File(dir, BinaryScannerUtil.GENERATED_FEATURES_FILE_PATH); + File oldGenFeaturesFile = new File(dir, FeatureGenUtil.GENERATED_FEATURES_FILE_PATH); if (oldGenFeaturesFile.exists()) { if (!oldGenFeaturesFile.delete()) { debug("Error trying to delete the generated features file:" + oldGenFeaturesFile.getAbsolutePath()); @@ -2743,9 +2743,9 @@ private void logGenerateToSrcStatus() { private void infoSrcDirModified() { String generatedFileCanonicalPath; try { - generatedFileCanonicalPath = new File(configDirectory, BinaryScannerUtil.GENERATED_FEATURES_FILE_PATH).getCanonicalPath(); + generatedFileCanonicalPath = new File(configDirectory, FeatureGenUtil.GENERATED_FEATURES_FILE_PATH).getCanonicalPath(); } catch (IOException e) { - generatedFileCanonicalPath = new File(configDirectory, BinaryScannerUtil.GENERATED_FEATURES_FILE_PATH).toString(); + generatedFileCanonicalPath = new File(configDirectory, FeatureGenUtil.GENERATED_FEATURES_FILE_PATH).toString(); } info("The source configuration directory will be modified. Features will automatically be generated in a new file: " + generatedFileCanonicalPath); } @@ -3090,7 +3090,7 @@ public void watchFiles(File outputDirectory, File testOutputDirectory, final Thr } // Always register the generated file in the temp dir. because generateToSrc can be toggled on and off in dev mode - File hiddenTempGenerateFeaturesFile = new File(generateFeaturesTmpDir, BinaryScannerUtil.GENERATED_FEATURES_FILE_PATH); + File hiddenTempGenerateFeaturesFile = new File(generateFeaturesTmpDir, FeatureGenUtil.GENERATED_FEATURES_FILE_PATH); hiddenTempGenerateFeaturesFile.getParentFile().mkdirs(); // must only mkdir on the directories registerSingleFile(hiddenTempGenerateFeaturesFile, executor); @@ -4265,7 +4265,7 @@ private void processFileChanges( // TODO process ALL files in newly registered directory, not just the generated features file https://github.com/OpenLiberty/ci.maven/issues/1548 // check if the generated features file exists in any of the newly registered directories Iterator it = FileUtils.iterateFiles(fileChanged, - new NameFileFilter(BinaryScannerUtil.GENERATED_FEATURES_FILE_NAME), + new NameFileFilter(FeatureGenUtil.GENERATED_FEATURES_FILE_NAME), TrueFileFilter.INSTANCE); if (it.hasNext()) { File newlyRegisteredFile = it.next(); diff --git a/src/main/java/io/openliberty/tools/common/plugins/util/BinaryScannerUtil.java b/src/main/java/io/openliberty/tools/common/plugins/util/FeatureGenUtil.java similarity index 69% rename from src/main/java/io/openliberty/tools/common/plugins/util/BinaryScannerUtil.java rename to src/main/java/io/openliberty/tools/common/plugins/util/FeatureGenUtil.java index 753fbbd0..fd05992b 100644 --- a/src/main/java/io/openliberty/tools/common/plugins/util/BinaryScannerUtil.java +++ b/src/main/java/io/openliberty/tools/common/plugins/util/FeatureGenUtil.java @@ -26,19 +26,19 @@ import java.util.Map; import java.util.Set; -public abstract class BinaryScannerUtil { +public abstract class FeatureGenUtil { - public static final String BINARY_SCANNER_MAVEN_GROUP_ID = "com.ibm.websphere.appmod.tools"; - public static final String BINARY_SCANNER_MAVEN_ARTIFACT_ID = "feature-gen"; - public static final String BINARY_SCANNER_MAVEN_TYPE = "jar"; - public static final String BINARY_SCANNER_MAVEN_VERSION = "[0.0.1-SNAPSHOT,)"; // use the specified version or later + public static final String FEATURE_GEN_MAVEN_GROUP_ID = "com.ibm.websphere.appmod.tools"; + public static final String FEATURE_GEN_MAVEN_ARTIFACT_ID = "feature-gen"; + public static final String FEATURE_GEN_MAVEN_TYPE = "jar"; + public static final String FEATURE_GEN_MAVEN_VERSION = "[0.0.1-SNAPSHOT,)"; // use the specified version or later // The coordinates to use for Open Liberty versions 25.0.0.7 and up public static final String OL_FEATURELIST_GROUP_ID = "io.openliberty.features"; public static final String OL_FEATURELIST_ARTIFACT_ID = "open_liberty_featurelist"; public static final String OL_FEATURELIST_TYPE = "xml"; // the version number is generated at the point of use - // The following key is used when passing the feature list file to the scanner + // The following key is used when passing the feature list file to the generator public static final String OL_FEATURELIST_KEY = "openLiberty"; // The coordinates to use for WebSphere Liberty versions describe three different @@ -61,7 +61,7 @@ public abstract class BinaryScannerUtil { public static final String WS_CORE_FEATURE_LIST_ARTIFACT_ID_BATCH3 = "websphere_liberty_core_featurelist"; // The remaining coordinate is the same for all three public static final String WS_FEATURELIST_TYPE = "xml"; - // The following keys are used when passing the feature list files to the scanner + // The following keys are used when passing the feature list files to the generator public static final String WSBASE_FEATURELIST_KEY = "liberty"; public static final String WSCORE_FEATURELIST_KEY = "libertyCore"; @@ -77,36 +77,36 @@ public abstract class BinaryScannerUtil { private static final String ILLEGAL_TARGET_EXCEPTION = "com.ibm.websphere.binary.cmdline.exceptions.IllegalTargetException"; private static final String ILLEGAL_TARGET_COMBINATION_EXCEPTION = "com.ibm.websphere.binary.cmdline.exceptions.IllegalTargetCombinationException"; private static final String VERSIONLESS_FEATURE_EXCEPTION = "com.ibm.websphere.binary.cmdline.exceptions.VersionlessFeatureException"; - public static final String BINARY_SCANNER_CONFLICT_MESSAGE1 = "A working set of features could not be generated due to conflicts " + + public static final String FEATURE_GEN_CONFLICT_MESSAGE1 = "A working set of features could not be generated due to conflicts " + "between configured features and the application's API usage: %s. Review and update your server configuration and " + "application to ensure they are not using conflicting features and APIs from different levels of MicroProfile, " + "Java EE, or Jakarta EE. Refer to the following set of suggested features for guidance: %s."; - public static final String BINARY_SCANNER_CONFLICT_MESSAGE2 = "A working set of features could not be generated due to conflicts " + + public static final String FEATURE_GEN_CONFLICT_MESSAGE2 = "A working set of features could not be generated due to conflicts " + "between configured features: %s. Review and update your server configuration to ensure it is not using conflicting " + "features from different levels of MicroProfile, Java EE, or Jakarta EE. Refer to the following set of " + "suggested features for guidance: %s."; - public static final String BINARY_SCANNER_CONFLICT_MESSAGE3 = "A working set of features could not be generated due to conflicts " + - "in the application’s API usage: %s. Review and update your application to ensure it is not using conflicting APIs " + + public static final String FEATURE_GEN_CONFLICT_MESSAGE3 = "A working set of features could not be generated due to conflicts " + + "in the application's API usage: %s. Review and update your application to ensure it is not using conflicting APIs " + "from different levels of MicroProfile, Java EE, or Jakarta EE."; - public static final String BINARY_SCANNER_CONFLICT_MESSAGE4 = "[None available]"; // format should match JVM Set.toString() - public static final String BINARY_SCANNER_CONFLICT_MESSAGE5 = "A working set of features could not be generated due to conflicts " + - "in the required features: %s and required levels of MicroProfile: %s, Java EE or Jakarta EE: %s. Review and update your application to ensure it " + + public static final String FEATURE_GEN_CONFLICT_MESSAGE4 = "[None available]"; // format should match JVM Set.toString() + public static final String FEATURE_GEN_CONFLICT_MESSAGE5 = "A working set of features could not be generated due to conflicts " + + "in the required features: %s and required levels of MicroProfile: %s, Java EE or Jakarta EE: %s. Review and update your application to ensure it " + "is using the correct levels of MicroProfile, Java EE, or Jakarta EE, or consider removing the following set of features: %s."; - public static final String BINARY_SCANNER_INVALID_MP_MESSAGE = "The MicroProfile version number %s specified in the build file " + + public static final String FEATURE_GEN_INVALID_MP_MESSAGE = "The MicroProfile version number %s specified in the build file " + "is not supported for feature generation."; - public static final String BINARY_SCANNER_INVALID_EE_MESSAGE = "The Java EE or Jakarta EE version number %s specified in the build file " + + public static final String FEATURE_GEN_INVALID_EE_MESSAGE = "The Java EE or Jakarta EE version number %s specified in the build file " + "is not supported for feature generation."; - public static final String BINARY_SCANNER_INVALID_EEMPARG_MESSAGE = "Either the Java EE or Jakarta EE version number or the MicroProfile version number specified in the build file " + - "is not supported for feature generation."; // We need to be prepared for this situation from the binary scanner. - public static final String BINARY_SCANNER_INVALID_COMBO_MESSAGE = "The Java EE or Jakarta EE version number %s specified in the build file " + + public static final String FEATURE_GEN_INVALID_EEMPARG_MESSAGE = "Either the Java EE or Jakarta EE version number or the MicroProfile version number specified in the build file " + + "is not supported for feature generation."; // We need to be prepared for this situation from the feature generator. + public static final String FEATURE_GEN_INVALID_COMBO_MESSAGE = "The Java EE or Jakarta EE version number %s specified in the build file " + "in combination with the MicroProfile version number %s specified in the build file " + "is not supported for feature generation."; - // Strings recognized by the binary scanner arguments for Java/Jakarta EE and MicroProfile + // Strings recognized by the feature generator arguments for Java/Jakarta EE and MicroProfile // Valid ee6, ee7, ee8, ee9 and so on - public static final String BINARY_SCANNER_EE_PREFIX = "ee"; + public static final String FEATURE_GEN_EE_PREFIX = "ee"; // Valid mp1, mp1.2, mp1.3 and so on - public static final String BINARY_SCANNER_MP_PREFIX = "mp"; + public static final String FEATURE_GEN_MP_PREFIX = "mp"; public abstract void debug(String message); public abstract void debug(String message, Throwable e); @@ -115,57 +115,57 @@ public abstract class BinaryScannerUtil { public abstract void info(String message); public abstract boolean isDebugEnabled(); - // The jar file containing the binary scanner code - private File binaryScannerJar; - private URLClassLoader binaryScannerClassLoader = null; - private Class binaryScannerClass = null; - private Method binaryScannerMethod = null; + // The jar file containing the feature generator code + private File featureGenJar; + private URLClassLoader featureGenClassLoader = null; + private Class featureGenClass = null; + private Method featureGenMethod = null; - public BinaryScannerUtil(File binaryScanner) { - this.binaryScannerJar = binaryScanner; + public FeatureGenUtil(File featureGen) { + this.featureGenJar = featureGen; } /** - * Call the binary scanner to generate a list of Liberty features to run an application. It will scan the + * Call the feature generator to generate a list of Liberty features to run an application. It will scan the * classFiles parameter or scan all the classes in the allClassesDirectories parameter depending on the * optimize parameter. The currentFeatureSet parameter indicates the starting list of features and all the * generated features will be compatible. The generated features will also be compatible with the indicated * versions of Java EE or Jakarta EE and MicroProfile. * * @param currentFeatureSet - the features already specified in the server configuration - * @param classFiles - a set of class files for the scanner to handle. Should be a subset of allClassesDirectories + * @param classFiles - a set of class files for the generator to handle. Should be a subset of allClassesDirectories * @param allClassesDirectories - the directories containing all the class files of the application - * @param logLocation - directory name relative to project or absolute path passed to binary scanner + * @param logLocation - directory name relative to project or absolute path passed to feature generator * @param targetJavaEE - generate features valid for the indicated version of EE * @param targetMicroProfile - generate features valid for the indicated version of MicroProfile * @param optimize - true value means to scan all the classes in allClassesDirectories rather than just the * classes in the classFiles parameter. currentFeatureSet is still used as the basis of * the feature set. * @return - a set of features that will allow the application to run in a Liberty server - * @throws PluginExecutionException - any exception that prevents the scanner from running + * @throws PluginExecutionException - any exception that prevents the generator from running * @throws NoRecommendationException - indicates a problem and there are no recommended features - * @throws RecommendationSetException - indicates a problem but the scanner was able to generate a set of + * @throws RecommendationSetException - indicates a problem but the generator was able to generate a set of * features that should work to run the application - * @throws FeatureModifiedException - indicates a problem but the scanner was able to generate a set of features + * @throws FeatureModifiedException - indicates a problem but the generator was able to generate a set of features * that should work if certain features are modified * @throws FeatureUnavailableException - indicates a problem between required features and required MP/EE levels but - * the scanner was able to generate a set of features that should be removed - * @throws IllegalTargetException - indicates one or both of the MP or EE versions is not supported by the binary scanner - * @throws IllegalTargetComboException - indicates the MP or EE version parameters are not supported by the binary - * scanner when used in combination with each other. E.g. EE 7 and MP 2.1 + * the generator was able to generate a set of features that should be removed + * @throws IllegalTargetException - indicates one or both of the MP or EE versions is not supported by the feature generator + * @throws IllegalTargetComboException - indicates the MP or EE version parameters are not supported by the feature + * generator when used in combination with each other. E.g. EE 7 and MP 2.1 */ - public Set runBinaryScanner(Set currentFeatureSet, List classFiles, Set allClassesDirectories, + public Set runFeatureGenerator(Set currentFeatureSet, List classFiles, Set allClassesDirectories, String logLocation, String targetJavaEE, String targetMicroProfile, Map featureListFileMap, boolean optimize) throws PluginExecutionException, NoRecommendationException, RecommendationSetException, FeatureModifiedException, FeatureUnavailableException, IllegalTargetException, IllegalTargetComboException, VersionlessFeatureDetectedException { Set generatedFeatureList = null; - if (binaryScannerJar != null && binaryScannerJar.exists()) { + if (featureGenJar != null && featureGenJar.exists()) { // if we are already generating features for all class files (optimize=true) and // we are not passing any user specified features (currentFeatureSet is empty) - // we do not need to rerun the binary scanner if it fails + // we do not need to rerun the feature generator if it fails boolean reRunIfFailed = !currentFeatureSet.isEmpty() || !optimize; try { - Method generateFeatureSetMethod = getScannerMethod(); + Method generateFeatureSetMethod = getGeneratorMethod(); // names: binaryInputs, targetJavaEE, targetMicroProfile, currentFeatures, logLocation, logLevel, locale Set binaryInputs = getBinaryInputs(classFiles, allClassesDirectories, optimize); String logLevel; @@ -175,7 +175,7 @@ public Set runBinaryScanner(Set currentFeatureSet, List logLevel = null; logLocation = null; } - debug("Calling " + binaryScannerJar.getName() + " with the following inputs...\n" + + debug("Calling " + featureGenJar.getName() + " with the following inputs...\n" + " binaryInputs: " + binaryInputs + "\n" + " targetJavaEE: " + targetJavaEE + "\n" + " targetMicroP: " + targetMicroProfile + "\n" + @@ -193,111 +193,111 @@ public Set runBinaryScanner(Set currentFeatureSet, List // 1. ProvidedFeatureConflictException means the currentFeatureSet contains conflicts. // 2. FeatureConflictException means the binary files scanned conflict with each other or with // the currentFeatureSet parameter. - // 3. RequiredFeatureModifiedException means the scanner can make a working list of features but + // 3. RequiredFeatureModifiedException means the generator can make a working list of features but // only if certain inputs are changed. // 4. FeatureNotAvailableAtRequestedLevelException means the features passed or binary files // scanned require features that do not exist at the requested EE or MP levels. // 5. IllegalTargetException means that the Java or Jakarta EE version or the MicroProfile version - // we read from the build file is out of range for the binary scanner. For EE we only use the first + // we read from the build file is out of range for the feature generator. For EE we only use the first // digit: ee6 to ee9. For MP we use the first two digits mp1.2 to mp5.0. // 6. IllegalTargetCombinationException means that the EE level and the MP level are not compatible. - Throwable scannerException = ite.getCause(); - if (scannerException.getClass().getName().equals(PROVIDED_FEATURE_EXCEPTION)) { + Throwable featureGenException = ite.getCause(); + if (featureGenException.getClass().getName().equals(PROVIDED_FEATURE_EXCEPTION)) { // The list of features from the app is passed in but it contains conflicts - Set conflicts = getFeatures(scannerException); - // always rerun binary scanner in this scenario, this exception only occurs if a current feature list is passed to binary scanner - Set sampleFeatureList = reRunBinaryScanner(allClassesDirectories, logLocation, targetJavaEE, targetMicroProfile, featureListFileMap); + Set conflicts = getFeatures(featureGenException); + // always rerun feature generator in this scenario, this exception only occurs if a current feature list is passed to feature generator + Set sampleFeatureList = reRunFeatureGenerator(allClassesDirectories, logLocation, targetJavaEE, targetMicroProfile, featureListFileMap); if (sampleFeatureList == null) { throw new NoRecommendationException(conflicts); } else { throw new RecommendationSetException(true, conflicts, sampleFeatureList); } - } else if (scannerException.getClass().getName().equals(FEATURE_CONFLICT_EXCEPTION)) { + } else if (featureGenException.getClass().getName().equals(FEATURE_CONFLICT_EXCEPTION)) { // The scanned files conflict with each other or with current features - Set conflicts = getFeatures(scannerException); - // rerun binary scanner with all class files and without the current feature set to get feature recommendations - Set sampleFeatureList = reRunIfFailed ? reRunBinaryScanner(allClassesDirectories, logLocation, targetJavaEE, targetMicroProfile, featureListFileMap): null; + Set conflicts = getFeatures(featureGenException); + // rerun feature generator with all class files and without the current feature set to get feature recommendations + Set sampleFeatureList = reRunIfFailed ? reRunFeatureGenerator(allClassesDirectories, logLocation, targetJavaEE, targetMicroProfile, featureListFileMap): null; if (sampleFeatureList == null) { throw new NoRecommendationException(conflicts); } else { throw new RecommendationSetException(false, conflicts, sampleFeatureList); } - } else if (scannerException.getClass().getName().equals(FEATURE_MODIFIED_EXCEPTION)) { - // The scanned files conflict and the scanner suggests modifying some features - Set modifications = getFeatures(scannerException); - // rerun binary scanner with all class files and without the current feature set - Set sampleFeatureList = reRunIfFailed ? reRunBinaryScanner(allClassesDirectories, logLocation, targetJavaEE, targetMicroProfile, featureListFileMap) : null; + } else if (featureGenException.getClass().getName().equals(FEATURE_MODIFIED_EXCEPTION)) { + // The scanned files conflict and the generator suggests modifying some features + Set modifications = getFeatures(featureGenException); + // rerun feature generator with all class files and without the current feature set + Set sampleFeatureList = reRunIfFailed ? reRunFeatureGenerator(allClassesDirectories, logLocation, targetJavaEE, targetMicroProfile, featureListFileMap) : null; throw new FeatureModifiedException(modifications, - (sampleFeatureList == null) ? getNoSampleFeatureList() : sampleFeatureList, scannerException.getLocalizedMessage()); - } else if (scannerException.getClass().getName().equals(FEATURE_NOT_AVAILABLE_EXCEPTION)) { - // The list of features required by app or passed to binary scanner do not exist + (sampleFeatureList == null) ? getNoSampleFeatureList() : sampleFeatureList, featureGenException.getLocalizedMessage()); + } else if (featureGenException.getClass().getName().equals(FEATURE_NOT_AVAILABLE_EXCEPTION)) { + // The list of features required by app or passed to feature generator do not exist // at the required EE or MP level - Set conflicts = getFeatures(scannerException); - Set unavailableFeatures = getUnavailableEEFeatures(scannerException); - unavailableFeatures.addAll(getUnavailableMPFeatures(scannerException)); + Set conflicts = getFeatures(featureGenException); + Set unavailableFeatures = getUnavailableEEFeatures(featureGenException); + unavailableFeatures.addAll(getUnavailableMPFeatures(featureGenException)); throw new FeatureUnavailableException(conflicts, unavailableFeatures, targetMicroProfile, targetJavaEE); - } else if (scannerException.getClass().getName().equals(ILLEGAL_TARGET_EXCEPTION)) { + } else if (featureGenException.getClass().getName().equals(ILLEGAL_TARGET_EXCEPTION)) { // The EE and/or the MP version number is out of range - throw new IllegalTargetException(getInvalidEETarget(scannerException), getInvalidMPTarget(scannerException)); - } else if (scannerException.getClass().getName().equals(ILLEGAL_TARGET_COMBINATION_EXCEPTION)) { + throw new IllegalTargetException(getInvalidEETarget(featureGenException), getInvalidMPTarget(featureGenException)); + } else if (featureGenException.getClass().getName().equals(ILLEGAL_TARGET_COMBINATION_EXCEPTION)) { // The EE and MP version numbers are in range but they are not compatible with each other based on the standards. - throw new IllegalTargetComboException(getInvalidEETarget(scannerException), getInvalidMPTarget(scannerException)); - } else if (scannerException.getClass().getName().equals(VERSIONLESS_FEATURE_EXCEPTION)) { - // One of the existing features has no version specified and the binary scanner does not support this. + throw new IllegalTargetComboException(getInvalidEETarget(featureGenException), getInvalidMPTarget(featureGenException)); + } else if (featureGenException.getClass().getName().equals(VERSIONLESS_FEATURE_EXCEPTION)) { + // One of the existing features has no version specified and the feature generator does not support this. throw new VersionlessFeatureDetectedException(); - } else if (scannerException.getClass().getName().contains("java.lang.IllegalArgumentException")) { - // Used by binary scanner 22.0.0.3, remove after 22.0.0.4 is in sonatype + } else if (featureGenException.getClass().getName().contains("java.lang.IllegalArgumentException")) { + // Used by feature generator 22.0.0.3, remove after 22.0.0.4 is in sonatype // TODO: Affected by issue #1558 - String msg = scannerException.getMessage(); + String msg = featureGenException.getMessage(); if (msg.contains("CWMIG12056E")) { if (msg.contains("targetJavaEE")) { - throw new PluginExecutionException(BINARY_SCANNER_INVALID_EE_MESSAGE); + throw new PluginExecutionException(FEATURE_GEN_INVALID_EE_MESSAGE); } else if (msg.contains("targetMicroProfile")) { - throw new PluginExecutionException(BINARY_SCANNER_INVALID_MP_MESSAGE); + throw new PluginExecutionException(FEATURE_GEN_INVALID_MP_MESSAGE); } } // otherwise exit this if statement and execute default behaviour. } - debug("Exception from binary scanner.", scannerException); - throw new PluginExecutionException("Error scanning the application for Liberty features: " + scannerException.toString()); + debug("Exception from feature generator.", featureGenException); + throw new PluginExecutionException("Error scanning the application for Liberty features: " + featureGenException.toString()); } catch (MalformedURLException|ClassNotFoundException|NoSuchMethodException|IllegalAccessException loadingException){ Object o = loadingException.getCause(); if (o != null) { debug("Caused by exception:"+loadingException.getCause().getClass().getName()); debug("Caused by exception message:"+loadingException.getCause().getMessage()); } - throw new PluginExecutionException("An error occurred when trying to call the binary scanner jar: " + loadingException.toString()); + throw new PluginExecutionException("An error occurred when trying to call the feature generator jar: " + loadingException.toString()); } } else { - if (binaryScannerJar == null) { - throw new PluginExecutionException("The binary scanner jar location is not defined."); + if (featureGenJar == null) { + throw new PluginExecutionException("The feature generator jar location is not defined."); } else { - throw new PluginExecutionException("Could not find the binary scanner jar at " + binaryScannerJar.getAbsolutePath()); + throw new PluginExecutionException("Could not find the feature generator jar at " + featureGenJar.getAbsolutePath()); } } return generatedFeatureList; } /** - * The method is intended to call the binary scanner to generate a list of the optimal features for an + * The method is intended to call the feature generator to generate a list of the optimal features for an * application. This optimal list can be reported to the user as a suggested list of features. * * In order to generate the optimal list we must scan all classes in the application and we do not consider * the features already specified in the server configuration (server.xml). * - * @param allClassesDirectories - the scanner will find all the class files in this set of directories - * @param logLocation - directory name relative to project or absolute path passed to binary scanner + * @param allClassesDirectories - the generator will find all the class files in this set of directories + * @param logLocation - directory name relative to project or absolute path passed to feature generator * @param targetJavaEE - generate features valid for the indicated version of EE * @param targetMicroProfile - generate features valid for the indicated version of MicroProfile * @return - a set of features that will allow the application to run in a Liberty server - * @throws PluginExecutionException - any exception that prevents the scanner from running + * @throws PluginExecutionException - any exception that prevents the generator from running */ - public Set reRunBinaryScanner(Set allClassesDirectories, String logLocation, String targetJavaEE, String targetMicroProfile, + public Set reRunFeatureGenerator(Set allClassesDirectories, String logLocation, String targetJavaEE, String targetMicroProfile, Map featureListFileMap) throws PluginExecutionException { Set generatedFeatureList = null; try { - Method generateFeatureSetMethod = getScannerMethod(); + Method generateFeatureSetMethod = getGeneratorMethod(); Set binaryInputs = allClassesDirectories; Set currentFeaturesSet = new HashSet(); // when re-running always pass in no features String logLevel; @@ -307,7 +307,7 @@ public Set reRunBinaryScanner(Set allClassesDirectories, String logLevel = null; logLocation = null; } - debug("Recalling binary scanner with the following inputs...\n" + + debug("Recalling feature generator with the following inputs...\n" + " binaryInputs: " + binaryInputs + "\n" + " targetJavaEE: " + targetJavaEE + "\n" + " targetMicroP: " + targetMicroProfile + "\n" + @@ -319,20 +319,20 @@ public Set reRunBinaryScanner(Set allClassesDirectories, String currentFeaturesSet, featureListFileMap, logLocation, logLevel, java.util.Locale.getDefault()); for (String s : generatedFeatureList) {debug(s);}; } catch (InvocationTargetException ite) { - Throwable scannerException = ite.getCause(); - if (scannerException.getClass().getName().equals(PROVIDED_FEATURE_EXCEPTION)) { + Throwable featureGenException = ite.getCause(); + if (featureGenException.getClass().getName().equals(PROVIDED_FEATURE_EXCEPTION)) { // this happens when the list of features passed in contains conflicts so now no recommendation possible - debug("RuntimeException from re-run of binary scanner", scannerException); // shouldn't happen + debug("RuntimeException from re-run of feature generator", featureGenException); // shouldn't happen generatedFeatureList = null; - } else if (scannerException.getClass().getName().equals(FEATURE_CONFLICT_EXCEPTION)) { + } else if (featureGenException.getClass().getName().equals(FEATURE_CONFLICT_EXCEPTION)) { // The features in the scanned files conflict with each other, no recommendation possible generatedFeatureList = getNoSampleFeatureList(); - } else if (scannerException.getClass().getName().equals(FEATURE_MODIFIED_EXCEPTION)) { + } else if (featureGenException.getClass().getName().equals(FEATURE_MODIFIED_EXCEPTION)) { // The features in the scanned files conflict with each other, no recommendation possible generatedFeatureList = getNoSampleFeatureList(); } else { - debug("Exception from rerunning binary scanner.", scannerException); - throw new PluginExecutionException("Error scanning the application for Liberty feature recommendations: " + scannerException.toString()); + debug("Exception from rerunning feature generator.", featureGenException); + throw new PluginExecutionException("Error scanning the application for Liberty feature recommendations: " + featureGenException.toString()); } } catch (MalformedURLException|ClassNotFoundException|NoSuchMethodException|IllegalAccessException loadingException){ Object o = loadingException.getCause(); @@ -340,7 +340,7 @@ public Set reRunBinaryScanner(Set allClassesDirectories, String debug("Caused by exception2:"+loadingException.getCause().getClass().getName()); debug("Caused by exception message2:"+loadingException.getCause().getMessage()); } - throw new PluginExecutionException("An error occurred when trying to call the binary scanner jar for Liberty feature recommendations: " + loadingException.toString()); + throw new PluginExecutionException("An error occurred when trying to call the feature generator jar for Liberty feature recommendations: " + loadingException.toString()); } return generatedFeatureList; } @@ -348,40 +348,40 @@ public Set reRunBinaryScanner(Set allClassesDirectories, String private Set getNoSampleFeatureList() { Set sampleFeatureList; sampleFeatureList = new HashSet(); - sampleFeatureList.add(BINARY_SCANNER_CONFLICT_MESSAGE4); + sampleFeatureList.add(FEATURE_GEN_CONFLICT_MESSAGE4); return sampleFeatureList; } - private ClassLoader getScannerClassLoader() throws MalformedURLException { - if (binaryScannerClassLoader == null) { + private ClassLoader getGeneratorClassLoader() throws MalformedURLException { + if (featureGenClassLoader == null) { ClassLoader cl = this.getClass().getClassLoader(); - binaryScannerClassLoader = new URLClassLoader(new URL[] { binaryScannerJar.toURI().toURL() }, cl); + featureGenClassLoader = new URLClassLoader(new URL[] { featureGenJar.toURI().toURL() }, cl); } - return binaryScannerClassLoader; + return featureGenClassLoader; } - private Class getScannerClass() throws MalformedURLException, ClassNotFoundException { - if (binaryScannerClass == null) { - ClassLoader cl = getScannerClassLoader(); - binaryScannerClass = cl.loadClass("com.ibm.websphere.binary.cmdline.BinaryScanner"); + private Class getGeneratorClass() throws MalformedURLException, ClassNotFoundException { + if (featureGenClass == null) { + ClassLoader cl = getGeneratorClassLoader(); + featureGenClass = cl.loadClass("com.ibm.websphere.binary.cmdline.BinaryScanner"); } - return binaryScannerClass; + return featureGenClass; } - private Method getScannerMethod() throws MalformedURLException, ClassNotFoundException, NoSuchMethodException, PluginExecutionException, SecurityException { - if (binaryScannerMethod == null) { - Class driveScan = getScannerClass(); + private Method getGeneratorMethod() throws MalformedURLException, ClassNotFoundException, NoSuchMethodException, PluginExecutionException, SecurityException { + if (featureGenMethod == null) { + Class driveScan = getGeneratorClass(); // Method name and return type: Set generateFeatureList() // arg types: Set, String, String, Set, Map, String, String, Locale // arg names: binaryInputs, targetJavaEE, targetMicroProfile, currentFeatures, featureListFileMap, logLocation, logLevel, locale - binaryScannerMethod = driveScan.getMethod("generateFeatureList", Set.class, String.class, String.class, + featureGenMethod = driveScan.getMethod("generateFeatureList", Set.class, String.class, String.class, Set.class, Map.class, String.class, String.class, java.util.Locale.class); - if (binaryScannerMethod == null) { - throw new PluginExecutionException("Error finding binary scanner method using reflection"); + if (featureGenMethod == null) { + throw new PluginExecutionException("Error finding feature generator method using reflection"); } } - return binaryScannerMethod; + return featureGenMethod; } private static Set getBinaryInputs(List classFiles, Set classDirectories, boolean optimize) throws PluginExecutionException { @@ -402,42 +402,42 @@ private static Set getBinaryInputs(List classFiles, Set } @SuppressWarnings("unchecked") - private Set getFeatures(Throwable scannerResponse) { - return (Set) getMethodResult(scannerResponse, "getFeatures"); + private Set getFeatures(Throwable generatorResponse) { + return (Set) getMethodResult(generatorResponse, "getFeatures"); } @SuppressWarnings("unchecked") - private Set getUnavailableMPFeatures(Throwable scannerResponse) { - return (Set) getMethodResult(scannerResponse, "getUnavailableMPFeatures"); + private Set getUnavailableMPFeatures(Throwable generatorResponse) { + return (Set) getMethodResult(generatorResponse, "getUnavailableMPFeatures"); } @SuppressWarnings("unchecked") - private Set getUnavailableEEFeatures(Throwable scannerResponse) { - return (Set) getMethodResult(scannerResponse, "getUnavailableEEFeatures"); + private Set getUnavailableEEFeatures(Throwable generatorResponse) { + return (Set) getMethodResult(generatorResponse, "getUnavailableEEFeatures"); } @SuppressWarnings("unchecked") - private String getInvalidMPTarget(Throwable scannerResponse) { - return (String) getMethodResult(scannerResponse, "getIllegalMPTarget"); + private String getInvalidMPTarget(Throwable generatorResponse) { + return (String) getMethodResult(generatorResponse, "getIllegalMPTarget"); } @SuppressWarnings("unchecked") - private String getInvalidEETarget(Throwable scannerResponse) { - return (String) getMethodResult(scannerResponse, "getIllegalEETarget"); + private String getInvalidEETarget(Throwable generatorResponse) { + return (String) getMethodResult(generatorResponse, "getIllegalEETarget"); } @SuppressWarnings("unchecked") - private Object getMethodResult(Throwable scannerResponse, String method) { + private Object getMethodResult(Throwable generatorResponse, String method) { try { - ClassLoader cl = getScannerClassLoader(); + ClassLoader cl = getGeneratorClassLoader(); @SuppressWarnings("rawtypes") - Class featureConflictException = cl.loadClass(scannerResponse.getClass().getName()); + Class featureConflictException = cl.loadClass(generatorResponse.getClass().getName()); Method featureMethod = featureConflictException.getMethod(method); if (featureMethod == null) { - debug("Error finding " + scannerResponse.getClass().getName() + " method " + method + " using reflection"); + debug("Error finding " + generatorResponse.getClass().getName() + " method " + method + " using reflection"); return null; } - return featureMethod.invoke(scannerResponse); + return featureMethod.invoke(generatorResponse); } catch (ClassNotFoundException | MalformedURLException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException x) { - debug("An error occurred when trying to call the binary scanner jar " + method + ":"+x.getClass().getName(), x); + debug("An error occurred when trying to call the feature generator jar " + method + ":"+x.getClass().getName(), x); Throwable cause = x.getCause(); if (cause != null) { debug("Caused by exception:"+cause.getClass().getName()); @@ -448,11 +448,11 @@ private Object getMethodResult(Throwable scannerResponse, String method) { } /** - * Create the string required by the binary scanner parameter targetJavaEE + * Create the string required by the feature generator parameter targetJavaEE * E.g. ee7, ee8 etc * @param ver the String value version number read from the build file (pom.xml, build.gradle) * E.g. 8, 8.0, 8.0.0 etc. This is verified by the parser and cannot be blank. - * @return String parameter passed to binary scanner + * @return String parameter passed to feature generator */ public static String composeEEVersion(String ver) { if (ver == null) { @@ -461,15 +461,15 @@ public static String composeEEVersion(String ver) { String majorVersion; int offset = ver.indexOf("."); majorVersion = (offset == -1) ? ver : ver.substring(0, offset); - return BINARY_SCANNER_EE_PREFIX + majorVersion; + return FEATURE_GEN_EE_PREFIX + majorVersion; } /** - * Create the string required by the binary scanner parameter targetMicroProfile + * Create the string required by the feature generator parameter targetMicroProfile * E.g. mp1.3, mp4.1 etc * @param ver the String value version number read from the build file (pom.xml, build.gradle) * E.g. 1, 2.1 etc. This is verified by the parser and cannot be blank. - * @return String parameter passed to binary scanner or null in case of error + * @return String parameter passed to feature generator or null in case of error */ public static String composeMPVersion(String ver) { if (ver == null) { @@ -479,10 +479,10 @@ public static String composeMPVersion(String ver) { if (offset > 0) { ver = ver.substring(0, offset); } - String[] parts = ver.split("\\.", 3); // binary scanner only recognises the first two values. Regex for "." char + String[] parts = ver.split("\\.", 3); // feature generator only recognises the first two values. Regex for "." char if (parts.length > 1 && parts[0] != null && !parts[0].isEmpty() && parts[1] != null && !parts[1].isEmpty()) { - return BINARY_SCANNER_MP_PREFIX + parts[0] + "." + parts[1]; + return FEATURE_GEN_MP_PREFIX + parts[0] + "." + parts[1]; } return null; } @@ -491,12 +491,12 @@ public static String composeMPVersion(String ver) { * Convenience method to build the string reported to the user when the exception is detected. * * This is used after the caller has analyzed the Java or Jakarta EE version number and the MicroProfile - * version number and generated argument values to pass to the binary scanner. If the binary scanner + * version number and generated argument values to pass to the feature generator. If the feature generator * detects a problem and throws an exception it reports the invalid arguments. We must map the invalid * arguments back to the user specified version number in order to fix the problem. * - * @param invalidEEArg - the argument passed to the binary scanner which may be returned as invalid. - * @param invalidMPArg - the argument passed to the binary scanner which may be returned as invalid. + * @param invalidEEArg - the argument passed to the feature generator which may be returned as invalid. + * @param invalidMPArg - the argument passed to the feature generator which may be returned as invalid. * @param eeVersion - the user specified version string from the build file used to generate the arg. * @param mpVersion - the user specified version string from the build file used to generate the arg. * @return a string we can report to the user to report an error or errors and guide the effort to fix it. @@ -504,18 +504,18 @@ public static String composeMPVersion(String ver) { public static String buildInvalidArgExceptionMessage(String invalidEEArg, String invalidMPArg, String eeVersion, String mpVersion) { String messages = null; if (invalidEEArg != null) { - messages = String.format(BINARY_SCANNER_INVALID_EE_MESSAGE, eeVersion); + messages = String.format(FEATURE_GEN_INVALID_EE_MESSAGE, eeVersion); } if (invalidMPArg != null) { if (messages != null) { messages += "\n" ; - messages += String.format(BINARY_SCANNER_INVALID_MP_MESSAGE, mpVersion); + messages += String.format(FEATURE_GEN_INVALID_MP_MESSAGE, mpVersion); } else { - messages = String.format(BINARY_SCANNER_INVALID_MP_MESSAGE, mpVersion); + messages = String.format(FEATURE_GEN_INVALID_MP_MESSAGE, mpVersion); } } - if (messages == null) { // We need to be prepared for this situation from the binary scanner. - messages = BINARY_SCANNER_INVALID_EEMPARG_MESSAGE; + if (messages == null) { // We need to be prepared for this situation from the feature generator. + messages = FEATURE_GEN_INVALID_EEMPARG_MESSAGE; } return messages; } From be64f27c8291d862e961474f50a620809525e09f Mon Sep 17 00:00:00 2001 From: Paul Gooderham Date: Thu, 4 Jun 2026 12:19:34 -0400 Subject: [PATCH 2/3] Renamed FeatureGenUtil to FeatureGeneratorUtil for clarity Co-authored-by-AI: IBM Bob 1.0.3 Signed-off-by: Paul Gooderham --- .../tools/common/plugins/util/DevUtil.java | 18 +++++++++--------- ...eGenUtil.java => FeatureGeneratorUtil.java} | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) rename src/main/java/io/openliberty/tools/common/plugins/util/{FeatureGenUtil.java => FeatureGeneratorUtil.java} (99%) diff --git a/src/main/java/io/openliberty/tools/common/plugins/util/DevUtil.java b/src/main/java/io/openliberty/tools/common/plugins/util/DevUtil.java index 5188aa57..1b154ae1 100644 --- a/src/main/java/io/openliberty/tools/common/plugins/util/DevUtil.java +++ b/src/main/java/io/openliberty/tools/common/plugins/util/DevUtil.java @@ -560,7 +560,7 @@ public DevUtil(File buildDirectory, File serverDirectory, File sourceDirectory, } this.generateFeatures = generateFeatures; this.generateToSrc = generateToSrc; - this.generateFeaturesTmpDir = new File(buildDirectory, FeatureGenUtil.GENERATED_FEATURES_TEMP_DIR); + this.generateFeaturesTmpDir = new File(buildDirectory, FeatureGeneratorUtil.GENERATED_FEATURES_TEMP_DIR); initGenerationContext(); this.compileArtifactPaths = compileArtifactPaths; this.testArtifactPaths = testArtifactPaths; @@ -577,7 +577,7 @@ public DevUtil(File buildDirectory, File serverDirectory, File sourceDirectory, private void initGenerationContext() { this.generateFeaturesOutputDir = generateToSrc ? configDirectory : generateFeaturesTmpDir; - this.generateFeaturesFile = new File(generateFeaturesOutputDir, FeatureGenUtil.GENERATED_FEATURES_FILE_PATH); + this.generateFeaturesFile = new File(generateFeaturesOutputDir, FeatureGeneratorUtil.GENERATED_FEATURES_FILE_PATH); } public void copyGeneratedFeaturesFile(File destinationDir) throws IOException { @@ -1950,8 +1950,8 @@ private void addUserId(List commandElements) { * @param classes class file paths features should be generated for (can be null if no modified classes) * @param optimize if true, generate optimized feature list * @param generateToSrc if true, generate feature list into file in src/main/liberty - * @param useTmpDirOut if true, generate feature file in a hidden directory named in FeatureGenUtil - * @param useTmpDirIn if true, the hidden directory named in FeatureGenUtil will be used as the + * @param useTmpDirOut if true, generate feature file in a hidden directory named in FeatureGeneratorUtil + * @param useTmpDirIn if true, the hidden directory named in FeatureGeneratorUtil will be used as the * context or input values to generate features * @return true if feature generation was successful */ @@ -2728,7 +2728,7 @@ private void toggleGenerateToSrc() { private void deleteGenFeaturesFile(File dir) { // N.B. processConfigFileChange() will be called upon deletion of generated features file, it should be ignored - File oldGenFeaturesFile = new File(dir, FeatureGenUtil.GENERATED_FEATURES_FILE_PATH); + File oldGenFeaturesFile = new File(dir, FeatureGeneratorUtil.GENERATED_FEATURES_FILE_PATH); if (oldGenFeaturesFile.exists()) { if (!oldGenFeaturesFile.delete()) { debug("Error trying to delete the generated features file:" + oldGenFeaturesFile.getAbsolutePath()); @@ -2743,9 +2743,9 @@ private void logGenerateToSrcStatus() { private void infoSrcDirModified() { String generatedFileCanonicalPath; try { - generatedFileCanonicalPath = new File(configDirectory, FeatureGenUtil.GENERATED_FEATURES_FILE_PATH).getCanonicalPath(); + generatedFileCanonicalPath = new File(configDirectory, FeatureGeneratorUtil.GENERATED_FEATURES_FILE_PATH).getCanonicalPath(); } catch (IOException e) { - generatedFileCanonicalPath = new File(configDirectory, FeatureGenUtil.GENERATED_FEATURES_FILE_PATH).toString(); + generatedFileCanonicalPath = new File(configDirectory, FeatureGeneratorUtil.GENERATED_FEATURES_FILE_PATH).toString(); } info("The source configuration directory will be modified. Features will automatically be generated in a new file: " + generatedFileCanonicalPath); } @@ -3090,7 +3090,7 @@ public void watchFiles(File outputDirectory, File testOutputDirectory, final Thr } // Always register the generated file in the temp dir. because generateToSrc can be toggled on and off in dev mode - File hiddenTempGenerateFeaturesFile = new File(generateFeaturesTmpDir, FeatureGenUtil.GENERATED_FEATURES_FILE_PATH); + File hiddenTempGenerateFeaturesFile = new File(generateFeaturesTmpDir, FeatureGeneratorUtil.GENERATED_FEATURES_FILE_PATH); hiddenTempGenerateFeaturesFile.getParentFile().mkdirs(); // must only mkdir on the directories registerSingleFile(hiddenTempGenerateFeaturesFile, executor); @@ -4265,7 +4265,7 @@ private void processFileChanges( // TODO process ALL files in newly registered directory, not just the generated features file https://github.com/OpenLiberty/ci.maven/issues/1548 // check if the generated features file exists in any of the newly registered directories Iterator it = FileUtils.iterateFiles(fileChanged, - new NameFileFilter(FeatureGenUtil.GENERATED_FEATURES_FILE_NAME), + new NameFileFilter(FeatureGeneratorUtil.GENERATED_FEATURES_FILE_NAME), TrueFileFilter.INSTANCE); if (it.hasNext()) { File newlyRegisteredFile = it.next(); diff --git a/src/main/java/io/openliberty/tools/common/plugins/util/FeatureGenUtil.java b/src/main/java/io/openliberty/tools/common/plugins/util/FeatureGeneratorUtil.java similarity index 99% rename from src/main/java/io/openliberty/tools/common/plugins/util/FeatureGenUtil.java rename to src/main/java/io/openliberty/tools/common/plugins/util/FeatureGeneratorUtil.java index fd05992b..abe3e4ea 100644 --- a/src/main/java/io/openliberty/tools/common/plugins/util/FeatureGenUtil.java +++ b/src/main/java/io/openliberty/tools/common/plugins/util/FeatureGeneratorUtil.java @@ -26,7 +26,7 @@ import java.util.Map; import java.util.Set; -public abstract class FeatureGenUtil { +public abstract class FeatureGeneratorUtil { public static final String FEATURE_GEN_MAVEN_GROUP_ID = "com.ibm.websphere.appmod.tools"; public static final String FEATURE_GEN_MAVEN_ARTIFACT_ID = "feature-gen"; @@ -121,7 +121,7 @@ public abstract class FeatureGenUtil { private Class featureGenClass = null; private Method featureGenMethod = null; - public FeatureGenUtil(File featureGen) { + public FeatureGeneratorUtil(File featureGen) { this.featureGenJar = featureGen; } From ae7af2434a7affa5fb45cc728cbc59fde3f57b84 Mon Sep 17 00:00:00 2001 From: Paul Gooderham Date: Thu, 4 Jun 2026 16:32:13 -0400 Subject: [PATCH 3/3] Rename variable for clarity Signed-off-by: Paul Gooderham --- .../plugins/util/FeatureGeneratorUtil.java | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/main/java/io/openliberty/tools/common/plugins/util/FeatureGeneratorUtil.java b/src/main/java/io/openliberty/tools/common/plugins/util/FeatureGeneratorUtil.java index abe3e4ea..c6d031ec 100644 --- a/src/main/java/io/openliberty/tools/common/plugins/util/FeatureGeneratorUtil.java +++ b/src/main/java/io/openliberty/tools/common/plugins/util/FeatureGeneratorUtil.java @@ -201,10 +201,10 @@ public Set runFeatureGenerator(Set currentFeatureSet, List conflicts = getFeatures(featureGenException); + Set conflicts = getFeatures(generatorException); // always rerun feature generator in this scenario, this exception only occurs if a current feature list is passed to feature generator Set sampleFeatureList = reRunFeatureGenerator(allClassesDirectories, logLocation, targetJavaEE, targetMicroProfile, featureListFileMap); if (sampleFeatureList == null) { @@ -212,9 +212,9 @@ public Set runFeatureGenerator(Set currentFeatureSet, List conflicts = getFeatures(featureGenException); + Set conflicts = getFeatures(generatorException); // rerun feature generator with all class files and without the current feature set to get feature recommendations Set sampleFeatureList = reRunIfFailed ? reRunFeatureGenerator(allClassesDirectories, logLocation, targetJavaEE, targetMicroProfile, featureListFileMap): null; if (sampleFeatureList == null) { @@ -222,34 +222,34 @@ public Set runFeatureGenerator(Set currentFeatureSet, List modifications = getFeatures(featureGenException); + Set modifications = getFeatures(generatorException); // rerun feature generator with all class files and without the current feature set Set sampleFeatureList = reRunIfFailed ? reRunFeatureGenerator(allClassesDirectories, logLocation, targetJavaEE, targetMicroProfile, featureListFileMap) : null; throw new FeatureModifiedException(modifications, - (sampleFeatureList == null) ? getNoSampleFeatureList() : sampleFeatureList, featureGenException.getLocalizedMessage()); - } else if (featureGenException.getClass().getName().equals(FEATURE_NOT_AVAILABLE_EXCEPTION)) { + (sampleFeatureList == null) ? getNoSampleFeatureList() : sampleFeatureList, generatorException.getLocalizedMessage()); + } else if (generatorException.getClass().getName().equals(FEATURE_NOT_AVAILABLE_EXCEPTION)) { // The list of features required by app or passed to feature generator do not exist // at the required EE or MP level - Set conflicts = getFeatures(featureGenException); - Set unavailableFeatures = getUnavailableEEFeatures(featureGenException); - unavailableFeatures.addAll(getUnavailableMPFeatures(featureGenException)); + Set conflicts = getFeatures(generatorException); + Set unavailableFeatures = getUnavailableEEFeatures(generatorException); + unavailableFeatures.addAll(getUnavailableMPFeatures(generatorException)); throw new FeatureUnavailableException(conflicts, unavailableFeatures, targetMicroProfile, targetJavaEE); - } else if (featureGenException.getClass().getName().equals(ILLEGAL_TARGET_EXCEPTION)) { + } else if (generatorException.getClass().getName().equals(ILLEGAL_TARGET_EXCEPTION)) { // The EE and/or the MP version number is out of range - throw new IllegalTargetException(getInvalidEETarget(featureGenException), getInvalidMPTarget(featureGenException)); - } else if (featureGenException.getClass().getName().equals(ILLEGAL_TARGET_COMBINATION_EXCEPTION)) { + throw new IllegalTargetException(getInvalidEETarget(generatorException), getInvalidMPTarget(generatorException)); + } else if (generatorException.getClass().getName().equals(ILLEGAL_TARGET_COMBINATION_EXCEPTION)) { // The EE and MP version numbers are in range but they are not compatible with each other based on the standards. - throw new IllegalTargetComboException(getInvalidEETarget(featureGenException), getInvalidMPTarget(featureGenException)); - } else if (featureGenException.getClass().getName().equals(VERSIONLESS_FEATURE_EXCEPTION)) { + throw new IllegalTargetComboException(getInvalidEETarget(generatorException), getInvalidMPTarget(generatorException)); + } else if (generatorException.getClass().getName().equals(VERSIONLESS_FEATURE_EXCEPTION)) { // One of the existing features has no version specified and the feature generator does not support this. throw new VersionlessFeatureDetectedException(); - } else if (featureGenException.getClass().getName().contains("java.lang.IllegalArgumentException")) { + } else if (generatorException.getClass().getName().contains("java.lang.IllegalArgumentException")) { // Used by feature generator 22.0.0.3, remove after 22.0.0.4 is in sonatype // TODO: Affected by issue #1558 - String msg = featureGenException.getMessage(); + String msg = generatorException.getMessage(); if (msg.contains("CWMIG12056E")) { if (msg.contains("targetJavaEE")) { throw new PluginExecutionException(FEATURE_GEN_INVALID_EE_MESSAGE); @@ -259,8 +259,8 @@ public Set runFeatureGenerator(Set currentFeatureSet, List reRunFeatureGenerator(Set allClassesDirectories, Stri currentFeaturesSet, featureListFileMap, logLocation, logLevel, java.util.Locale.getDefault()); for (String s : generatedFeatureList) {debug(s);}; } catch (InvocationTargetException ite) { - Throwable featureGenException = ite.getCause(); - if (featureGenException.getClass().getName().equals(PROVIDED_FEATURE_EXCEPTION)) { + Throwable generatorException = ite.getCause(); + if (generatorException.getClass().getName().equals(PROVIDED_FEATURE_EXCEPTION)) { // this happens when the list of features passed in contains conflicts so now no recommendation possible - debug("RuntimeException from re-run of feature generator", featureGenException); // shouldn't happen + debug("RuntimeException from re-run of feature generator", generatorException); // shouldn't happen generatedFeatureList = null; - } else if (featureGenException.getClass().getName().equals(FEATURE_CONFLICT_EXCEPTION)) { + } else if (generatorException.getClass().getName().equals(FEATURE_CONFLICT_EXCEPTION)) { // The features in the scanned files conflict with each other, no recommendation possible generatedFeatureList = getNoSampleFeatureList(); - } else if (featureGenException.getClass().getName().equals(FEATURE_MODIFIED_EXCEPTION)) { + } else if (generatorException.getClass().getName().equals(FEATURE_MODIFIED_EXCEPTION)) { // The features in the scanned files conflict with each other, no recommendation possible generatedFeatureList = getNoSampleFeatureList(); } else { - debug("Exception from rerunning feature generator.", featureGenException); - throw new PluginExecutionException("Error scanning the application for Liberty feature recommendations: " + featureGenException.toString()); + debug("Exception from rerunning feature generator.", generatorException); + throw new PluginExecutionException("Error scanning the application for Liberty feature recommendations: " + generatorException.toString()); } } catch (MalformedURLException|ClassNotFoundException|NoSuchMethodException|IllegalAccessException loadingException){ Object o = loadingException.getCause();