tags:

views:

26

answers:

1

Is there a way to parse all all the classes in a groovy script? To Parse ONE clase right now:

java.lang.Class clazz = groovyClassLoader.parseClass(new File("MainApp.groovy"))

MainApp.groovy: class MainApp { def doIt() {} }

class OtherMainApp { def doTheRest() {} }

This will return only MainApp.

I would like something like this:

java.lang.Class[] clazz = groovyClassLoader.parseClass(new File("MainApp.groovy"))

where claszz contains will contain MainApp class and OtherMainAppClass

Basically I want to be able to extract all the declared classes in a script.

Because of the nature of the app that I'm builgin groovyc command won't help

Thanks,

Federico

A: 

No can do:

http://jira.codehaus.org/browse/GROOVY-3793

You could do it yourself though: you could parse the class yourself (just count the {} pairs), dump it out to a new file, and away you go. Ugly? yes. Painful? Very. Possible? Maybe. Better solution? Not until Groovy fixes the bug.

glowcoder