I’m using gradle-1.0-milestone-6 and cannot find a way to put ojdbc6.jar onto the CLASSPATH for my groovy code that calls Sql.newInstance(…, “oracle.jdbc.OracleDriver”) and which is executed from my gradle script. This causes java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
I tried various approaches via dependencies specification mentioned in other posts, and still cannot get it to work.
When I was using gradle-1.0-milestone-3, I resolved this problem by dropping ojdbc6.jar file into the lib directory of gradle-1.0-milestone-3, but this no longer works with gradle-1.0-milestone-6.
Based on previous posts, it appears to be a common problem, but what is a real solution for it?
Here is an example of how you can do this for HsqlDB. I didn’t have an oracle instance hanging around so couldn’t test against oracle but the procedure should be the same.
As a side note, I did try a number of methods more in the spirit of gradle: adding the class to the buildscript classpath, adding the class to the settings object classloader, using groovy grapes to do this, using the groovy root loader, etc etc. None of it worked, so if some gradle guru has a more proper way of doing this I would be interested to know. If none exists, perhaps it would be worth adding something like the groovy @GrabConfig(systemClassLoader=true) syntax to gradle?
This isn’t exactly pretty, but the best I could come up with and it works: