Skip to content

Commit

Permalink
Fix handling of removed classpath folders
Browse files Browse the repository at this point in the history
  • Loading branch information
oehme committed Mar 5, 2023
1 parent 13b3e6a commit c37d2db
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ class BuildingASimpleXtendProject extends AbstractXtendIntegrationTest {

snapshot.assertChangedClasses("UpStream", "DownStream")
}

@Test
def generatorHandlesDeletionOfClasspathFolders() {
createFile('src/main/java/UpStream.xtend', '''
class UpStream {}
''')
createFile('src/test/java/DownStream.xtend', '''
class DownStream{
}
''')
build("build")
val snapshot = snapshot(projectDir)

//remove the main sources from the test classpath
buildFile << "sourceSets.test.compileClasspath = configurations.testCompileClasspath"
build("build")

snapshot.assertChangedClasses("DownStream")
}


@Test
def affectedResourcesAreDetectedAcrossXtendAndJava() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,20 @@ abstract class XtextGenerate extends DefaultTask {
request.dirtyFiles += file
}
]
inputs.getFileChanges(classpath).forEach [ change |
// Gradle notifies us about individual .class files, but we only want their containing directory
request.dirtyClasspathEntries += classpath.files.findFirst[change.file.path.startsWith(it.path)]
]
val classpathRoots = classpath.files
inputs.getFileChanges(classpath)
.forEach[change |
if (change.normalizedPath.isEmpty) {
request.dirtyClasspathEntries += change.file
} else {
val root = classpathRoots.findFirst[change.file.path.startsWith(it.path)]
if (root !== null) {
request.dirtyClasspathEntries += root
} else {
request.incremental = false
}
}
]
}

def installDebugInfo(File classesDir) {
Expand Down

0 comments on commit c37d2db

Please sign in to comment.