Bug 53122 [Actions] Rebuild Project does not auto-save files
bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/BuildAction.java
HashSet toBuild = new HashSet();
        for (Iterator it = resourceCollection.iterator(); it.hasNext();)
            addAllProjects((IProject) it.next(), toBuild);
        
        if (toBuild.size() < 2)
            return resourceCollection;
        
        String[] orderedNames = ResourcesPlugin.getWorkspace().getDescription()
                .getBuildOrder();
        if (orderedNames != null) {
            List orderedProjects = new ArrayList(toBuild.size());
            IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
            for (int i = 0; i < orderedNames.length; i++) {
                IProject handle = root.getProject(orderedNames[i]);
                if (toBuild.contains(handle)) {
                    orderedProjects.add(handle);
                    toBuild.remove(handle);
                }
            }
            
            orderedProjects.addAll(toBuild);
            return orderedProjects;
        }
        
        IProject[] projects = new IProject[toBuild.size()];
        projects = (IProject[]) toBuild.toArray(projects);
        IWorkspace.ProjectOrder po = ResourcesPlugin.getWorkspace()
                .computeProjectOrder(projects);
        ArrayList orderedProjects = new ArrayList();
        orderedProjects.addAll(Arrays.asList(po.projects));