IProgressMonitor monitor) throws CoreException, InterruptedException, FactoryException {
if (Utils.isEmpty(resources)) {
throw new IllegalArgumentException("Resources cannot be null");
}
ProjectPackageList projectPackageList = getProjectPackageListInstance();
projectPackageList.setProject(resources.get(0).getProject());
for (IResource resource : resources) {
if (resource.getType() == IResource.PROJECT) {
projectPackageList = getProjectContents(resource.getProject(), monitor);
} else if (isSourceFolder(resource)) {
projectPackageList = getProjectContents(resource.getProject(), monitor);
} else if (isComponentFolder(resource)) {
ComponentList componentList = getComponentsForComponentFolder((IFolder) resource, true, true);
projectPackageList.addComponents(componentList, false);
} else if (isSubComponentFolder(resource)) {
ComponentList componentList = getComponentsForSubComponentFolder((IFolder) resource, true);
projectPackageList.addComponents(componentList, false);
} else if (isManagedFile(resource)) { //if we're in a force.com project. "isManaged" is misleading.
Component component = getComponentFactory().getComponentFromFile((IFile) resource);
projectPackageList.addComponent(component, true);
// add dependent or associated components such as folder metadata component if component is sub-folder component
if (includeAssociated) {
ComponentList componentList = getComponentFactory().getAssociatedComponents(component);
if (Utils.isNotEmpty(componentList)) {
projectPackageList.addComponents(componentList, false);
}
}
}
}
//filter out any built in folder stuff.
// if component subfolder is built-in subfolder, then this subfolder will be available in dest org (also this subfolder is not retrievable/deployable)
// so no need to add subfolder component to deploy list. W-623512
ComponentList allComponentsList = getComponentFactory().getComponentListInstance();
allComponentsList.addAll(projectPackageList.getAllComponents());
for (Component component : allComponentsList) {
if (Utils.isNotEmpty(component.getBuiltInSubFolders())) {
for (String builtInSubFolder : component.getBuiltInSubFolders()) {
if (builtInSubFolder.equals(component.getName())) {
projectPackageList.removeComponent(component);
}
}
}
}