From 4ad8ac55080f99b4fbaad70eb139e2727c14147b Mon Sep 17 00:00:00 2001 From: Scott Kurz Date: Fri, 11 Aug 2023 15:55:13 -0400 Subject: [PATCH] Redeploy app on war-plugin config change Signed-off-by: Scott Kurz --- .../tools/maven/applications/DeployMojoSupport.java | 12 ++++-------- .../io/openliberty/tools/maven/server/DevMojo.java | 7 +++++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/applications/DeployMojoSupport.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/applications/DeployMojoSupport.java index 7efb85bc5..e1df929ed 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/applications/DeployMojoSupport.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/applications/DeployMojoSupport.java @@ -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. // //////////////////////////////////// @@ -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"); ////////////////////////// diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java index 88c70d024..618bf140f 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java @@ -872,10 +872,12 @@ public boolean recompileBuildFile(File buildFile, Set 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 @@ -917,6 +919,11 @@ public boolean recompileBuildFile(File buildFile, Set 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)) {