Skip to content

Commit

Permalink
automatically configure source folders and xbase dependency for java …
Browse files Browse the repository at this point in the history
…generating languages
  • Loading branch information
oehme committed Mar 13, 2014
1 parent b82b17d commit aa2dde4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import org.gradle.api.plugins.JavaPluginConvention
import org.gradle.api.tasks.SourceSet
import org.gradle.plugins.ide.eclipse.EclipsePlugin;
import org.gradle.plugins.ide.eclipse.model.EclipseModel;
import org.xtext.gradle.tasks.Language
import org.xtext.gradle.tasks.OutputConfiguration;
import org.xtext.gradle.tasks.XtextEclipseSettings;
import org.xtext.gradle.tasks.XtextExtension
import org.xtext.gradle.tasks.XtextGenerate
Expand Down Expand Up @@ -52,6 +54,14 @@ class XtextPlugin implements Plugin<Project> {
xtext.sources.srcDirs(sourceDirs.toArray())
}
xtextDependencies.extendsFrom(project.configurations[JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME])
xtext.languages.each { Language language ->
language.outputs.each { OutputConfiguration output ->
if (output.javaSourceSet != null) {
project.dependencies.add("compile", "org.eclipse.xtext:org.eclipse.xtext.xbase.lib:${xtext.version}")
output.javaSourceSet.getJava().srcDir(output.dir)
}
}
}
project.tasks[JavaPlugin.COMPILE_JAVA_TASK_NAME].dependsOn(generatorTask)
}
generatorTask.configure(xtext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,13 @@ class Language {
class OutputConfiguration {
String name
def dir
SourceSet javaSourceSet

OutputConfiguration(String name) {
this.name = name
}

def producesJavaFor(SourceSet javaSourceSet) {
setJavaSourceSet(javaSourceSet)
}
}

0 comments on commit aa2dde4

Please sign in to comment.