Permalink
Browse files

synchronize one project at a time

  • Loading branch information...
1 parent 8315b12 commit be4c21b82f80ff04bcdcd354d5a96fafd85abf22 @JPMoresmau committed Mar 27, 2012
@@ -119,6 +119,14 @@ public synchronized SingleJobQueue getThingAtPointJobQueue(IFile f){
return sjq;
}
+ private void deleteCabalProblems(){
+ String relCabal=getCabalFile().substring(getProject().getLocation().toOSString().length());
+ IFile f=getProject().getFile(relCabal);
+ if (f!=null && f.exists()){
+ BuildWrapperPlugin.deleteProblems(f);
+ }
+ }
+
public JSONArray build(BuildOptions buildOptions){
JSONArray arrC=null;
if (buildOptions.isConfigure()){
@@ -129,11 +137,7 @@ public JSONArray build(BuildOptions buildOptions){
}
if (hasCabalProblems){
- String relCabal=getCabalFile().substring(getProject().getLocation().toOSString().length());
- IFile f=getProject().getFile(relCabal);
- if (f!=null && f.exists()){
- BuildWrapperPlugin.deleteProblems(f);
- }
+ deleteCabalProblems();
hasCabalProblems=false;
}
@@ -700,6 +704,7 @@ private CabalPackage parsePackage(JSONObject obj){
String l=br.readLine();
boolean goOn=true;
boolean needConfigure=false;
+ boolean needDelete=false;
while (goOn && l!=null){
/*if (outStream!=null){
outStream.write(l);
@@ -721,6 +726,9 @@ private CabalPackage parsePackage(JSONObject obj){
} else {
if (l.contains(" re-run the 'configure'") || l.contains("cannot satisfy -package-id")){
+ if (l.contains("The version of Cabal")){
+ needDelete=true;
+ }
needConfigure=true;
}
if (ow!=null) {
@@ -732,6 +740,16 @@ private CabalPackage parsePackage(JSONObject obj){
}
}
if (needConfigure && canRerun){
+ if (needDelete){
+ try {
+ IFolder fldr=project.getFolder(DIST_FOLDER);
+ if (fldr.exists()){
+ fldr.delete(IResource.FORCE, new NullProgressMonitor());
+ }
+ } catch (CoreException ce){
+ BuildWrapperPlugin.logError(BWText.process_launch_error, ce);
+ }
+ }
configure(new BuildOptions().setTarget(BWTarget.Target));
return run(new LinkedList<String>(args.subList(1, args.size()-4)),f,false);
}
@@ -874,6 +892,7 @@ public void clean(IProgressMonitor mon) throws CoreException{
if (fldr.exists()){
fldr.delete(IResource.FORCE, mon);
}
+ deleteCabalProblems();
cabalFileChanged();
outlines.clear();
synchronize(false);
@@ -15,6 +15,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.Path;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status;
@@ -102,7 +102,7 @@ protected IStatus run(IProgressMonitor arg0) {
}
}
});
- // not needed since we put the job in a query ourselves
+ // not needed since we put the job in a queue ourselves
// except if both synchronized and build are run concurrently
//buildJob.setRule( getProject() );
buildJob.setPriority(Job.BUILD);
@@ -137,7 +137,8 @@ protected IStatus run(IProgressMonitor monitor) {
return Status.OK_STATUS;
}
};
- buildJob.setRule( getProject() );
+ //
+ buildJob.setRule( getProject().getWorkspace().getRoot() );
buildJob.setPriority(Job.BUILD);
return buildJob;
}
@@ -98,6 +98,24 @@ protected void execute(IProgressMonitor arg0) throws CoreException,
BuildWrapperPlugin.logError(ie.getLocalizedMessage(), ie.getCause());
}
}
+
+ public void synchronizeAndBuild(final boolean force,final BuildOptions buildOptions) {
+ WorkspaceModifyOperation wmo=new WorkspaceModifyOperation(getProject()){
+ @Override
+ protected void execute(IProgressMonitor arg0) throws CoreException,
+ InvocationTargetException, InterruptedException {
+ realFacade.synchronize(force);
+ realFacade.build(buildOptions);
+ }
+ };
+ try {
+ wmo.run(monitor);
+ } catch (InterruptedException ie){
+ // noop
+ }catch (InvocationTargetException ie){
+ BuildWrapperPlugin.logError(ie.getLocalizedMessage(), ie.getCause());
+ }
+ }
/**
* perform a clean

0 comments on commit be4c21b

Please sign in to comment.