use of org.mortbay.resource.Resource in project gradle by gradle.
the class JettyRun method getDependencyFiles.
@Internal
private Set<File> getDependencyFiles() {
List<Resource> overlays = new ArrayList<Resource>();
Set<File> dependencies = getClasspath().getFiles();
LOGGER.debug("Adding dependencies {} for WEB-INF/lib ", dependencies);
// }
if (!overlays.isEmpty()) {
try {
Resource resource = getWebAppConfig().getBaseResource();
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().toURI().toURL());
for (int i = 1; i < size; i++) {
resources[i] = overlays.get(i - 1);
LOGGER.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; i < size; i++) {
resources[i] = overlays.get(i - old.length);
LOGGER.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++) {
resources[i] = overlays.get(i - 1);
LOGGER.info("Adding overlay: " + resources[i]);
}
rc.setResources(resources);
}
}
getWebAppConfig().setBaseResource(rc);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return dependencies;
}
Aggregations