Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Bartel2015-04-29 20:44:44 -0400
committerJan Bartel2015-04-29 20:44:44 -0400
commite30c05cc2b3ad9dc9c17ab99f746f67af12f3e20 (patch)
tree1fda04005b28a8d7ee1f4d86fc6e540bd2f30582 /jetty-maven-plugin
parent15eb1081e90c10267a8c9cdac1756e8ddeca98bf (diff)
parent25474ff7ab41a93d3c89de7ddc3f04b384c51762 (diff)
downloadorg.eclipse.jetty.project-e30c05cc2b3ad9dc9c17ab99f746f67af12f3e20.tar.gz
org.eclipse.jetty.project-e30c05cc2b3ad9dc9c17ab99f746f67af12f3e20.tar.xz
org.eclipse.jetty.project-e30c05cc2b3ad9dc9c17ab99f746f67af12f3e20.zip
Merge remote-tracking branch 'origin/jetty-9.2.x'
Conflicts: tests/test-integration/src/test/java/org/eclipse/jetty/test/support/TestableJettyServer.java tests/test-integration/src/test/resources/BIOHttp.xml tests/test-integration/src/test/resources/BIOHttps.xml tests/test-integration/src/test/resources/NIOHttp.xml tests/test-integration/src/test/resources/NIOHttps.xml
Diffstat (limited to 'jetty-maven-plugin')
-rw-r--r--jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyEffectiveWebXml.java3
-rw-r--r--jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java60
-rw-r--r--jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenQuickStartConfiguration.java40
-rw-r--r--jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java24
-rw-r--r--jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java18
5 files changed, 93 insertions, 52 deletions
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyEffectiveWebXml.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyEffectiveWebXml.java
index 3b3883077f..7d454444c4 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyEffectiveWebXml.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyEffectiveWebXml.java
@@ -71,8 +71,7 @@ public class JettyEffectiveWebXml extends JettyRunMojo
@Override
public void startJetty() throws MojoExecutionException
{
- //Only do enough setup to be able to produce a quickstart-web.xml file to
- //pass onto the forked process to run
+ //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
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java
index be33e9bf1b..b6a1e4456e 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java
@@ -146,6 +146,7 @@ public class JettyRunForkedMojo extends JettyRunMojo
private Resource originalBaseResource;
+ private boolean originalPersistTemp;
/**
@@ -253,6 +254,9 @@ 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);
@@ -275,8 +279,11 @@ public class JettyRunForkedMojo extends JettyRunMojo
tpool.start();
else
webApp.setAttribute(AnnotationConfiguration.MULTI_THREADED, Boolean.FALSE.toString());
+
+ //leave everything unpacked for the forked process to use
+ webApp.setPersistTempDirectory(true);
- webApp.start(); //just enough to generate the quickstart
+ webApp.start(); //just enough to generate the quickstart
//save config of the webapp BEFORE we stop
File props = prepareConfiguration();
@@ -470,31 +477,23 @@ public class JettyRunForkedMojo extends JettyRunMojo
//tmp dir
props.put("tmp.dir", webApp.getTempDirectory().getAbsolutePath());
- props.put("tmp.dir.persist", Boolean.toString(webApp.isPersistTempDirectory()));
-
- //resource bases - these are what has been configured BEFORE the webapp started and
- //potentially reordered them and included any resources from META-INF
- if (originalBaseResource != null)
- {
- StringBuffer rb = new StringBuffer();
- if (originalBaseResource instanceof ResourceCollection)
- {
- ResourceCollection resources = ((ResourceCollection)originalBaseResource);
- for (Resource r:resources.getResources())
- {
- if (rb.length() > 0) rb.append(",");
- rb.append(r.toString());
- }
- }
- else
- rb.append(originalBaseResource.toString());
-
- props.put("base.dirs", rb.toString());
- }
+ props.put("tmp.dir.persist", Boolean.toString(originalPersistTemp));
- //sort out the resource base directories of the webapp
- props.put("base.first", Boolean.toString(webApp.getBaseAppFirst()));
+ //send over the original base resources before any overlays were added
+ if (originalBaseResource instanceof ResourceCollection)
+ props.put("base.dirs.orig", toCSV(((ResourceCollection)originalBaseResource).getResources()));
+ else
+ props.put("base.dirs.orig", originalBaseResource.toString());
+ //send over the calculated resource bases that includes unpacked overlays, but none of the
+ //meta-inf resources
+ Resource postOverlayResources = (Resource)webApp.getAttribute(MavenWebInfConfiguration.RESOURCE_BASES_POST_OVERLAY);
+ if (postOverlayResources instanceof ResourceCollection)
+ props.put("base.dirs", toCSV(((ResourceCollection)postOverlayResources).getResources()));
+ else
+ props.put("base.dirs", postOverlayResources.toString());
+
+
//web-inf classes
if (webApp.getClasses() != null)
{
@@ -751,4 +750,17 @@ public class JettyRunForkedMojo extends JettyRunMojo
}
return strbuff.toString();
}
+
+ private String toCSV (Resource[] resources)
+ {
+ StringBuffer rb = new StringBuffer();
+
+ for (Resource r:resources)
+ {
+ if (rb.length() > 0) rb.append(",");
+ rb.append(r.toString());
+ }
+
+ return rb.toString();
+ }
}
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenQuickStartConfiguration.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenQuickStartConfiguration.java
index 5375b515af..c0212dc293 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenQuickStartConfiguration.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenQuickStartConfiguration.java
@@ -23,9 +23,11 @@ import java.io.File;
import java.util.Iterator;
import org.eclipse.jetty.quickstart.QuickStartConfiguration;
+import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.resource.Resource;
+import org.eclipse.jetty.util.resource.ResourceCollection;
import org.eclipse.jetty.webapp.WebAppClassLoader;
import org.eclipse.jetty.webapp.WebAppContext;
@@ -54,6 +56,20 @@ public class MavenQuickStartConfiguration extends QuickStartConfiguration
return _quickStartWebXml;
}
+ @Override
+ public void preConfigure(WebAppContext context) throws Exception
+ {
+ //check that webapp is suitable for quick start
+ if (context.getBaseResource() == null)
+ throw new IllegalStateException ("No location for webapp");
+
+
+ //look for quickstart-web.xml in WEB-INF of webapp
+ Resource quickStartWebXml = getQuickStartWebXml(context);
+ LOG.debug("quickStartWebXml={}",quickStartWebXml);
+
+ context.getMetaData().setWebXml(quickStartWebXml);
+ }
@Override
@@ -89,4 +105,28 @@ public class MavenQuickStartConfiguration extends QuickStartConfiguration
context.setServerClasses( newServerClasses );
}
+ @Override
+ public void deconfigure(WebAppContext context) throws Exception
+ {
+ //if we're not persisting the temp dir, get rid of any overlays
+ if (!context.isPersistTempDirectory())
+ {
+ Resource originalBases = (Resource)context.getAttribute("org.eclipse.jetty.resources.originalBases");
+ String originalBaseStr = originalBases.toString();
+
+ //Iterate over all of the resource bases and ignore any that were original bases, just
+ //deleting the overlays
+ Resource res = context.getBaseResource();
+ if (res instanceof ResourceCollection)
+ {
+ for (Resource r:((ResourceCollection)res).getResources())
+ {
+ if (originalBaseStr.contains(r.toString()))
+ continue;
+ IO.delete(r.getFile());
+ }
+ }
+ }
+ }
+
}
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java
index 95803f6a55..578e15a39c 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java
@@ -25,7 +25,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Locale;
-import org.eclipse.jetty.util.IO;
+
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.resource.Resource;
@@ -46,7 +46,7 @@ public class MavenWebInfConfiguration extends WebInfConfiguration
{
private static final Logger LOG = Log.getLogger(MavenWebInfConfiguration.class);
-
+ public static final String RESOURCE_BASES_POST_OVERLAY = "org.eclipse.jetty.resource.postOverlay";
protected static int COUNTER = 0;
protected Resource _originalResourceBase;
protected List<Resource> _unpackedOverlayResources;
@@ -115,24 +115,11 @@ public class MavenWebInfConfiguration extends WebInfConfiguration
*/
public void deconfigure(WebAppContext context) throws Exception
{
- //remove the unpacked wars
- if (_unpackedOverlayResources != null && !_unpackedOverlayResources.isEmpty())
- {
- try
- {
- for (Resource r:_unpackedOverlayResources)
- {
- IO.delete(r.getFile());
- }
- }
- catch (IOException e)
- {
- LOG.ignore(e);
- }
- }
super.deconfigure(context);
//restore whatever the base resource was before we might have included overlaid wars
context.setBaseResource(_originalResourceBase);
+ //undo the setting of the overlayed resources
+ context.removeAttribute(RESOURCE_BASES_POST_OVERLAY);
}
@@ -190,9 +177,10 @@ public class MavenWebInfConfiguration extends WebInfConfiguration
resourceBaseCollection.add(_originalResourceBase);
}
}
-
jwac.setBaseResource(new ResourceCollection(resourceBaseCollection.toArray(new Resource[resourceBaseCollection.size()])));
}
+
+ jwac.setAttribute(RESOURCE_BASES_POST_OVERLAY, jwac.getBaseResource());
}
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java
index 20ac0a64c3..c47ec2c4a2 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java
@@ -192,21 +192,23 @@ public class Starter
str = (String)props.getProperty("tmp.dir.persist");
if (str != null)
webApp.setPersistTempDirectory(Boolean.valueOf(str));
-
- // - the base directories
+
+ //Get the calculated base dirs which includes the overlays
str = (String)props.getProperty("base.dirs");
if (str != null && !"".equals(str.trim()))
{
ResourceCollection bases = new ResourceCollection(str.split(","));
- webApp.setWar(bases.getResources()[0].toString());
+ webApp.setWar(null);
webApp.setBaseResource(bases);
}
-
- // - put virtual webapp base resource first on resource path or not
- str = (String)props.getProperty("base.first");
+
+ //Get the original base dirs without the overlays
+ str = (String)props.get("base.dirs.orig");
if (str != null && !"".equals(str.trim()))
- webApp.setBaseAppFirst(Boolean.valueOf(str));
-
+ {
+ ResourceCollection bases = new ResourceCollection(str.split(","));
+ webApp.setAttribute ("org.eclipse.jetty.resources.originalBases", bases);
+ }
//For overlays
str = (String)props.getProperty("maven.war.includes");

Back to the top