Skip to content

Commit

Permalink
add tuning option to always run clean+build
Browse files Browse the repository at this point in the history
(quick workaround see #1000220)
  • Loading branch information
davidB committed Jan 10, 2011
1 parent 094bf4a commit c0c79b4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
24 changes: 17 additions & 7 deletions org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaBuilder.scala
Expand Up @@ -18,6 +18,7 @@ import scala.tools.eclipse.contribution.weaving.jdt.builderoptions.ScalaJavaBuil
import scala.tools.eclipse.javaelements.JDTUtils
import scala.tools.eclipse.util.{ FileUtils, ReflectionUtils }
import scala.tools.eclipse.internal.logging.Tracer
import scala.tools.eclipse.util.IDESettings

class ScalaBuilder extends IncrementalProjectBuilder {
def plugin = ScalaPlugin.plugin
Expand All @@ -44,10 +45,14 @@ class ScalaBuilder extends IncrementalProjectBuilder {
val dependeeProjectChanged =
project.externalDepends.exists(
x => { val delta = getDelta(x); delta == null || delta.getKind != IResourceDelta.NO_CHANGE})

val (addedOrUpdated, removed) = dependeeProjectChanged match {
case true => (allSourceFiles, Set.empty[IFile])
case _ => kind match {
val cleanBuildForced = IDESettings.alwaysCleanBuild.value || dependeeProjectChanged
val (addedOrUpdated, removed) = cleanBuildForced match {
case true => {
Tracer.println("clean+build forced")
clean(monitor)
(allSourceFiles, Set.empty[IFile])
}
case false => kind match {
case INCREMENTAL_BUILD | AUTO_BUILD => {
val addedOrUpdated0 = new HashSet[IFile] ++ allSourceFiles.filter(FileUtils.hasBuildErrors(_))
val removed0 = new HashSet[IFile]
Expand Down Expand Up @@ -77,9 +82,9 @@ class ScalaBuilder extends IncrementalProjectBuilder {
}

project.build(addedOrUpdated, removed, monitor)

//TODO trigger rebuild of depends only if no error in current build
val depends = project.externalDepends
val back = (allSourceFiles.exists(_.getFileExtension == "java")) match {
val back = ((allSourceFiles.exists(_.getFileExtension == "java")) match {
case false => {
ensureProject
val javaDepends = scalaJavaBuilder.build(kind, ignored, monitor)
Expand All @@ -97,8 +102,13 @@ class ScalaBuilder extends IncrementalProjectBuilder {
(depends ++ javaDepends).toArray
}
case true => depends
}).distinct

// reset classpath of depend project to force reload of newly generated class in the current thread (using events can raised event too late)
for( p <- back if plugin.isScalaProject(p)) {
plugin.getScalaProject(p).resetCompilers(monitor)
}
back.distinct
back
}

def ensureProject = {
Expand Down
Expand Up @@ -43,13 +43,14 @@ object IDESettings {

def tuningSettings: List[Box] = {
List(
Box("Editor Tuning", List(compileOnTyping, useContentOfEditor))
Box("Editor Tuning", List(compileOnTyping, useContentOfEditor, alwaysCleanBuild))
, Box("Logging Tuning", List(tracerEnabled))
)
}

val compileOnTyping = BooleanSetting("_auto compile", "compile file on typing (else compile on save)", true)
val useContentOfEditor = BooleanSetting("_editor content", "use content from Editor for compilation instead of saved file (may lock/freeze)", false)
val alwaysCleanBuild = BooleanSetting("_clean+build", "always do a clean+full build", false)

// TODO remove compileOnTypingDelay (useless)
val compileOnTypingDelay = IntSetting("_auto compile delay", "compile file on typing, delay (ms), 0 : immediate", 600, Some((0,3000)), parseInt)
Expand Down

0 comments on commit c0c79b4

Please sign in to comment.