Merge remote-tracking branch 'origin/master' into jetty-9.1
This commit is contained in:
commit
a64319b9b1
|
@ -74,6 +74,10 @@ import org.eclipse.jetty.util.IO;
|
|||
*/
|
||||
public class JettyRunForkedMojo extends AbstractMojo
|
||||
{
|
||||
public static final String DEFAULT_WEBAPP_SRC = "src"+File.separator+"main"+File.separator+"webapp";
|
||||
public static final String FAKE_WEBAPP = "webapp-tmp";
|
||||
|
||||
|
||||
public String PORT_SYSPROPERTY = "jetty.port";
|
||||
|
||||
/**
|
||||
|
@ -421,7 +425,18 @@ public class JettyRunForkedMojo extends AbstractMojo
|
|||
}
|
||||
|
||||
//sort out base dir of webapp
|
||||
if (webAppSourceDirectory != null)
|
||||
if (webAppSourceDirectory == null || !webAppSourceDirectory.exists())
|
||||
{
|
||||
webAppSourceDirectory = new File (project.getBasedir(), DEFAULT_WEBAPP_SRC);
|
||||
if (!webAppSourceDirectory.exists())
|
||||
{
|
||||
//try last resort of making a fake empty dir
|
||||
File target = new File(project.getBuild().getDirectory());
|
||||
webAppSourceDirectory = new File(target, FAKE_WEBAPP);
|
||||
if (!webAppSourceDirectory.exists())
|
||||
webAppSourceDirectory.mkdirs();
|
||||
}
|
||||
}
|
||||
props.put("base.dir", webAppSourceDirectory.getAbsolutePath());
|
||||
|
||||
//sort out the resource base directories of the webapp
|
||||
|
|
|
@ -68,6 +68,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
|||
public class JettyRunMojo extends AbstractJettyMojo
|
||||
{
|
||||
public static final String DEFAULT_WEBAPP_SRC = "src"+File.separator+"main"+File.separator+"webapp";
|
||||
public static final String FAKE_WEBAPP = "webapp-tmp";
|
||||
|
||||
|
||||
|
||||
|
@ -182,9 +183,18 @@ public class JettyRunMojo extends AbstractJettyMojo
|
|||
{
|
||||
if ((webAppSourceDirectory == null) || !webAppSourceDirectory.exists())
|
||||
{
|
||||
File defaultWebAppSrcDir = new File (project.getBasedir(), DEFAULT_WEBAPP_SRC);
|
||||
getLog().info("webAppSourceDirectory"+(webAppSourceDirectory == null ? " not set." : " does not exist.")+" Defaulting to "+defaultWebAppSrcDir.getAbsolutePath());
|
||||
webAppSourceDirectory = defaultWebAppSrcDir;
|
||||
getLog().info("webAppSourceDirectory"+(webAppSourceDirectory == null ? " not set." : (webAppSourceDirectory.getAbsolutePath()+" does not exist."))+" Trying "+DEFAULT_WEBAPP_SRC);
|
||||
webAppSourceDirectory = new File (project.getBasedir(), DEFAULT_WEBAPP_SRC);
|
||||
if (!webAppSourceDirectory.exists())
|
||||
{
|
||||
getLog().info("webAppSourceDirectory "+webAppSourceDirectory.getAbsolutePath()+" does not exist. Trying "+project.getBuild().getDirectory()+File.separator+FAKE_WEBAPP);
|
||||
|
||||
//try last resort of making a fake empty dir
|
||||
File target = new File(project.getBuild().getDirectory());
|
||||
webAppSourceDirectory = new File(target, FAKE_WEBAPP);
|
||||
if (!webAppSourceDirectory.exists())
|
||||
webAppSourceDirectory.mkdirs();
|
||||
}
|
||||
}
|
||||
else
|
||||
getLog().info( "Webapp source directory = " + webAppSourceDirectory.getCanonicalPath());
|
||||
|
@ -504,6 +514,7 @@ public class JettyRunMojo extends AbstractJettyMojo
|
|||
{
|
||||
getLog().info("Reconfiguring scanner after change to pom.xml ...");
|
||||
scanList.clear();
|
||||
if (webApp.getDescriptor() != null)
|
||||
scanList.add(new File(webApp.getDescriptor()));
|
||||
if (webApp.getJettyEnvXml() != null)
|
||||
scanList.add(new File(webApp.getJettyEnvXml()));
|
||||
|
@ -599,7 +610,7 @@ public class JettyRunMojo extends AbstractJettyMojo
|
|||
|
||||
for (Artifact a:warArtifacts)
|
||||
{
|
||||
if (overlayMatchesArtifact (o, a))
|
||||
if (o.matchesArtifact (a.getGroupId(), a.getArtifactId(), a.getClassifier()))
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
@ -607,22 +618,4 @@ public class JettyRunMojo extends AbstractJettyMojo
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param o
|
||||
* @param a
|
||||
* @return
|
||||
*/
|
||||
protected boolean overlayMatchesArtifact(OverlayConfig o, Artifact a)
|
||||
{
|
||||
if (((o.getGroupId() == null && a.getGroupId() == null) || (o.getGroupId() != null && o.getGroupId().equals(a.getGroupId())))
|
||||
&& ((o.getArtifactId() == null && a.getArtifactId() == null) || (o.getArtifactId() != null && o.getArtifactId().equals(a.getArtifactId())))
|
||||
&& ((o.getClassifier() == null) || (o.getClassifier().equals(a.getClassifier()))))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -169,18 +169,20 @@ public class MavenWebInfConfiguration extends WebInfConfiguration
|
|||
for (Overlay o:jwac.getOverlays())
|
||||
{
|
||||
//can refer to the current project in list of overlays for ordering purposes
|
||||
if (o.getConfig() != null && o.getConfig().isCurrentProject())
|
||||
if (o.getConfig() != null && o.getConfig().isCurrentProject() && _originalResourceBase.exists())
|
||||
{
|
||||
resourceBaseCollection.add(_originalResourceBase);
|
||||
LOG.info("Adding virtual project to resource base list");
|
||||
continue;
|
||||
}
|
||||
|
||||
Resource unpacked = unpackOverlay(jwac,o);
|
||||
_unpackedOverlayResources.add(unpacked); //remember the unpacked overlays for later so we can delete the tmp files
|
||||
resourceBaseCollection.add(unpacked); //add in the selectively unpacked overlay in the correct order to the webapps resource base
|
||||
LOG.info("Adding "+unpacked+" to resource base list");
|
||||
}
|
||||
|
||||
if (!resourceBaseCollection.contains(_originalResourceBase))
|
||||
if (!resourceBaseCollection.contains(_originalResourceBase) && _originalResourceBase.exists())
|
||||
{
|
||||
if (jwac.getBaseAppFirst())
|
||||
{
|
||||
|
@ -273,33 +275,4 @@ public class MavenWebInfConfiguration extends WebInfConfiguration
|
|||
LOG.info("Unpacked overlay: "+overlay+" to "+unpackedOverlay);
|
||||
return unpackedOverlay;
|
||||
}
|
||||
|
||||
protected Artifact getArtifactForOverlay (OverlayConfig o, List<Artifact> warArtifacts)
|
||||
{
|
||||
if (o == null || warArtifacts == null || warArtifacts.isEmpty())
|
||||
return null;
|
||||
|
||||
for (Artifact a:warArtifacts)
|
||||
{
|
||||
if (overlayMatchesArtifact (o, a))
|
||||
{
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected boolean overlayMatchesArtifact(OverlayConfig o, Artifact a)
|
||||
{
|
||||
if ((o.getGroupId() == null && a.getGroupId() == null) || (o.getGroupId() != null && o.getGroupId().equals(a.getGroupId())))
|
||||
{
|
||||
if ((o.getArtifactId() == null && a.getArtifactId() == null) || (o.getArtifactId() != null && o.getArtifactId().equals(a.getArtifactId())))
|
||||
{
|
||||
if ((o.getClassifier() == null) || (o.getClassifier().equals(a.getClassifier())))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
@ -264,6 +265,44 @@ public class OverlayConfig
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if this overlay configuration matches an Artifact's info
|
||||
*
|
||||
* @param gid Artifact groupId
|
||||
* @param aid Artifact artifactId
|
||||
* @param cls Artifact classifier
|
||||
* @return
|
||||
*/
|
||||
public boolean matchesArtifact (String gid, String aid, String cls)
|
||||
{
|
||||
if (((getGroupId() == null && gid == null) || (getGroupId() != null && getGroupId().equals(gid)))
|
||||
&&((getArtifactId() == null && aid == null) || (getArtifactId() != null && getArtifactId().equals(aid)))
|
||||
&&((getClassifier() == null) || (getClassifier().equals(cls))))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this overlay configuration matches an Artifact's info
|
||||
*
|
||||
* @param gid
|
||||
* @param aid
|
||||
* @return
|
||||
*/
|
||||
public boolean matchesArtifact (String gid, String aid)
|
||||
{
|
||||
if (((getGroupId() == null && gid == null) || (getGroupId() != null && getGroupId().equals(gid)))
|
||||
&&((getArtifactId() == null && aid == null) || (getArtifactId() != null && getArtifactId().equals(aid))))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer strbuff = new StringBuffer();
|
||||
|
|
|
@ -458,13 +458,9 @@ public class Starter
|
|||
while(itor.hasNext() && war == null)
|
||||
{
|
||||
Artifact a = itor.next();
|
||||
if (((c.getGroupId() == null && a.gid == null) || (c.getGroupId() != null && c.getGroupId().equals(a.gid)))
|
||||
&& ((c.getArtifactId() == null && a.aid == null) || (c.getArtifactId() != null && c.getArtifactId().equals(a.aid)))
|
||||
&& ((c.getClassifier() == null) || (c.getClassifier().equals(a.aid))))
|
||||
{
|
||||
if (c.matchesArtifact(a.gid, a.aid, null))
|
||||
war = a;
|
||||
}
|
||||
}
|
||||
return war;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue