[gradle-user] Re: Run groovy script from gradle with classpath

2011-08-07 Thread Peter Niederwieser
Kenneth Kousen wrote: > > then the generateTestDb task runs every time, despite the fact I have the > inputs and outputs properties set. What am I missing? > Seems to be a known problem with JavaExec. But you can always use "onlyIf { !myFile.exists() }". -- Peter Niederwieser Principal Enginee

Re: [gradle-user] Re: Run groovy script from gradle with classpath

2011-08-07 Thread Magnus Rundberget
hit the same issue a while back. Check out this thread. There is a workaround suggested http://gradle.1045684.n5.nabble.com/javaexec-task-type-and-inputs-files-outputs-files-td4305023.html Cheers Magnus On 2011-08-07 15:44:09 + Kenneth Kousen wrote: > > On Sun,

Re: [gradle-user] Re: Run groovy script from gradle with classpath

2011-08-07 Thread Kenneth Kousen
By the way, before you say that I'm mixing up the configuration phase with the execution phase, if I simply change my task to: task generateTestDb(dependsOn:classes, type:JavaExec) << { srcFile = file("src/main/groovy/service/populate_stadium_data.groovy") destFile = file("$buildDir/baseba

Re: [gradle-user] Re: Run groovy script from gradle with classpath

2011-08-07 Thread Kenneth Kousen
On Sun, Aug 7, 2011 at 2:01 AM, Peter Niederwieser wrote: > > Kenneth Kousen wrote: > > > > I only want to execute the task if the test database does not exist. > > > > You can add an output to the task, or use Task.onlyIf{}, or use > Project.exec(). > I understand that in principle, but if my bu

[gradle-user] Re: Run groovy script from gradle with classpath

2011-08-06 Thread Peter Niederwieser
Kenneth Kousen wrote: > > I only want to execute the task if the test database does not exist. > You can add an output to the task, or use Task.onlyIf{}, or use Project.exec(). -- Peter Niederwieser Principal Engineer, Gradleware http://gradleware.com Creator, Spock Framework http://spockfra

Re: [gradle-user] Re: Run groovy script from gradle with classpath

2011-08-06 Thread Kenneth Kousen
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

[gradle-user] Re: Run groovy script from gradle with classpath

2011-08-06 Thread Peter Niederwieser
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, jus

Re: [gradle-user] Re: Run groovy script from gradle with classpath

2011-08-06 Thread Kenneth Kousen
Hi again, On Sat, Aug 6, 2011 at 10:17 AM, Peter Niederwieser wrote: > > Kenneth Kousen wrote: > > > > The problem is that when I run the populateStadiumDb task, I now get: > > > > * What went wrong: > > Execution failed for task ':generateTestDb'. > > Cause: java.lang.ClassNotFoundException: org

[gradle-user] Re: Run groovy script from gradle with classpath

2011-08-06 Thread Peter Niederwieser
Kenneth Kousen wrote: > > The problem is that when I run the populateStadiumDb task, I now get: > > * What went wrong: > Execution failed for task ':generateTestDb'. > Cause: java.lang.ClassNotFoundException: org.h2.Driver > Cause: org.h2.Driver > > That's strange, because the gradle dependenci

[gradle-user] Re: Run groovy script from gradle with classpath

2011-08-06 Thread Peter Niederwieser
Kenneth Kousen wrote: > >> Even better, introduce your own configuration (e.g. 'script') and use >> that. > > Um, how do I do that? Can you point me to an example? > configurations { script } dependencies { script ... } But if the script also needs the current project's code, the solutio

Re: [gradle-user] Re: Run groovy script from gradle with classpath

2011-08-05 Thread Kenneth Kousen
I thought it might be easier to just post the whole gradle.build file, so here it is. It's still evolving (I plan to put the generateTestDb task in the main build sequence), but this is what it looks like now: apply plugin:'groovy' apply plugin:'war' apply plugin:'eclipse-wtp' import org.codehaus

Re: [gradle-user] Re: Run groovy script from gradle with classpath

2011-08-05 Thread Kenneth Kousen
I'm definitely getting closer, but I still have a strange error. Here's an excerpt from my gradle.build file: task generateTestDb { srcFile = file("src/main/groovy/service/populate_stadium_data.groovy") destFile = file("$buildDir/baseball.h2.db") inputs.file srcFile outputs.file d

Re: [gradle-user] Re: Run groovy script from gradle with classpath

2011-08-04 Thread Adam Murdoch
On 05/08/2011, at 3:18 AM, Kenneth Kousen wrote: > Hi Peter, > > Thanks for the help, but I still don't quite have it. Here's the idea: I have > a web application whose data resides in a database. I have a script that > generates that database, which uses some of the classes in my domain. > >

Re: [gradle-user] Re: Run groovy script from gradle with classpath

2011-08-04 Thread Kenneth Kousen
Hi Peter, Thanks for the help, but I still don't quite have it. Here's the idea: I have a web application whose data resides in a database. I have a script that generates that database, which uses some of the classes in my domain. What I want to do is to execute that script as part of the build p

[gradle-user] Re: Run groovy script from gradle with classpath

2011-08-04 Thread Peter Niederwieser
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. >