diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-03-23 21:22:52 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-03-23 21:22:52 +0000 |
commit | 497e8dc38cfdbab4b754684f2cea5c74a5e405e4 (patch) | |
tree | 3062ec7a094d8585c2b3ab7dbe4a3033715fae6b | |
parent | 777ecc0a233137e542d4ace2496efd997e79826b (diff) |
Schedule the target definition job
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@926790 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | sandbox/rfeng/eclipse-workspace/src/main/java/org/apache/tuscany/eclipse/workspace/WorkspaceConfigurator.java | 64 |
1 files changed, 54 insertions, 10 deletions
diff --git a/sandbox/rfeng/eclipse-workspace/src/main/java/org/apache/tuscany/eclipse/workspace/WorkspaceConfigurator.java b/sandbox/rfeng/eclipse-workspace/src/main/java/org/apache/tuscany/eclipse/workspace/WorkspaceConfigurator.java index 0c548de8e8..ca1fbfa412 100644 --- a/sandbox/rfeng/eclipse-workspace/src/main/java/org/apache/tuscany/eclipse/workspace/WorkspaceConfigurator.java +++ b/sandbox/rfeng/eclipse-workspace/src/main/java/org/apache/tuscany/eclipse/workspace/WorkspaceConfigurator.java @@ -35,7 +35,6 @@ import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceVisitor; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.IncrementalProjectBuilder; @@ -45,6 +44,9 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.IJobChangeListener; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.equinox.app.IApplication; import org.eclipse.equinox.app.IApplicationContext; import org.eclipse.jdt.core.JavaCore; @@ -66,6 +68,7 @@ public class WorkspaceConfigurator implements IApplication { private static final String M2_REPO = "M2_REPO"; private IWorkspace workspace; + private final Object lock = new Object(); public Object start(final IApplicationContext appcontext) throws Exception { IProgressMonitor monitor = createMonitor(); @@ -74,12 +77,15 @@ public class WorkspaceConfigurator implements IApplication { configureJDT(); setM2REPOClassPathVariable(args, monitor); setTargetPlatform(args, monitor); + synchronized (lock) { + lock.wait(60000); + } configureWorkspace(args, monitor); return EXIT_OK; } - private void setTargetPlatform(String args[], IProgressMonitor monitor) throws FileNotFoundException, CoreException, - ParserConfigurationException, SAXException, IOException { + private void setTargetPlatform(String args[], IProgressMonitor monitor) throws FileNotFoundException, + CoreException, ParserConfigurationException, SAXException, IOException { String targetFile = getOptionValue(args, TARGET_DEFINITION); if (targetFile == null) { return; @@ -96,7 +102,39 @@ public class WorkspaceConfigurator implements IApplication { is.close(); } LoadTargetDefinitionJob job = new LoadTargetDefinitionJob(th.getTargetDefinition()); - job.run(monitor); + Job.getJobManager().cancel("LoadTargetDefinitionJob"); + job.setUser(true); + job.addJobChangeListener(new IJobChangeListener() { + + @Override + public void sleeping(IJobChangeEvent event) { + } + + @Override + public void scheduled(IJobChangeEvent event) { + } + + @Override + public void running(IJobChangeEvent event) { + } + + @Override + public void done(IJobChangeEvent event) { + print("Target platform is now configured. (" + event.getResult() + ")"); + synchronized (lock) { + lock.notifyAll(); + } + } + + @Override + public void awake(IJobChangeEvent event) { + } + + @Override + public void aboutToRun(IJobChangeEvent event) { + } + }); + job.schedule(); } private IProgressMonitor createMonitor() { @@ -143,9 +181,7 @@ public class WorkspaceConfigurator implements IApplication { sourceRoot = new File(sourceRootArg); } - if (sourceRoot != null) { - importProjects(sourceRoot, monitor); - } + configureProjects(sourceRoot, monitor); // cleanProjects(monitor); buildWorkspace(monitor); @@ -169,12 +205,13 @@ public class WorkspaceConfigurator implements IApplication { this.workspace = null; } - private void importProjects(File sourceRoot, final IProgressMonitor monitor) throws Exception { + private void configureProjects(File sourceRoot, final IProgressMonitor monitor) throws Exception { IWorkspaceRoot workspaceRoot = workspace.getRoot(); loadProjects(sourceRoot, monitor); for (IProject p : workspaceRoot.getProjects()) { + print("Refreshing project: " + p.getName()); if (!p.isOpen()) { // Open the project p.open(monitor); @@ -187,7 +224,9 @@ public class WorkspaceConfigurator implements IApplication { p.delete(false, true, monitor); } } - + + // If we set .svn to private member, the svn plugin will not bind the project + /* workspaceRoot.accept(new IResourceVisitor() { public boolean visit(IResource res) throws CoreException { @@ -200,6 +239,7 @@ public class WorkspaceConfigurator implements IApplication { return true; } }); + */ } @@ -217,6 +257,9 @@ public class WorkspaceConfigurator implements IApplication { } private void loadProjects(File sourceRoot, final IProgressMonitor monitor) throws CoreException { + if (sourceRoot == null) { + return; + } if (sourceRoot.isDirectory()) { File dotProject = new File(sourceRoot, ".project"); if (dotProject.exists() && dotProject.isFile()) { @@ -245,7 +288,8 @@ public class WorkspaceConfigurator implements IApplication { } private void buildWorkspace(IProgressMonitor monitor) throws Exception { - print("Running a full build..."); + print("Running a clean/full build..."); + workspace.build(IncrementalProjectBuilder.CLEAN_BUILD, monitor); workspace.build(IncrementalProjectBuilder.FULL_BUILD, monitor); reportErrors(); |