So, after studying JavaParser API, I've come to conclusion that creating exact clone of this API for Groovy would be completely irrelevant for this project.
JavaParser only works on Java class/interface/enum/annotation structures, there is no way to modify method logic other than manually editing its source code (from Method.getBody() method, which returns plain String).
What we really need, is a util which works on imperative expressions, not data structures, so it should be exactly opposite of JavaParser (in Gradle build script there will be rarely any class declarations).
I think this issue can be dealt in two ways:
1) Create a full GroovyParser with all capabilities to synthesize any piece of code (including class structures and method bodies) - that's what I was thinking initially, surely nice to have, but it's very hard to even design an API (with statements and expressions its API size will be about twice of JavaParser), and implementing it. To do that we would need to either use one of the existing parsers which are not easy to use (mostly IDE plugins, which are not even available as a Maven dependencies, and they take quite a lot of memory space) or write our own Groovy AST rewriter which may be easy or hard depending on what output quality we expect from it - if we want to keep comments and formatting it certainly won't be easy to do.
2) Use my simple parser ( https://github.com/adamwy/simple-gradle-manager
) or rewrite it, and start working on Gradle support from now, it's fast and light solution (no dependencies other than Groovy library), and it's sufficient to make all necessary modifications to the Gradle build script. I could work on GroovyParser (which I promised to do) after Gradle support in Forge is done, and we could think about creating a common API for parsing Java, Groovy and maybe other languages with full support for expressions inside method bodies. Having this abstraction layer addons which need to synthesize code could work with any supported language without caring in which language the class they modify is written.
What do you think is a better way? I planned to go with the first, but the many issue related to this made me think that maybe we should take more time to think and discuss how the Groovy (and probably Java) parser should look and work like, and it will be better to do that later (it's not necessary for Gradle addon, but a nice feature which we will probably need in the future anyway).
2013/5/5 Adam Wyłuda <firstname.lastname@example.org>
Hello JBoss community,
This year I want to participate in an OS project and GSoC gives me great opportunity to do so.