tags:

views:

68

answers:

2

I'm new to Groovy, really like it, but found a compilation problem. I'm using Jetty as a webserver, which is serving .groovy files (groovlets)

Consider two files:

Test1.groovy which contains:
   println new Test2().property

Test2.groovy which contains:
  public class Test2 {
   String property = "print this"
 }

When calling /Test1.groovy in a browser it prints "print this". But when I change the property in something else, it still prints "print this", it won't recompile. The only thing I can do is restart jetty. Note that when all the code is in one file, recompilation does work.

Is there a workaround for this..?

Thanks,

Bas.

A: 

I think the reason it's always displaying the default value is because you're newing it inline ... or is that just a problem with the example?

overslacked
A: 

Thanks, but that's not it. I am getting a little closer, the compiler can be fooled:

When calling /test2.groovy in a browser you get a server error, because test2.groovy only contains class code (and not a main method), but when you add the line
   println ""
to this file, it actually recompiles when calling it in a browser.

After that, test1.groovy should be recompiled too in order to make it work. It's not a very neat solution, but jetty doesn't need to be restarted this way...