Issue #1743 Field and method names; remove scanTargets

Signed-off-by: Jan Bartel <janb@webtide.com>
This commit is contained in:
Jan Bartel 2019-11-06 11:30:47 +11:00
parent 9839e35977
commit ee7f860a2e
6 changed files with 59 additions and 49 deletions

View File

@ -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)

View File

@ -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 &lt;scope&gt;provided&lt;/scope&gt;
* 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<File> scanTargets;
/**
* List of directories with ant-style &lt;include&gt; and &lt;exclude&gt; patterns
* for extra targets to periodically scan for changes. Can be used instead of,
* or in conjunction with &lt;scanTargets&gt;.Optional.
* for extra targets to periodically scan for changes.Optional.
*/
@Parameter
protected List<ScanTargetPattern> 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)
{

View File

@ -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.
* <p>
@ -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&gt; at the command line to manually control redeployment.
* Alternatively, you can configure the plugin to wait for an &lt;enter&gt; at the command line to manually control redeployment.
* <p>
* 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());

View File

@ -44,7 +44,10 @@ import org.eclipse.jetty.util.StringUtil;
* <p>
* You may also specify the location of a jetty.xml file whose contents will be applied before any plugin configuration.
* </p>
* Runs jetty on a war file
* <p>
* 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.
* </p>
*/
@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()
{

View File

@ -34,6 +34,10 @@ import org.apache.maven.plugins.annotations.ResolutionScope;
* <p>
* This goal will NOT scan for changes in either the webapp project or any scanTargets or scanTargetPatterns.
* </p>
* <p>
* 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.
* </p>
*/
@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
}

View File

@ -29,10 +29,11 @@ import org.eclipse.jetty.util.StringUtil;
* to be used with a project of packaging type "war".
* </p>
* <p>
* 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.
* </p>
* <p>
* 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.
* </p>
* <p>
* 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.
* </p>
*/
@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
}