Skip to content

Commit c37d2db

Browse files
committed
Fix handling of removed classpath folders
1 parent 13b3e6a commit c37d2db

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

xtext-gradle-plugin/src/integTest/java/org/xtext/gradle/test/BuildingASimpleXtendProject.xtend

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,26 @@ class BuildingASimpleXtendProject extends AbstractXtendIntegrationTest {
5656

5757
snapshot.assertChangedClasses("UpStream", "DownStream")
5858
}
59+
60+
@Test
61+
def generatorHandlesDeletionOfClasspathFolders() {
62+
createFile('src/main/java/UpStream.xtend', '''
63+
class UpStream {}
64+
''')
65+
createFile('src/test/java/DownStream.xtend', '''
66+
class DownStream{
67+
}
68+
''')
69+
build("build")
70+
val snapshot = snapshot(projectDir)
71+
72+
//remove the main sources from the test classpath
73+
buildFile << "sourceSets.test.compileClasspath = configurations.testCompileClasspath"
74+
build("build")
75+
76+
snapshot.assertChangedClasses("DownStream")
77+
}
78+
5979

6080
@Test
6181
def affectedResourcesAreDetectedAcrossXtendAndJava() {

xtext-gradle-plugin/src/main/java/org/xtext/gradle/tasks/XtextGenerate.xtend

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,20 @@ abstract class XtextGenerate extends DefaultTask {
127127
request.dirtyFiles += file
128128
}
129129
]
130-
inputs.getFileChanges(classpath).forEach [ change |
131-
// Gradle notifies us about individual .class files, but we only want their containing directory
132-
request.dirtyClasspathEntries += classpath.files.findFirst[change.file.path.startsWith(it.path)]
133-
]
130+
val classpathRoots = classpath.files
131+
inputs.getFileChanges(classpath)
132+
.forEach[change |
133+
if (change.normalizedPath.isEmpty) {
134+
request.dirtyClasspathEntries += change.file
135+
} else {
136+
val root = classpathRoots.findFirst[change.file.path.startsWith(it.path)]
137+
if (root !== null) {
138+
request.dirtyClasspathEntries += root
139+
} else {
140+
request.incremental = false
141+
}
142+
}
143+
]
134144
}
135145

136146
def installDebugInfo(File classesDir) {

0 commit comments

Comments
 (0)