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 dependencies include > 'com.h2database:h2:1.2.140' and the script runs just fine without gradle > (I > run it from Eclipse, but the Eclipse project was created using the gradle > eclipse plugin). Using sourceSets.main.runtimeClasspath.asPath resolved > the > issue of finding the Stadium and Geocoder classes, and if I print the > sourceSets.main.runtimeClasspath elements the H2 jar is in there, so why > isn't the driver being found? >
How do you load the JDBC driver? Class loader problems with JDBC drivers are common, especially with alternative languages like Groovy. The JDK's way to determine a method's caller (and the caller's class loader) doesn't work reliably here because the Groovy runtime sits between the caller and the callee. Kenneth Kousen wrote: > > As an aside (and probably an easier question), is there a simpler way to > refer to the populate_stadium_data groovy script than giving it an > explicit > path from the src directory? > Not really. Question is whether you should put the script into src/main/groovy, because then it becomes part of the compiled code 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-tp4664822p4672644.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
