// Include runtime and compile time libraries, and possibly test libs too
if(artifact.getType().equals("war"))
{
try
{
Resource r = Resource.newResource("jar:" + artifact.getFile().toURL().toString() + "!/");
overlays.add(r);
getExtraScanTargets().add(artifact.getFile());
}
catch(Exception e)
{
throw new RuntimeException(e);
}
continue;
}
if (((!Artifact.SCOPE_PROVIDED.equals(artifact.getScope())) && (!Artifact.SCOPE_TEST.equals( artifact.getScope())))
||
(useTestClasspath && Artifact.SCOPE_TEST.equals( artifact.getScope())))
{
dependencyFiles.add(artifact.getFile());
getLog().debug( "Adding artifact " + artifact.getFile().getName() + " for WEB-INF/lib " );
}
}
if(!overlays.isEmpty() && !isEqual(overlays, _overlays))
{
try
{
Resource resource = _overlays==null ? webAppConfig.getBaseResource() : null;
ResourceCollection rc = new ResourceCollection();
if(resource==null)
{
// nothing configured, so we automagically enable the overlays
int size = overlays.size()+1;
Resource[] resources = new Resource[size];
resources[0] = Resource.newResource(getWebAppSourceDirectory().toURL());
for(int i=1; i<size; i++)
{
resources[i] = (Resource)overlays.get(i-1);
getLog().info("Adding overlay: " + resources[i]);
}
rc.setResources(resources);
}
else
{
if(resource instanceof ResourceCollection)
{
// there was a preconfigured ResourceCollection ... append the artifact wars
Resource[] old = ((ResourceCollection)resource).getResources();
int size = old.length + overlays.size();
Resource[] resources = new Resource[size];
System.arraycopy(old, 0, resources, 0, old.length);
for(int i=old.length,j=0; i<size; i++,j++)
{
resources[i] = (Resource)overlays.get(j);
getLog().info("Adding overlay: " + resources[i]);
}
rc.setResources(resources);
}
else
{
// baseResource was already configured w/c could be src/main/webapp
if(!resource.isDirectory() && String.valueOf(resource.getFile()).endsWith(".war"))
{
// its a war
resource = Resource.newResource("jar:" + resource.getURL().toString() + "!/");
}
int size = overlays.size()+1;
Resource[] resources = new Resource[size];
resources[0] = resource;
for(int i=1; i<size; i++)