Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

wait properly for build to finish by running the build in the build job,

abandonning the job query concept
  • Loading branch information...
commit 4d4c4420d48f5057f80a428f4353302d9b6d97d8 1 parent 2dcc23f
@JPMoresmau authored
View
30 net.sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/BWFacade.java
@@ -213,7 +213,7 @@ public JSONArray build(BuildOptions buildOptions){
command.add("--output="+buildOptions.isOutput());
command.add("--cabaltarget="+buildOptions.getTarget().toString());
JSONArray arr=run(command,ARRAY,false);
- refreshDist();
+ refreshDist(true);
if (arr!=null && arrC!=null){
for (int a=0;a<arrC.length();a++){
try {
@@ -561,14 +561,26 @@ public void synchronize(boolean force){
}
}
- private void refreshDist(){
- IFolder fldr=getProject().getFolder(BWFacade.DIST_FOLDER);
- if (fldr!=null && fldr.exists()){
- try {
- fldr.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
- } catch (CoreException ce){
- BuildWrapperPlugin.logError(BWText.error_refreshLocal, ce);
+ private void refreshDist(boolean async){
+ Runnable r=new Runnable(){
+ @Override
+ public void run() {
+ IFolder fldr=getProject().getFolder(BWFacade.DIST_FOLDER);
+ if (fldr!=null && fldr.exists()){
+ try {
+ fldr.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ } catch (CoreException ce){
+ BuildWrapperPlugin.logError(BWText.error_refreshLocal, ce);
+ }
+ }
+
}
+ };
+ if (async){
+ new Thread(r).start();
+
+ } else {
+ r.run();
}
}
@@ -588,7 +600,7 @@ public void generateUsage(Component c,boolean returnAll){
JSONArray allPaths=arr.optJSONArray(0);
if (allPaths!=null){
if (allPaths.length()>0){
- refreshDist();
+ refreshDist(false);
}
BuildWrapperPlugin plugin=BuildWrapperPlugin.getDefault();
if (plugin!=null){
View
147 net.sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/JobFacade.java
@@ -27,6 +27,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
@@ -65,18 +66,44 @@ protected IStatus run(IProgressMonitor monitor) {
try {
notes=realFacade.build(buildOptions);
if (buildOptions.isOutput()){
- try {
- IResource res=realFacade.getProject().findMember(BWFacade.DIST_FOLDER);
- if (res!=null){
- res.refreshLocal(IResource.DEPTH_INFINITE, monitor);
- } else {
- realFacade.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
- }
- } catch (CoreException ce){
- BuildWrapperPlugin.logError(BWText.error_refreshLocal, ce);
- ce.printStackTrace();
- }
+ new Thread(new Runnable(){public void run() {
+ try {
+ IProgressMonitor monitor=new NullProgressMonitor();
+ IResource res=realFacade.getProject().findMember(BWFacade.DIST_FOLDER);
+ if (res!=null){
+ res.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ } else {
+ realFacade.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ }
+ } catch (CoreException ce){
+ BuildWrapperPlugin.logError(BWText.error_refreshLocal, ce);
+ ce.printStackTrace();
+ }
+
+ };}).start();
+
+
}
+ // do all that as build job otherwise launch start too early
+ boolean ok=realFacade.parseBuildResult(notes);
+ if (ok){
+ realFacade.closeAllProcesses(); // GHC needs to reload the changes. It can do it for source files, but not across components
+ String name=NLS.bind(BWText.job_sandbox_deps, realFacade.getProject().getName());
+ Job installJob=new Job(name) {
+
+ @Override
+ protected IStatus run(IProgressMonitor arg0) {
+ try {
+ SandboxHelper.updateUsing(realFacade);
+ } catch (CoreException ce){
+ BuildWrapperPlugin.logError(BWText.error_sandbox,ce);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ installJob.setPriority(Job.BUILD);
+ installJob.schedule();
+ }
} finally {
monitor.done();
}
@@ -93,40 +120,40 @@ public BuildJob getBuildJob(final BuildOptions buildOptions){
final BuildJob buildJob=new BuildJob(jobNamePrefix,realFacade,buildOptions);
- buildJob.addJobChangeListener(new JobChangeAdapter(){
- @Override
- public void done(IJobChangeEvent event) {
- if (event.getResult().isOK()){
- Job parseJob = new Job (jobNamePrefix) {
- protected IStatus run(IProgressMonitor arg0) {
- boolean ok=realFacade.parseBuildResult(buildJob.getNotes());
- if (ok){
- realFacade.closeAllProcesses(); // GHC needs to reload the changes. It can do it for source files, but not across components
- String name=NLS.bind(BWText.job_sandbox_deps, realFacade.getProject().getName());
- Job installJob=new Job(name) {
-
- @Override
- protected IStatus run(IProgressMonitor arg0) {
- try {
- SandboxHelper.updateUsing(realFacade);
- } catch (CoreException ce){
- BuildWrapperPlugin.logError(BWText.error_sandbox,ce);
- }
- return Status.OK_STATUS;
- }
- };
- installJob.setPriority(Job.BUILD);
- installJob.schedule();
- }
- return Status.OK_STATUS;
- };
- };
- parseJob.setRule( getProject() );
- parseJob.setPriority(Job.BUILD);
- parseJob.schedule();
- }
- }
- });
+// buildJob.addJobChangeListener(new JobChangeAdapter(){
+// @Override
+// public void done(IJobChangeEvent event) {
+// if (event.getResult().isOK()){
+// Job parseJob = new Job (jobNamePrefix) {
+// protected IStatus run(IProgressMonitor arg0) {
+// boolean ok=realFacade.parseBuildResult(buildJob.getNotes());
+// if (ok){
+// realFacade.closeAllProcesses(); // GHC needs to reload the changes. It can do it for source files, but not across components
+// String name=NLS.bind(BWText.job_sandbox_deps, realFacade.getProject().getName());
+// Job installJob=new Job(name) {
+//
+// @Override
+// protected IStatus run(IProgressMonitor arg0) {
+// try {
+// SandboxHelper.updateUsing(realFacade);
+// } catch (CoreException ce){
+// BuildWrapperPlugin.logError(BWText.error_sandbox,ce);
+// }
+// return Status.OK_STATUS;
+// }
+// };
+// installJob.setPriority(Job.BUILD);
+// installJob.schedule();
+// }
+// return Status.OK_STATUS;
+// };
+// };
+// parseJob.setRule( getProject() );
+// parseJob.setPriority(Job.BUILD);
+// parseJob.schedule();
+// }
+// }
+// });
// not needed since we put the job in a queue ourselves
// except if both synchronized and build are run concurrently
//buildJob.setRule( getProject() );
@@ -137,10 +164,20 @@ protected IStatus run(IProgressMonitor arg0) {
public void build(final BuildOptions buildOptions) {
realFacade.getBuildJobQueue().addJob(getBuildJob(buildOptions));
}
+
+ /**
+ * build without starting a new job
+ * @param buildOptions
+ * @param monitor
+ */
+ public void build(final BuildOptions buildOptions,final IProgressMonitor monitor) {
+ BuildJob bj=getBuildJob(buildOptions);
+ bj.run(monitor);
+ }
- public void synchronizeAndBuild(final boolean force,final BuildOptions buildOptions){
- Job sj=getSynchronizeJob(force,false);
- sj.addJobChangeListener(new JobChangeAdapter(){
+ public void synchronizeAndBuild(final boolean force,final BuildOptions buildOptions,final IProgressMonitor monitor){
+ /*Job sj=getSynchronizeJob(force,false);
+ /*sj.addJobChangeListener(new JobChangeAdapter(){
@Override
public void done(IJobChangeEvent event) {
if (event.getResult().isOK()){
@@ -151,7 +188,19 @@ public void done(IJobChangeEvent event) {
}
}
});
- sj.schedule();
+ sj.schedule();*/
+ realFacade.synchronize(force);
+ if (monitor!=null && monitor.isCanceled()){
+ return;
+ }
+ BuildJob bj=getBuildJob(buildOptions);
+ IStatus st=bj.run(monitor);
+ if (st.isOK()){
+ UsageThread ut=BuildWrapperPlugin.getDefault().getUsageThread();
+ if (ut!=null){
+ ut.addProject(getProject());
+ }
+ }
}
/**
View
96 net.sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/WorkspaceFacade.java
@@ -29,54 +29,54 @@ public WorkspaceFacade(BWFacade realF,IProgressMonitor monitor){
this.monitor=monitor;
}
- public void build(final BuildOptions buildOptions) {
- /*WorkspaceModifyOperation wmo=new WorkspaceModifyOperation(getProject()){
- @Override
- protected void execute(IProgressMonitor arg0) throws CoreException,
- InvocationTargetException, InterruptedException {
- realFacade.build(buildOptions);
- }
- };
- try {
- wmo.run(monitor);
- } catch (InterruptedException ie){
- // noop
- }catch (InvocationTargetException ie){
- BuildWrapperPlugin.logError(ie.getLocalizedMessage(), ie.getCause());
- }*/
-
- JobFacade jf=BuildWrapperPlugin.getJobFacade(getProject());
- if (jf!=null){
- final String jobNamePrefix = NLS.bind(BWText.job_build, getProject().getName());
-
- final BuildJob buildJob=new BuildJob(jobNamePrefix,realFacade,buildOptions);
-
- buildJob.addJobChangeListener(new JobChangeAdapter(){
- @Override
- public void done(IJobChangeEvent event) {
- if (event.getResult().isOK()){
- WorkspaceModifyOperation wmo=new WorkspaceModifyOperation(getProject()){
- @Override
- protected void execute(IProgressMonitor arg0) throws CoreException,
- InvocationTargetException, InterruptedException {
- realFacade.parseBuildResult(buildJob.getNotes());
- };
- };
- try {
- wmo.run(monitor);
- } catch (InterruptedException ie){
- // noop
- }catch (InvocationTargetException ie){
- BuildWrapperPlugin.logError(ie.getLocalizedMessage(), ie.getCause());
- }
- }
- }
- });
- //buildJob.setRule( getProject() );
- buildJob.setPriority(Job.BUILD);
- realFacade.getBuildJobQueue().addJob(buildJob);
- }
- }
+// public void build(final BuildOptions buildOptions) {
+// /*WorkspaceModifyOperation wmo=new WorkspaceModifyOperation(getProject()){
+// @Override
+// protected void execute(IProgressMonitor arg0) throws CoreException,
+// InvocationTargetException, InterruptedException {
+// realFacade.build(buildOptions);
+// }
+// };
+// try {
+// wmo.run(monitor);
+// } catch (InterruptedException ie){
+// // noop
+// }catch (InvocationTargetException ie){
+// BuildWrapperPlugin.logError(ie.getLocalizedMessage(), ie.getCause());
+// }*/
+//
+// JobFacade jf=BuildWrapperPlugin.getJobFacade(getProject());
+// if (jf!=null){
+// final String jobNamePrefix = NLS.bind(BWText.job_build, getProject().getName());
+//
+// final BuildJob buildJob=new BuildJob(jobNamePrefix,realFacade,buildOptions);
+//
+// buildJob.addJobChangeListener(new JobChangeAdapter(){
+// @Override
+// public void done(IJobChangeEvent event) {
+// if (event.getResult().isOK()){
+// WorkspaceModifyOperation wmo=new WorkspaceModifyOperation(getProject()){
+// @Override
+// protected void execute(IProgressMonitor arg0) throws CoreException,
+// InvocationTargetException, InterruptedException {
+// realFacade.parseBuildResult(buildJob.getNotes());
+// };
+// };
+// try {
+// wmo.run(monitor);
+// } catch (InterruptedException ie){
+// // noop
+// }catch (InvocationTargetException ie){
+// BuildWrapperPlugin.logError(ie.getLocalizedMessage(), ie.getCause());
+// }
+// }
+// }
+// });
+// //buildJob.setRule( getProject() );
+// buildJob.setPriority(Job.BUILD);
+// realFacade.getBuildJobQueue().addJob(buildJob);
+// }
+// }
public IProject getProject() {
return realFacade.getProject();
View
4 net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/builder/HaskellBuilder.java
@@ -144,9 +144,9 @@ public void fullBuild(final boolean synchronize,final boolean output, final IPro
public void run() {
if (synchronize){
addProjectDependencies( f.getRealFacade(), getProject() );
- f.synchronizeAndBuild( false, bo );
+ f.synchronizeAndBuild( false, bo, mon );
} else {
- f.build( bo );
+ f.build( bo,mon );
}
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.