The need for a schema versioning system at LocaModa finally became a priority this sprint so I’ve spent the past few days researching and diving into implementation. After comparing LiquiBase, dbdeploy, MIGRATEdb, and dbmigrate I settled on the simple SQL driven solution that dbdeploy provides and started integrating it with our Ant build. Pramod Sadalage over at Agile DBA put up a nice post on the basics but I quickly hit a wall, the MySQL driver was not in my classpath.
As I mentioned earlier we are using Ivy for our dependancy management which makes it difficult to throw jars into the Ant classpath since they are automatically downloaded at build time. So far this hasn’t been an issue since most Ant tasks allow you to specify the classpath as a parameter within the task. Dbdeploy does not. Goggling around I quickly found a posting that suggested patching the dbdeploy ant task as the only way to go, so off I went. However, a few hours later, after wandering through the Java classloader abyss I was stymied.
I backed out of the changes and decided a different tactic was needed; back to Goggle I went. This time I came across a post which suggested all I needed was to add the jar to the taskdef classpath Could it really be that easy? Switching back to my build.xml I doctored up the dbdeploy taskdef, kicked off a build and sure enough the damn thing worked.
So, if you want to centrally manage your ant dependencies, just remember to add the necessary classpath references to your taskdefs, like so: