470505 jetty-maven-plugin JettyWebAppContext#setQuickStartWebDescriptor should accept a Maven-friendly type

This commit is contained in:
Jan Bartel 2015-07-08 17:09:41 +10:00
parent 7fbf512b17
commit 77bdf84f5c
3 changed files with 46 additions and 32 deletions

View File

@ -73,16 +73,7 @@ public class JettyEffectiveWebXml extends JettyRunMojo
{
//Only do enough setup to be able to produce a quickstart-web.xml file
//if the user didn't nominate a file to generate into, pick the name and
//make sure that it is deleted on exit
if (effectiveWebXml == null)
{
deleteOnExit = true;
effectiveWebXml = new File(target, "effective-web.xml");
effectiveWebXml.deleteOnExit();
}
Resource descriptor = Resource.newResource(effectiveWebXml);
QueuedThreadPool tpool = null;
@ -104,13 +95,27 @@ public class JettyEffectiveWebXml extends JettyRunMojo
webApp.setCopyWebDir(false);
webApp.setCopyWebInf(false);
webApp.setGenerateQuickStart(true);
if (!effectiveWebXml.getParentFile().exists())
effectiveWebXml.getParentFile().mkdirs();
if (!effectiveWebXml.exists())
effectiveWebXml.createNewFile();
webApp.setQuickStartWebDescriptor(descriptor);
//if the user didn't nominate a file to generate into, pick the name and
//make sure that it is deleted on exit
if (webApp.getQuickStartWebDescriptor() == null)
{
if (effectiveWebXml == null)
{
deleteOnExit = true;
effectiveWebXml = new File(target, "effective-web.xml");
effectiveWebXml.deleteOnExit();
}
Resource descriptor = Resource.newResource(effectiveWebXml);
if (!effectiveWebXml.getParentFile().exists())
effectiveWebXml.getParentFile().mkdirs();
if (!effectiveWebXml.exists())
effectiveWebXml.createNewFile();
webApp.setQuickStartWebDescriptor(descriptor);
}
ServerSupport.addWebApplication(server, webApp);
@ -142,7 +147,7 @@ public class JettyEffectiveWebXml extends JettyRunMojo
try
{
//just show the result in the log
getLog().info(IO.toString(descriptor.getInputStream()));
getLog().info(IO.toString(webApp.getQuickStartWebDescriptor().getInputStream()));
}
catch (IOException e)
{

View File

@ -233,10 +233,7 @@ public class JettyRunForkedMojo extends JettyRunMojo
{
//Only do enough setup to be able to produce a quickstart-web.xml file to
//pass onto the forked process to run
if (forkWebXml == null)
forkWebXml = new File (target, "fork-web.xml");
try
{
printSystemProperties();
@ -253,21 +250,27 @@ public class JettyRunForkedMojo extends JettyRunMojo
//copy the base resource as configured by the plugin
originalBaseResource = webApp.getBaseResource();
//get the original persistance setting
originalPersistTemp = webApp.isPersistTempDirectory();
//set the webapp up to do very little other than generate the quickstart-web.xml
webApp.setCopyWebDir(false);
webApp.setCopyWebInf(false);
webApp.setGenerateQuickStart(true);
if (!forkWebXml.getParentFile().exists())
forkWebXml.getParentFile().mkdirs();
if (!forkWebXml.exists())
forkWebXml.createNewFile();
webApp.setQuickStartWebDescriptor(Resource.newResource(forkWebXml));
if (webApp.getQuickStartWebDescriptor() == null)
{
if (forkWebXml == null)
forkWebXml = new File (target, "fork-web.xml");
if (!forkWebXml.getParentFile().exists())
forkWebXml.getParentFile().mkdirs();
if (!forkWebXml.exists())
forkWebXml.createNewFile();
webApp.setQuickStartWebDescriptor(Resource.newResource(forkWebXml));
}
//add webapp to our fake server instance
ServerSupport.addWebApplication(server, webApp);

View File

@ -243,7 +243,13 @@ public class JettyWebAppContext extends WebAppContext
}
/* ------------------------------------------------------------ */
public void setQuickStartWebDescriptor (Resource quickStartWebXml)
public void setQuickStartWebDescriptor (String quickStartWebXml) throws Exception
{
setQuickStartWebDescriptor(Resource.newResource(quickStartWebXml));
}
/* ------------------------------------------------------------ */
protected void setQuickStartWebDescriptor (Resource quickStartWebXml)
{
_quickStartWebXml = quickStartWebXml;
}