Skip to content

Commit

Permalink
Restore src/main/resources as an Xtext input
Browse files Browse the repository at this point in the history
Mainly so active annotations can read from these folders. This worked before
and was only accidentally removed in a refactoring. Added test coverage to
make sure it doesn't happen again.
  • Loading branch information
oehme committed Aug 31, 2021
1 parent b2852cb commit a897d07
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,34 @@ class BuildingAMultiModuleXtendProject extends AbstractXtendIntegrationTest {
snapshot.assertChangedClasses("B")
}

@Test
def void activeAnnotationsCanReadResourcesByDefault() {
upStreamProject.file("src/main/java/ReadingAnnotation.xtend") << '''
import org.eclipse.xtend.lib.macro.*
@Active(ReadingProcessor)
annotation ReadingAnnotation {}
'''
upStreamProject.file("src/main/java/ReadingProcessor.xtend") << '''
import org.eclipse.xtend.lib.macro.*
import org.eclipse.xtend.lib.macro.declaration.*
class ReadingProcessor extends AbstractClassProcessor {
override doValidate(ClassDeclaration annotatedClass, @Extension ValidationContext context) {
val exists = context.getProjectSourceFolders(annotatedClass.compilationUnit.filePath).exists [ folder |
context.exists(folder.append(annotatedClass.simpleName + '.txt'))
]
if (!exists) {
context.addError(annotatedClass, 'No corresponding text file found')
}
}
}
'''
downStreamProject.file("src/main/java/Foo.xtend") << '''
@ReadingAnnotation class Foo {}
'''
downStreamProject.file("src/main/resources/Foo.txt") << '''
FOO!
'''
build('build')
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ class XtextBuilderPlugin implements Plugin<Project> {
xtext.sourceSets.maybeCreate(javaSourceSet.name) => [ xtextSourceSet |
val generatorTask = project.tasks.getByName(xtextSourceSet.generatorTaskName) as XtextGenerate
xtextSourceSet.srcDirs([javaSourceSet.java.srcDirs] as Callable<Set<File>>)
xtextSourceSet.srcDirs([javaSourceSet.resources.srcDirs] as Callable<Set<File>>)
javaSourceSet.allSource.srcDirs([
val dslSources = new LinkedHashSet(xtextSourceSet.srcDirs)
dslSources.removeAll(javaSourceSet.java.srcDirs)
dslSources.removeAll(javaSourceSet.resources.srcDirs)
dslSources
] as Callable<Set<File>>)
javaSourceSet.java.srcDirs([
Expand Down

0 comments on commit a897d07

Please sign in to comment.