diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java index 87a13ba7470..5d5355da984 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java @@ -477,7 +477,7 @@ public class JettyRunMojo extends AbstractJettyMojo scanner.watch(project.getFile().toPath()); - if (webApp.getTestClasses() != null) + if (webApp.getTestClasses() != null && webApp.getTestClasses().exists()) { PathWatcher.Config config = new PathWatcher.Config(webApp.getTestClasses().toPath()); config.setRecurseDepth(PathWatcher.Config.UNLIMITED_DEPTH); @@ -491,7 +491,7 @@ public class JettyRunMojo extends AbstractJettyMojo scanner.watch(config); } - if (webApp.getClasses() != null) + if (webApp.getClasses() != null && webApp.getClasses().exists()) { PathWatcher.Config config = new PathWatcher.Config(webApp.getClasses().toPath()); config.setRecurseDepth(PathWatcher.Config.UNLIMITED_DEPTH); diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunWarExplodedMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunWarExplodedMojo.java index 8b31d9bfde4..53c98b662d4 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunWarExplodedMojo.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunWarExplodedMojo.java @@ -98,21 +98,31 @@ public class JettyRunWarExplodedMojo extends AbstractJettyMojo { scanner.watch(project.getFile().toPath()); File webInfDir = new File(war,"WEB-INF"); - scanner.watch(new File(webInfDir, "web.xml").toPath()); + File webXml = new File(webInfDir, "web.xml"); + if (webXml.exists()) + scanner.watch(webXml.toPath()); File jettyWebXmlFile = findJettyWebXmlFile(webInfDir); if (jettyWebXmlFile != null) scanner.watch(jettyWebXmlFile.toPath()); File jettyEnvXmlFile = new File(webInfDir, "jetty-env.xml"); if (jettyEnvXmlFile.exists()) scanner.watch(jettyEnvXmlFile.toPath()); - - PathWatcher.Config classesConfig = new PathWatcher.Config(new File(webInfDir, "classes").toPath()); - classesConfig.setRecurseDepth(PathWatcher.Config.UNLIMITED_DEPTH); - scanner.watch(classesConfig); - - PathWatcher.Config libConfig = new PathWatcher.Config(new File(webInfDir, "lib").toPath()); - libConfig.setRecurseDepth(PathWatcher.Config.UNLIMITED_DEPTH); - scanner.watch(libConfig); + + File classes = new File(webInfDir, "classes"); + if (classes.exists()) + { + PathWatcher.Config classesConfig = new PathWatcher.Config(classes.toPath()); + classesConfig.setRecurseDepth(PathWatcher.Config.UNLIMITED_DEPTH); + scanner.watch(classesConfig); + } + + File lib = new File(webInfDir, "lib"); + if (lib.exists()) + { + PathWatcher.Config libConfig = new PathWatcher.Config(lib.toPath()); + libConfig.setRecurseDepth(PathWatcher.Config.UNLIMITED_DEPTH); + scanner.watch(libConfig); + } scanner.addListener(new PathWatcher.EventListListener() {