title: Compiling and using Groovy classes from Java at runtime?
body: <p>I have an app which I'd like to make extensible by letting users define classes in Groovy, eventually implementing some interfaces.</p>
  
  <p>The key aspect is that it should be interpreted/compiled at runtime. I.e. I need my app to take the <code>.groovy</code> and compile it. Doing it during boot is ok.</p>
  
  <p>Then, of course, my app should be able to instantiate that class.</p>
  
  <p>I see two solutions:</p>
  
  <p>1) Compile while the app runs, put the classes somewhere on classpath, and then just load the classes, pretending they were always there.</p>
  
  <p>2) Some smarter way - calling a compiler API and some classloading magic to let my system classloader see them.</p>
  
  <p><strong>How would I do option 2)?</strong><br>
  <strong>Any other ideas?</strong></p>