Gradle is adding a set of import statements to any gradlefile before
it is evaluated. This saves the user typing something like
org.gradle.api.X and she can just type X. In particular for non
IntelliJ users this is an important feature ;)
Right now the set of import statements is just a String we add to the
actual gradlefile text before we evaluate it. This has one big
disadvantage. The line numbers are changed. In case of an exception
we parse the stacktrace for line number information and add an offset
to it before we report it. This is tedious and does not work when the
line number is part of the exception message (e.g. Groovy's compile
exception). I think AST transformations could do a much better job
here. I don't have any experience here.
The relevant class is BuildScriptProcessor and here is the snippet
where the evaluation takes place:
buildScript = buildScriptWithImports(project)
GroovyShell groovyShell = new GroovyShell(classLoader,
binding, conf)
Script script = groovyShell.parse(buildScript.text,
project.buildScriptFinder.buildFileName)
replaceMetaclass(script, project)
project.projectScript = script
script.run()
Of course I could start to do my own experiments or post to the
Groovy list. But if someone has a clear idea of how to do this that
would be a great time saver. And although this is a public mail I
have a one person in mind for whom this might be very easy to do :)
- Hans
--
Hans Dockter
Gradle Project lead
http://www.gradle.org
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email