Skip to content



Using Dbdeploy with Ant, an example

Here is an example of using dbdeploy in anĀ  ant build file:

<taskdef name="dbdeploy" classname="net.sf.dbdeploy.AntTarget"
classpathref="lib.dir"/>

<target name="build" depends="create-build-directory"
description="Compile main source tree java files">
    <echoproperties prefix="jdbc" />
    <echoproperties prefix="smn" />
    <javac destdir="${smn.build.dir}" source="1.5" target="1.5"
debug="true" deprecation="false" optimize="false" failonerror="true">
        <src path="${smn.src.dir}"/>
        <classpath refid="master-classpath"/>
    </javac>

    <dbdeploy
driver="${jdbc.driverClassName}"
url="${jdbc.url}"
userid="${jdbc.username}"
password="${jdbc.password}"
dir="${smn.base.dir}\db\deltas"
outputfile="${smn.base.dir}\db-deploy-output\all-deltas.sql"
dbms="mysql"
undoOutputfile="${smn.base.dir}\db-deploy-output\undo-all-deltas.sql"
    />
    <sql driver="${jdbc.driverClassName}" password="${jdbc.password}"
url="${jdbc.url}" userid="${jdbc.username}"
src="${smn.base.dir}\db-deploy-output\all-deltas.sql"
print="true" classpathref="lib.dir" />
</target>
  1. Note: dbdeploy does not run your change scripts, you have to run the script it outputs with an sql task
  2. If you get errors likeĀ 
    > taskdef class net.sf.dbdeploy.AntTarget cannot be found

    it means that the dbdeploy.jar is not in your classpath.

One Comment

  1. Michael wrote:

    quote: it means that the dbdeploy.jar is not in your classpath.

    My dbdeploy.jar is in my classpath and it contains net.sf.dbdeploy.AntTarget,

    but when I’m building my project I get this message.
    Could anybody help me?

    Wednesday, February 17, 2010 at 5:09 am | Permalink

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*