Woah, Nellie.NET!

From my simple mind to… mine…

Incorporating Liquibase into NAnt Builds

leave a comment »

With Liquibase for .NET a little ways off, I spent a little time trying to get Liquibase for Java incorporated into my NAnt build. The following lessons learned were originally from a spike, but I’ve gone ahead and incorporated liquibase into my new project. Let me know if you have something better.

The first step is to download the Liquibase jar, the SQL Server JDBC driver (if you are using SQL Server) and ikvm.

Liquibase is a pretty good database refactoring tool, facilitating such things as multiple DB support, multiple developer merges, test data inserts for unit testing, and so on.

ikvm is a Java implementation for .NET and Mono. I chose this route as opposed to installing Java just to keep things easy for me.

My NAnt target utilizes the <exec> task to execute liquibase using ikvm.exe:

  description="Sets up database for unit testing purposes"
    <exec basedir="..\..\tools\ikvm"
        <arg line="-jar ..\..\tools\liquibase\liquibase-1.8.1.jar" />
        <arg value="--logLevel=SEVERE" />
        <arg value="--classpath=..\..\tools\ikvm\sqljdbc.jar" />
        <arg value="--driver=com.microsoft.sqlserver.jdbc.SQLServerDriver" />
        <arg value="--url=jdbc:sqlserver://localhost;databasename=DirectSalesSoftware;integratedSecurity=true;" />
        <arg value="--changeLogFile=.\Persistence\liquibase\db.changelog.xml " />
        <arg value="--contexts=tests" />
        <arg value="update" />

From here, I setup a batch file that I can double click to update my database:

@..\..\tools\nant\bin\nant.exe -buildfile:default.build liquibase.for.testing


Written by Nelson

November 7, 2008 at 9:14 am

Posted in .NET, Agile Software

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: