Skip to content

Commit

Permalink
Redeploy app on war-plugin config change
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Kurz <[email protected]>
  • Loading branch information
scottkurz committed Aug 11, 2023
1 parent f605c77 commit 4ad8ac5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,16 @@ protected void installLooseConfigWar(MavenProject proj, LooseConfigData config,
runExplodedMojo();

////////////////////////////////////
// The order matters and establishes a well-defined precedence as documented:
//////////////////////////////////// https://www.ibm.com/docs/en/was-liberty/base?topic=liberty-loose-applications
// The order matters and establishes a well-defined precedence as documented: https://www.ibm.com/docs/en/was-liberty/base?topic=liberty-loose-applications
//
// ".. If you have two files with the same target location in the loose archive, the first occurrence of the file is used.
// The first occurrence is based on a top-down approach to reading the elements of the loose application configuration file..."
//
// Because the flow is so complicated we may have cases where we are applying filtering where one location contains a filtered
//////////////////////////////////// version
// of a file and another potentially has an unfiltered one, and in such cases we need to make sure the filtered version takes
//////////////////////////////////// precedence.
// version of a file and another potentially has an unfiltered one, and in such cases we need to make sure the filtered version takes
// precedence.
//
// In certain cases, like step 1. below we avoid writing a location into the loose app XML because we don't want an unfiltered
//////////////////////////////////// version
// to take precedence and prevent the filtered value from taking effect.
//
////////////////////////////////////
Expand All @@ -180,8 +177,7 @@ protected void installLooseConfigWar(MavenProject proj, LooseConfigData config,
looseWar.addNonFilteredSourceAndWebResourcesPaths();

// 2. target classes - this allows non-deploy mode cases (e.g. non-deploy cases such as `mvn compile` or m2e update in Eclipse)
// to pick up Java class updates
// upon compilation.
// to pick up Java class updates upon compilation.
looseWar.addOutputDir(looseWar.getDocumentRoot(), new File(proj.getBuild().getOutputDirectory()), "/WEB-INF/classes");

//////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -872,10 +872,12 @@ public boolean recompileBuildFile(File buildFile, Set<String> compileArtifactPat

// set the updated project in current session;
Plugin backupLibertyPlugin = getLibertyPlugin();
Plugin backupWarPlugin = getPluginForProject("org.apache.maven.plugins", "maven-war-plugin", project);
MavenProject backupProject = project;
project = build.getProject();
session.setCurrentProject(project);
Plugin libertyPlugin = getLibertyPlugin();
Plugin warPlugin = getPluginForProject("org.apache.maven.plugins", "maven-war-plugin", project);

try {
// TODO rebuild the corresponding module if the compiler options have changed
Expand Down Expand Up @@ -917,6 +919,11 @@ public boolean recompileBuildFile(File buildFile, Set<String> compileArtifactPat
if (!Objects.equals(config, oldConfig)) {
redeployApp = true;
}
config = ExecuteMojoUtil.getPluginGoalConfig(warPlugin, "exploded", getLog());
oldConfig = ExecuteMojoUtil.getPluginGoalConfig(backupWarPlugin, "exploded", getLog());
if (!Objects.equals(config, oldConfig)) {
redeployApp = true;
}
config = ExecuteMojoUtil.getPluginGoalConfig(libertyPlugin, "generate-features", getLog());
oldConfig = ExecuteMojoUtil.getPluginGoalConfig(backupLibertyPlugin, "generate-features", getLog());
if (!Objects.equals(config, oldConfig)) {
Expand Down

0 comments on commit 4ad8ac5

Please sign in to comment.