Originally posted by: ovu
What I am trying to do is to integrate liquibase with my application, which does not use Spring. Is there any way to do that?
I had to do something similar recently (a single central dashboard for managing updates for all DEV/UAT/Production environments within a company) and ended up calling the CLI’s static main(String) method (didn’t had the time to go over the source code and figure out how to do it “properly” – another choice could be to take the ant target code and pull the ant-specific legs off). Anyway, re-using main() in my code gives me access to all the power of liquibase CLI, with only minor (in my case) integration issues, so I went for that.
I don’t think liquibase has a “customer-ready” API at the moment; I would have to read through quite a bit of the sources to hook into it.
What I’d love though would be an API with the functionality of liquibase Ant tasks, but without any dependencies on Ant environment. Essentially, a liquibase service bean, an object that I could instantiate in my code, or through spring, and then just call it’s methods as I need them (select a changelog file, get details for all updates, do update, generate SQL, and so on. Does it sound useful to anyone else? (I’m thinking of finding some time to write the required patches, but I won’t bother if it’s too niche to ever be accepted into the official codebase). Actually, would it be possible to implement something like that (an API extension) through the new 2.0 plugin interface? Probably not, would need to be a patch…
Also, what just came to my mind… wouldn’t it be nice if that hypothethical liquibase API could do resource lookups through some sort of a locator interface (put resource path in, get resource stream/File object out)? One could then easily write a custom locator and make it fetch changelogs directly from VCS, or through http, or whatever… Or virtually change the working directory by prefixing something to all resource paths on the fly, making it possible to work around any problems with relative paths in changesets. That would put icing on the cake for me… (maybe it’s already possible, haven’t really looked at liquibase internals yet).