Hello OC,

Thank you very much for your email. I was contemplating something like the 
regex, but dismissed this as it seemed to be doing the same work as the groovy 
compiler. I am trying to understand how the groovy compiler command line knows 
where to load these classes from? For instance, defining classes A and B inside 
a file called C.groovy still works when you import just A (with no reference to 
C). How does the compiler handle this? Is there some preprocessor that breaks 
up all classes into separate files?

regards
Saravanan

On 2020/05/24 11:05:09, OCsite <o...@ocs.cz> wrote: 
> Hi there,
> 
> far as I know, you have to build your own index which would contain the 
> classname:pathname pairs for all classes — I am afraid there's no standard 
> tool which would do that for you automatically.
> 
> Alas, it is essentially impossible to obtain the class information directly 
> from a groovy source, for even if you could use some smart regexp to find all 
> the class declarations, you would still miss the generated closure classes 
> etc.
> 
> I'd say your best option would be to prepare the index thusly:
> 
> - go through all your sources
> - compile each of them to a new empty -d folder
> - and then enumerate in that folder all the generated .class'es and add their 
> names to the index as keys, with your source name as the appropriate value.
> 
> Someone please correct me if I am overlooking an easier and better approach.
> 
> All the best,
> OC
> 
> > On 24 May 2020, at 7:35, Saravanan Palanichamy <chava...@gmail.com> wrote:
> > 
> > Hello
> > 
> > I have a requirement where I load all my groovy files into a remote
> > database. I then have to pull them down to compile and I am wondering what
> > is the best way to do this. Right now I do this
> > 
> > * I pull down the names of all files (not the actual file)
> > * I then use a GroovyClassLoader to load each one of them (turning off
> > script compile). If I hit a classNotFound error, I then catch that and try
> > to parse a file with that name from my repository
> > 
> > The problem I run into is my file name matching logic. I use the full class
> > name to locate a file in my remote repository with that name. The issue
> > with this is that my class names now have to match my file name. How do I
> > preserve the goodness of groovy's flexibility of defining class names that
> > dont match file names, and even define multiple classes in the same file
> > 
> > regards
> > Saravanan
> 
> 

Reply via email to