groovyclassloader

What are the pros and cons of using GroovyClassLoader vs. GroovyShell

I need to run some external code from my Java application that will be updated frequently and orthogonally to the rest of the application. As I do not to re-deploy the entire application for every code change (and for other reasons as well) we chose to use groovy for this code, and store it either on the file system or in the database. ...

Groovy classloader bug?

I've encountered buggy behavior: import groovy.xml.DOMBuilder def filePath = "MestaXml.log"; def doc = DOMBuilder.parse(new FileReader(filePath)); def docElm = doc.documentElement; - $ groovy SaveTransformer.groovy Caught: java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated lo...

Run groovy script from within gradle

What's the best way to create a gradle task, which runs a groovy script? I realize that gradle build files are groovy, so I would think it would be possible to do something like this: task run << { Script app = new GroovyShell().parse(new File("examples/foo.groovy")) // or replace .parse() w/ a .evalulate()? app.run() } I...

Loading classes not present in the classpath

Let's say I've compiled a Groovy script using Groovyc, which has generated one or more .class files in the file system. From a Java application, how do I add those classes to the classpath dynamically in order to load them and call their methods? The goal is to pre-compile Groovy scripts and store them into the database, so evaluation ca...