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 37540dea..4657f386 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 @@ -158,7 +158,7 @@ public FeatureGeneratorUtil(File featureGen) { * @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 runFeatureGenerator(Set currentFeatureSet, List classFiles, String deployedAppFilePath, + public Set runFeatureGenerator(Set currentFeatureSet, List classFiles, String[] deployedAppFilePaths, String logLocation, String targetJavaEE, String targetMicroProfile, Map featureListFileMap, boolean optimize) throws PluginExecutionException, NoRecommendationException, RecommendationSetException, FeatureModifiedException, FeatureUnavailableException, IllegalTargetException, IllegalTargetComboException, VersionlessFeatureDetectedException, @@ -171,7 +171,7 @@ public Set runFeatureGenerator(Set currentFeatureSet, List binaryInputs = getBinaryInputs(classFiles, deployedAppFilePath, optimize); + Set binaryInputs = getBinaryInputs(classFiles, deployedAppFilePaths, optimize); String logLevel; if (isDebugEnabled()) { @@ -212,7 +212,7 @@ public Set runFeatureGenerator(Set currentFeatureSet, List 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(deployedAppFilePath, logLocation, targetJavaEE, targetMicroProfile, featureListFileMap); + Set sampleFeatureList = reRunFeatureGenerator(deployedAppFilePaths, logLocation, targetJavaEE, targetMicroProfile, featureListFileMap); if (sampleFeatureList == null) { throw new NoRecommendationException(conflicts); } else { @@ -222,7 +222,7 @@ public Set runFeatureGenerator(Set currentFeatureSet, List conflicts = getFeatures(generatorException); // rerun feature generator with all class files and without the current feature set to get feature recommendations - Set sampleFeatureList = reRunIfFailed ? reRunFeatureGenerator(deployedAppFilePath, logLocation, targetJavaEE, targetMicroProfile, featureListFileMap): null; + Set sampleFeatureList = reRunIfFailed ? reRunFeatureGenerator(deployedAppFilePaths, logLocation, targetJavaEE, targetMicroProfile, featureListFileMap): null; if (sampleFeatureList == null) { throw new NoRecommendationException(conflicts); } else { @@ -232,7 +232,7 @@ public Set runFeatureGenerator(Set currentFeatureSet, List modifications = getFeatures(generatorException); // rerun feature generator with all class files and without the current feature set - Set sampleFeatureList = reRunIfFailed ? reRunFeatureGenerator(deployedAppFilePath, logLocation, targetJavaEE, targetMicroProfile, featureListFileMap) : null; + Set sampleFeatureList = reRunIfFailed ? reRunFeatureGenerator(deployedAppFilePaths, logLocation, targetJavaEE, targetMicroProfile, featureListFileMap) : null; throw new FeatureModifiedException(modifications, (sampleFeatureList == null) ? getNoSampleFeatureList() : sampleFeatureList, generatorException.getLocalizedMessage()); } else if (generatorException.getClass().getName().equals(FEATURE_NOT_AVAILABLE_EXCEPTION)) { @@ -299,12 +299,12 @@ public Set runFeatureGenerator(Set currentFeatureSet, List reRunFeatureGenerator(String deployedAppFilePath, String logLocation, String targetJavaEE, String targetMicroProfile, + public Set reRunFeatureGenerator(String[] deployedAppFilePaths, String logLocation, String targetJavaEE, String targetMicroProfile, Map featureListFileMap) throws PluginExecutionException, IOErrorReadingXMLException { Set generatedFeatureList = null; try { Method generateFeatureSetMethod = getGeneratorMethod(); - Set binaryInputs = getBinaryInputs(null, deployedAppFilePath, true); + Set binaryInputs = getBinaryInputs(null, deployedAppFilePaths, true); Set currentFeaturesSet = new HashSet(); // when re-running always pass in no features String logLevel; if (isDebugEnabled()) { @@ -391,23 +391,27 @@ private Method getGeneratorMethod() throws MalformedURLException, ClassNotFoundE } // Required is either some type of app file or some class files. This is checked by the caller to runFeatureGenerator() - private Set getBinaryInputs(List classFiles, String deployedAppFilePath, boolean optimize) throws IOErrorReadingXMLException { + private Set getBinaryInputs(List classFiles, String[] deployedAppFilePaths, boolean optimize) throws IOErrorReadingXMLException { Set resultSet = new HashSet(); if (optimize) { // Use either the loose app config or a regular application deployment binary file (ear/war/jar) - if (deployedAppFilePath != null) { - if (deployedAppFilePath.endsWith(".xml")) { - try { - // extract the file names from the xml file - File looseAppFile = new File(deployedAppFilePath); - if (looseAppFile.exists()) { - resultSet = ServerConfigDocument.getSourceOnDiskPaths(looseAppFile); + if (deployedAppFilePaths != null) { + for (String deployedAppFilePath : deployedAppFilePaths) { + if (deployedAppFilePath.endsWith(".xml")) { + try { + // extract the file names from the xml file + File looseAppFile = new File(deployedAppFilePath); + if (looseAppFile.exists()) { + resultSet.addAll(ServerConfigDocument.getSourceOnDiskPaths(looseAppFile)); + } else { + debug("Error, specified application file does not exist:" + deployedAppFilePath); + } + } catch (IOException e) { + throw new IOErrorReadingXMLException(); } - } catch (IOException e) { - throw new IOErrorReadingXMLException(); + } else { + resultSet.add(deployedAppFilePath); } - } else { - resultSet.add(deployedAppFilePath); } } } else {