This actually worked:

task generateTestDb(dependsOn:classes, type:JavaExec) {
    main = 'service.populate_stadium_data'
    classpath sourceSets.main.runtimeClasspath
}

The only problem is that it runs every time. I only want to execute the task
if the test database does not exist. The examples all look like:

task buildDb << {
    srcFile = file("src/main/groovy/service/populate_stadium_data.groovy")
    destFile = file("$buildDir/baseball.h2.db")
    inputs.file srcFile
    outputs.file destFile
    doLast {
        // what do I put here to call the generateTestDb task?
    }
}

Ken



On Sat, Aug 6, 2011 at 3:47 PM, Peter Niederwieser <[email protected]>wrote:

>
> Kenneth Kousen wrote:
> >
> > As I say, it works in isolation, just not as part of the gradle script.
> >
>
> The fact that it works in isolation doesn't say anything about whether it
> works in other class loader environments (like Gradle's).
>
>
> Kenneth Kousen wrote:
> >
> > The script is src/main/groovy, just part of the service package, so it is
> > compiled.
> >
> > I'll try the JavaExec approach and see if that helps.
> >
>
> If the script is compiled along with the other sources, JavaExec makes more
> sense than GroovyShell, and will probably solve your class loader problem
> too.
>
> --
> Peter Niederwieser
> Principal Engineer, Gradleware
> http://gradleware.com
> Creator, Spock Framework
> http://spockframework.org
> Twitter: @pniederw
>
> --
> View this message in context:
> http://gradle.1045684.n5.nabble.com/Run-groovy-script-from-gradle-with-classpath-tp4664822p4673445.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
>
>
>


-- 
Kenneth A. Kousen
President
Kousen IT, Inc.

Reply via email to