Browse files

Re #1000388, Re #1000607. Set the call to the Eclipse Java compiler a…

…synchronous so it can see the changes.

The way the incremental Eclipse Java compiler works, it doesn't see that because a .class has been changed it needs
to recompile some sources.
This change 'touches' the java files to recompile and call asynchronously the Eclipse Java compiler so it can see
the touched files in the delta.
  • Loading branch information...
1 parent 7d856bf commit 0d02de6bbf45ec8067c9606cb76c49801f47362b @skyluc skyluc committed Nov 11, 2011
@@ -23,6 +23,13 @@ import
import org.eclipse.jdt.launching.JavaRuntime
import org.eclipse.jdt.core.{ JavaCore, IJavaProject }
+import org.eclipse.core.resources.ResourcesPlugin
+import org.eclipse.core.resources.IResource
+import org.eclipse.core.runtime.NullProgressMonitor
+import org.eclipse.core.runtime.IProgressMonitor
+import org.eclipse.core.runtime.IStatus
+import org.eclipse.core.runtime.Status
class AnalysisCompile (conf: BasicConfiguration, bm: EclipseSbtBuildManager, contr: Controller) extends HasLogger {
import AnalysisFormats._
@@ -137,13 +144,29 @@ class AnalysisCompile (conf: BasicConfiguration, bm: EclipseSbtBuildManager, con
- }
+ }
if(order == JavaThenScala) {
compileJava(); compileScala()
} else {
- compileScala(); compileJava()
+ compileScala();
+ for (javaSource <- javaSrcs) {
+ for (file <- ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(javaSource.toURI())) {
+ file.touch(new NullProgressMonitor)
+ }
+ }
+ val markerJob= new Job("Update classpath error marker") {
+ override def run(monitor: IProgressMonitor): IStatus = {
+ compileJava()
+ Status.OK_STATUS
+ }
+ }
+ markerJob.setRule(conf.project.underlying)
+ markerJob.schedule()
// if we reached here, then it might be that compiling scala files failed but java succeded
// it might be the case that we just want to proceed with compiling java files when scala succeded
// this is still something that needs to be settled (in the latter case we won't see errors for java files)

3 comments on commit 0d02de6


This fixes the problem for me:
With this patch I cannot reproduce the error and it happened consistently before. I'm really excited about this since I can finally switch to the sbt build manager :)

One thing I noticed, is that a lot more files gets recompiled now. But I guess that is because you touch the source files?

Eclipse Scala IDE member

It does recompile more files... In fact, it recompiles all Java files in the project every time.

I debugged a bit more to see if I was getting the deltas I expected. I wasn't.

So it is kind of working, but it is not a good solution.


That explains it. Thank you for looking into this issue. I will do some more testing later.

Please sign in to comment.