Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compile errors since updates to workspace mechanic in April 2014. #141

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
Expand All @@ -14,12 +13,13 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;

import com.google.eclipse.mechanic.DirectoryIteratingTaskScanner;
import com.google.eclipse.mechanic.IResourceTaskProvider;
import com.google.eclipse.mechanic.IResourceTaskReference;
import com.google.eclipse.mechanic.ListCollector;
import com.google.eclipse.mechanic.ResourceTaskScanner;
import com.google.eclipse.mechanic.TaskCollector;

public class ImportProjectTaskScanner extends DirectoryIteratingTaskScanner {
public class ImportProjectTaskScanner extends ResourceTaskScanner {
private static final Logger log = Logger.getLogger(ImportProjectsTask.class.getName());

public ImportProjectTaskScanner() {
Expand All @@ -29,8 +29,13 @@ public ImportProjectTaskScanner() {
public void scan(IResourceTaskProvider source, TaskCollector collector) {
Pattern variablePattern = Pattern.compile("^#\\s*@(\\S+)\\s+(.*)");

for (Iterator<IResourceTaskReference> iterator = source.getTaskReferences(".proj").iterator(); iterator.hasNext();) {
IResourceTaskReference ref = iterator.next();
// based on example scanner at https://github.com/alfsch/workspacemechanic/
// source folder: parent/bundles/com.google.eclipse.mechanic/src/
// source: com/google/eclipse/mechanic/internal/PreferenceFileTaskScanner.java

ListCollector<IResourceTaskReference> taskCollector = ListCollector.create();
source.collectTaskReferences(".proj", taskCollector);
for (IResourceTaskReference ref : taskCollector.get()) {
File projectFile = ref.asFile();
try {
BufferedReader br = new BufferedReader(new FileReader(projectFile));
Expand Down Expand Up @@ -68,7 +73,7 @@ else if (line.startsWith("#")) {
}
}

collector.add(new ImportProjectsTask(id, title, description, importPaths, reconcile));
collector.collect(new ImportProjectsTask(id, title, description, importPaths, reconcile));
}
finally {
br.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;

import com.google.eclipse.mechanic.CompositeTask;

Expand All @@ -41,7 +41,6 @@ public ImportProjectsTask(String id, String title, String description, List<IPat
_reconcileProjects = reconcileProjects;
}

@Override
public String getId() {
return "ImportProjectsTask-" + _id;
}
Expand Down Expand Up @@ -129,9 +128,9 @@ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
for (IProjectDescription projectDescription : projectDescriptions) {
try {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectDescription.getName());
monitor.beginTask("Importing " + project.getName() + " ...", 100);
project.create(projectDescription, new SubProgressMonitor(monitor, 30));
project.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(monitor, 70));
SubMonitor subMonitor = SubMonitor.convert(monitor, "Importing " + project.getName() + " ...", 100);
project.create(projectDescription, subMonitor.split(30));
project.open(IResource.BACKGROUND_REFRESH, subMonitor.split(70));
}
catch (Throwable t) {
System.out.println("ImportProjectsTask.run: " + t.getMessage());
Expand Down