diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractForker.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractForker.java index 9aa7f4772e6..ca04a359bdd 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractForker.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractForker.java @@ -55,9 +55,9 @@ public abstract class AbstractForker extends AbstractLifeCycle protected boolean waitForChild; - protected int maxChildChecks = 10; //check up to 10 times for child to start + protected int maxChildStartChecks = 10; //check up to 10 times for child to start - protected long maxChildCheckInterval = 200; //wait 100ms between checks + protected long maxChildStartCheckMs = 200; //wait 200ms between checks protected File tokenFile; @@ -195,24 +195,24 @@ public abstract class AbstractForker extends AbstractLifeCycle this.waitForChild = waitForChild; } - public int getMaxChildChecks() + public int getMaxChildtartChecks() { - return maxChildChecks; + return maxChildStartChecks; } - public void setMaxChildChecks(int maxChildChecks) + public void setMaxChildStartChecks(int maxChildStartChecks) { - this.maxChildChecks = maxChildChecks; + this.maxChildStartChecks = maxChildStartChecks; } - public long getMaxChildCheckInterval() + public long getMaxChildStartCheckMs() { - return maxChildCheckInterval; + return maxChildStartCheckMs; } - public void setMaxChildCheckInterval(long maxChildCheckInterval) + public void setMaxChildStartCheckMs(long maxChildStartCheckMs) { - this.maxChildCheckInterval = maxChildCheckInterval; + this.maxChildStartCheckMs = maxChildStartCheckMs; } public File getTokenFile() @@ -242,10 +242,10 @@ public abstract class AbstractForker extends AbstractLifeCycle else { //just wait until the child has started successfully - int attempts = maxChildChecks; + int attempts = maxChildStartChecks; while (!tokenFile.exists() && attempts > 0) { - Thread.currentThread().sleep(maxChildCheckInterval); + Thread.currentThread().sleep(maxChildStartCheckMs); --attempts; } if (attempts <= 0) diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractWebAppMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractWebAppMojo.java index 3225dd8a103..5d0695e4158 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractWebAppMojo.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractWebAppMojo.java @@ -80,7 +80,19 @@ public abstract class AbstractWebAppMojo extends AbstractMojo DISTRO } + /** + * Max number of times to check to see if jetty has started correctly + * when running in FORK or DISTRO mode. + */ + @Parameter (defaultValue = "10") + protected int maxChildStartChecks; + /** + * How long to wait in msec between checks to see if jetty has started + * correctly when running in FORK or DISTRO mode. + */ + @Parameter (defaultValue = "200") + protected long maxChildStartCheckMs; /** * Whether or not to include dependencies on the plugin's classpath with <scope>provided</scope> * Use WITH CAUTION as you may wind up with duplicate jars/classes. @@ -192,16 +204,9 @@ public abstract class AbstractWebAppMojo extends AbstractMojo @Parameter (defaultValue = "${project.baseDir}/src/main/webapp") protected File webAppSourceDirectory; - /** - * List of files or directories to additionally periodically scan for changes. Optional. - */ - @Parameter - protected List scanTargets; - /** * List of directories with ant-style <include> and <exclude> patterns - * for extra targets to periodically scan for changes. Can be used instead of, - * or in conjunction with <scanTargets>.Optional. + * for extra targets to periodically scan for changes.Optional. */ @Parameter protected List scanTargetPatterns; @@ -1015,24 +1020,8 @@ public abstract class AbstractWebAppMojo extends AbstractMojo * * @param scanner PathWatcher that notices changes in files and dirs. */ - protected void configureScanTargetsAndPatterns(PathWatcher scanner) + protected void configureScanTargetPatterns(PathWatcher scanner) { - //handle the explicit extra scan targets - if (scanTargets != null) - { - for (File f:scanTargets) - { - if (f.isDirectory()) - { - PathWatcher.Config config = new PathWatcher.Config(f.toPath()); - config.setRecurseDepth(PathWatcher.Config.UNLIMITED_DEPTH); - scanner.watch(config); - } - else - scanner.watch(f.toPath()); - } - } - //handle the extra scan patterns if (scanTargetPatterns != null) { 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 37f3f40c8af..296ae9f47d5 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 @@ -36,8 +36,6 @@ import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.webapp.WebAppContext; /** - * NewJettyRunMojo - * * This goal is used in-situ on a Maven project without first requiring that the project * is assembled into a war, saving time during the development cycle. *

@@ -48,7 +46,10 @@ import org.eclipse.jetty.webapp.WebAppContext; * Once invoked, the plugin can be configured to run continuously, scanning for changes in the project and automatically performing a * hot redeploy when necessary. This allows the developer to concentrate on coding changes to the project using their IDE of choice and have those changes * immediately and transparently reflected in the running web container, eliminating development time that is wasted on rebuilding, reassembling and redeploying. - * Alternatively, you can configure the plugin to wait for an %lt;enter> at the command line to manually control redeployment. + * Alternatively, you can configure the plugin to wait for an <enter> at the command line to manually control redeployment. + *

+ * You can configure this goal to run your unassembled webapp either in-process with maven, or forked into a new process, or deployed into a + * jetty distribution. */ @Mojo (name = "run", requiresDependencyResolution = ResolutionScope.TEST) @Execute (phase = LifecyclePhase.TEST_COMPILE) @@ -259,7 +260,7 @@ public class JettyRunMojo extends AbstractWebAppMojo } //set up any extra files or dirs to watch - configureScanTargetsAndPatterns(scanner); + configureScanTargetPatterns(scanner); scanner.watch(project.getFile().toPath()); diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunWarMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunWarMojo.java index f6574b7925b..4ea5a8ec4d2 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunWarMojo.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunWarMojo.java @@ -44,7 +44,10 @@ import org.eclipse.jetty.util.StringUtil; *

* You may also specify the location of a jetty.xml file whose contents will be applied before any plugin configuration. *

-* Runs jetty on a war file +*

+* You can configure this goal to run your webapp either in-process with maven, or forked into a new process, or deployed into a +* jetty distribution. +*

*/ @Mojo(name = "run-war", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME) @Execute(phase = LifecyclePhase.PACKAGE) @@ -186,7 +189,7 @@ public class JettyRunWarMojo extends AbstractWebAppMojo scanner.watch(war); //set up any extra files or dirs to watch - configureScanTargetsAndPatterns(scanner); + configureScanTargetPatterns(scanner); scanner.addListener(new PathWatcher.EventListListener() { diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyStartMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyStartMojo.java index 035c00b1a4c..52324a6239c 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyStartMojo.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyStartMojo.java @@ -34,6 +34,10 @@ import org.apache.maven.plugins.annotations.ResolutionScope; *

* This goal will NOT scan for changes in either the webapp project or any scanTargets or scanTargetPatterns. *

+ *

+ * You can configure this goal to run your webapp either in-process with maven, or forked into a new process, or deployed into a + * jetty distribution. + *

*/ @Mojo(name = "start", requiresDependencyResolution = ResolutionScope.TEST) @Execute(phase = LifecyclePhase.VALIDATE) @@ -76,7 +80,9 @@ public class JettyStartMojo extends AbstractWebAppMojo try { JettyForker jetty = newJettyForker(); - jetty.setWaitForChild(false); //we never wait for child + jetty.setWaitForChild(false); //we never wait for child to finish + jetty.setMaxChildStartChecks(maxChildStartChecks); + jetty.setMaxChildStartCheckMs(maxChildStartCheckMs); jetty.setJettyOutputFile(getJettyOutputFile("jetty-start.out")); jetty.start(); //forks jetty instance } @@ -96,7 +102,9 @@ public class JettyStartMojo extends AbstractWebAppMojo try { JettyDistroForker jetty = newJettyDistroForker(); - jetty.setWaitForChild(false); //never wait for child + jetty.setWaitForChild(false); //never wait for child to finish + jetty.setMaxChildStartChecks(maxChildStartChecks); + jetty.setMaxChildStartCheckMs(maxChildStartCheckMs); jetty.setJettyOutputFile(getJettyOutputFile("jetty-start.out")); jetty.start(); //forks a jetty distro } diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyStartWarMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyStartWarMojo.java index c9efc1b4fda..63eb5908182 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyStartWarMojo.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyStartWarMojo.java @@ -29,10 +29,11 @@ import org.eclipse.jetty.util.StringUtil; * to be used with a project of packaging type "war". *

*

- * You must configure the "webApp" element with the location of either a war file or + * You can configure the "webApp" element with the location of either a war file or * an unpacked war that you wish to deploy - in either case, the webapp must be * fully compiled and assembled as this goal does not do anything other than start - * jetty with the given webapp. + * jetty with the given webapp. If you do not configure the "webApp" element, then + * the goal will default to using the war of the webapp project. *

*

* This goal is designed to be bound to a build phase, and NOT to be run at the @@ -43,6 +44,10 @@ import org.eclipse.jetty.util.StringUtil; * This goal is useful e.g. for launching a web app in Jetty as a target for unit-tested * HTTP client components via binding to the test-integration build phase. *

+ *

+ * You can configure this goal to run the webapp either in-process with maven, or + * forked into a new process, or deployed into a jetty distribution. + *

*/ @Mojo(name = "start-war", requiresDependencyResolution = ResolutionScope.RUNTIME) public class JettyStartWarMojo extends AbstractWebAppMojo @@ -92,7 +97,9 @@ public class JettyStartWarMojo extends AbstractWebAppMojo try { forker = newJettyForker(); - forker.setWaitForChild(false); //we never wait for child + forker.setWaitForChild(false); //we never wait for child to finish + forker.setMaxChildStartChecks(maxChildStartChecks); + forker.setMaxChildStartCheckMs(maxChildStartCheckMs); forker.setJettyOutputFile(getJettyOutputFile("jetty-start-war.out")); forker.start(); //forks jetty instance @@ -112,7 +119,9 @@ public class JettyStartWarMojo extends AbstractWebAppMojo try { distroForker = newJettyDistroForker(); - distroForker.setWaitForChild(false); //never wait for child + distroForker.setWaitForChild(false); //never wait for child tofinish + distroForker.setMaxChildStartCheckMs(maxChildStartCheckMs); + distroForker.setMaxChildStartChecks(maxChildStartChecks); distroForker.setJettyOutputFile(getJettyOutputFile("jetty-start-war.out")); distroForker.start(); //forks a jetty distro }