@@ -792,24 +792,28 @@ public boolean updateArtifactPaths(ProjectModule projectModule, boolean redeploy
792792
793793 // detect compile dependency changes
794794 if (!dependencyListsEquals (getCompileDependency (deps ), getCompileDependency (oldDeps ))) {
795+ boolean generateFeaturesSuccess = false ;
795796 // optimize generate features
796797 if (generateFeatures ) {
797798 getLog ().debug ("Detected a change in the compile dependencies for "
798799 + buildFile + " , regenerating features" );
799800 // If generateToSrc is false then we must copy new generated features file from temp dir to server dir after install
800- boolean generateFeaturesSuccess = libertyGenerateFeatures (null , true , generateToSrc , !generateToSrc , false );
801- if (generateFeaturesSuccess ) {
802- util .getJavaSourceClassPaths ().clear ();
803- }
804- // install new generated features, will not trigger install-feature if the feature list has not changed
805- util .installFeaturesToTempDir (generateFeaturesFile , configDirectory , null ,
806- generateFeaturesSuccess );
801+ generateFeaturesSuccess = optimizeGenerateFeatures (!generateToSrc , false );
802+ // install new generated features because deploy will copy config files to server dir.
803+ // It will not trigger install-feature if the feature list has not changed
804+ util .installFeaturesToTempDir (generateFeaturesFile , configDirectory , null , generateFeaturesSuccess );
805+ // When generating to the src dir, mojo deploy will copy the files from src to the server.
806+ // When not generating to the src dir, we must copy the generated features file here.
807807 if (!generateToSrc ) {
808- // TODO: do we really need to copy this file here or is it copied by the file watcher after we register the generation temp dir?
808+ // Copy the file here to be used by updateExistingFeatures() below
809809 util .copyGeneratedFeaturesFile (serverDirectory ); // finalize the generate-features operation
810810 }
811811 }
812812 runLibertyMojoDeploy ();
813+ // Update the features after deploy mojo has copied the config files to server dir
814+ if (generateFeaturesSuccess ) {
815+ updateExistingFeatures (); // update the dev mode cache of features in the server
816+ }
813817 }
814818 }
815819 } catch (ProjectBuildingException | DependencyResolutionRequiredException | IOException
@@ -1007,6 +1011,7 @@ public boolean recompileBuildFile(File buildFile, Set<String> compileArtifactPat
10071011 boolean redeployApp = false ;
10081012 boolean runBoostPackage = false ;
10091013 boolean optimizeGenerateFeatures = false ;
1014+ boolean generateFeaturesSuccess = false ;
10101015
10111016 ProjectBuildingResult build ;
10121017 try {
@@ -1121,15 +1126,13 @@ public boolean recompileBuildFile(File buildFile, Set<String> compileArtifactPat
11211126 compileArtifactPaths .addAll (project .getCompileClasspathElements ());
11221127 testArtifactPaths .addAll (project .getTestClasspathElements ());
11231128
1124- boolean generateFeaturesSuccess = false ;
11251129 if (optimizeGenerateFeatures && generateFeatures ) {
11261130 getLog ().debug ("Detected a change in the compile dependencies, regenerating features" );
11271131 // always optimize generate features on dependency change
1128- // If generateToSrc is false then we must copy new generated features file from temp dir to server dir after install
1129- generateFeaturesSuccess = libertyGenerateFeatures (null , true , generateToSrc , !generateToSrc , false );
1130- if (generateFeaturesSuccess ) {
1131- util .getJavaSourceClassPaths ().clear ();
1132- } else {
1132+ // If generateToSrc is false then we must copy (below) new generated features file from temp dir to server dir
1133+ generateFeaturesSuccess = optimizeGenerateFeatures (!generateToSrc , false );
1134+ util .installFeaturesToTempDir (generateFeaturesFile , configDirectory , null , generateFeaturesSuccess );
1135+ if (!generateFeaturesSuccess ) {
11331136 installFeature = false ; // skip installing features if generate features fails
11341137 }
11351138 }
@@ -1172,19 +1175,21 @@ public boolean recompileBuildFile(File buildFile, Set<String> compileArtifactPat
11721175 } else if (createServer ) {
11731176 runLibertyMojoCreate ();
11741177 } else if (redeployApp ) {
1175- util .installFeaturesToTempDir (generateFeaturesFile , configDirectory , null ,
1176- generateFeaturesSuccess );
1178+ // Copy the file here to be used by updateExistingFeatures() below
1179+ // If generateToSrc is false then we must copy new generated features file from temp dir to server dir after install
1180+ if (generateFeaturesSuccess && !generateToSrc ) {
1181+ util .copyGeneratedFeaturesFile (serverDirectory ); // finalize the generate-features operation
1182+ }
11771183 runLibertyMojoDeploy ();
1184+ // Update the features after deploy mojo has copied the config files to server dir and generated features file added
1185+ if (generateFeaturesSuccess ) {
1186+ updateExistingFeatures (); // update the dev mode cache of features in the server
1187+ }
11781188 }
11791189 if (installFeature ) {
11801190 runLibertyMojoInstallFeature (null , null , super .getContainerName ());
11811191 }
11821192 }
1183- // TODO: do we really need to copy this file here or is it copied by the file watcher after we register the generation temp dir?
1184- // If generateToSrc is false then we must copy new generated features file from temp dir to server dir after install
1185- if (generateFeaturesSuccess && !generateToSrc ) {
1186- util .copyGeneratedFeaturesFile (serverDirectory ); // finalize the generate-features operation
1187- }
11881193 if (!(reinstallLiberty || restartServer || createServer || redeployApp || installFeature || runBoostPackage )) {
11891194 // pom.xml is changed but not affecting liberty:dev mode. return true with the
11901195 // updated project set in the session
0 commit comments