Skip to content

Commit

Permalink
Rebuild on any builder classpath change
Browse files Browse the repository at this point in the history
Until now we only did a rebuild when the list of files on the builder
classpath changed. This ignored changes to the content of those files.
We now actively throw away the builder when the incremental inputs
indicate a change in the builder classpath.

Fixes #41
  • Loading branch information
oehme committed Feb 13, 2016
1 parent 35dcaa6 commit 16fe5d2
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.xtext.gradle.tasks;

import com.google.common.base.Charsets
import java.io.File
import java.net.URLClassLoader
import java.util.Collection
Expand All @@ -24,7 +25,6 @@ import org.xtext.gradle.protocol.GradleOutputConfig
import org.xtext.gradle.protocol.IncrementalXtextBuilder
import org.xtext.gradle.protocol.IncrementalXtextBuilderFactory
import org.xtext.gradle.tasks.internal.FilteringClassLoader
import com.google.common.base.Charsets

class XtextGenerate extends DefaultTask {

Expand Down Expand Up @@ -73,12 +73,18 @@ class XtextGenerate extends DefaultTask {
val removedFiles = newLinkedHashSet
val outOfDateFiles = newLinkedHashSet
inputs.outOfDate[
if (getSources.contains(file) || getNullSafeClasspath.contains(file))
if (getSources.contains(file) || getNullSafeClasspath.contains(file)) {
outOfDateFiles += file
} else if (getXtextClasspath.contains(file)) {
closeBuilder
}
]
inputs.removed[
if (getSources.contains(file))
if (getSources.contains(file)) {
removedFiles += file
} else if (getXtextClasspath.contains(file)) {
closeBuilder
}
]

if (needsCleanBuild) {
Expand Down Expand Up @@ -172,10 +178,15 @@ class XtextGenerate extends DefaultTask {
}

private def initializeBuilder() {
closeBuilder
builder = new IncrementalXtextBuilderFactory().create(project.rootDir.path, languageSetups, nullSafeEncoding, builderClassLoader)
}

private def closeBuilder() {
if (builder !== null) {
(builder.class.classLoader as URLClassLoader).close
builder = null
}
builder = new IncrementalXtextBuilderFactory().create(project.rootDir.path, languageSetups, nullSafeEncoding, builderClassLoader)
}

private def isBuilderCompatible() {
Expand Down

0 comments on commit 16fe5d2

Please sign in to comment.