Adam, Many thanks. I won't be able to try this for a few days, but I'll report back when all is done.
Tim On Sun, May 16, 2010 at 7:08 PM, Adam Murdoch <[email protected]> wrote: > > > On 17/05/10 10:21 AM, Tim Berglund wrote: > > Hello, > > I'm just getting started with Gradle, and really enjoying what I'm seeing > so far. However, I've got a question. I'd like to create a target that runs > a Groovy script located inside my project. The script imports classes from > the project, so script's classpath should include the project's classes. > The project is on github here: > > http://github.com/tlberglund/midpoint-mountains > > As it stands, I can build, then run this from the command line to do what > I want: > > groovy -cp build/classes/main/ src/main/groovy/BuildMountain > > I thought it would be cool to have a "run" target that did the same > thing. What's the best way to make this happen? > > > To run the script in-process, you could use GroovyShell to execute the > script: http://groovy.codehaus.org/gapi/groovy/lang/GroovyShell.html > > To run the script in a separate process, you could use the Exec or JavaExec > tasks to execute the script. See > http://gradle.org/latest/docs/javadoc/org/gradle/api/tasks/Exec.html or > http://gradle.org/latest/docs/javadoc/org/gradle/api/tasks/JavaExec.html > > I guess it might be nice to add a GroovyExec task at some point, too. > > To get the classpath, you might use sourceSets.main.runtimeClasspath, with > is of type FileCollection: > http://gradle.org/latest/docs/javadoc/org/gradle/api/file/FileCollection.html > > > -- > Adam Murdoch > Gradle Developerhttp://www.gradle.org > >
