Kenneth Kousen wrote:
> 
> I tried using a CompilerConfiguration:
> 
> def config = new
> org.codehaus.groovy.control.CompilerConfiguration(classpath:sourceSets.main.runtimeClasspath)
> new GroovyShell(new Binding(), config).evaluate(script)
> 
> but again the classes in the script aren't found.
> 

sourceSets.main.runtimeClasspath is a FileCollection, but
CompilerConfiguration.setClasspath() expects a String. 

Try this: new CompilerConfiguration(classpath:
configurations.runtime.asPath)

Even better, introduce your own configuration (e.g. 'script') and use that.


Kenneth Kousen wrote:
> 
> I know there's a JavaExec task, but I don't see a GroovyExec task and it
> seems a
> bit strange to artificially wrap my script in a Java program just to run
> this.
> 

Compiled Groovy scripts can be run with JavaExec as-is. Might make sense to
have something for source scripts, although inlining and "apply from:" are
also options.

--
Peter Niederwieser
Principal Engineer, Gradleware 
http://gradleware.com
Creator, Spock Framework 
http://spockframework.org
Blog: http://pniederw.wordpress.com
Twitter: @pniederw


--
View this message in context: 
http://gradle.1045684.n5.nabble.com/Run-groovy-script-from-gradle-with-classpath-tp4664822p4666604.html
Sent from the gradle-user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to