ant path problem

I am running up against a path issue with using liquibase and ant.

If I run ant from the directory where the build.xml is defined then everything runs correctly.   But if I run ant from a different location and specify the build.xml file manually then the liquibase scripts can no longer locate the changeLogFile file.

So if I am in the directory /tmp  and my “build.xml” file is in the directory “/tmp/liquibase” and I run “ant -f /tmp/liquibase/build.xml” I will get an error “/tmp/liquibase/build.xml:28: liquibase.exception.ChangeLogParseException: ora/update.xml does not exist”.   It appears that Liquibase is using the directory I run ant from rather than the directory where the build file is located as its base directory.   It should take all of its directory references from where the build file is specified rather than from where the ant script is executed.

I can get around this problem by stating the entire path in the build.xml file but then it makes it so each developer using liquibase must have the exact same path structure or else I have the chance of a changeset being executed twice because of a differing file structure.

For repeatability here is my project structure and my build.xml file

Here is my file structure
/tmp/liquibase/build.xml
/tmp/liquibase/ora/update.xml
/tmp/liquibase/lib/liquibase.jar
/tmp/liquibase/lib/ojdbc.jar

note my liquibase.jar is the 2.0-rc7 version.

My build.xml file looks like this

 

 

 
   
           
   
 

 
   
 

 
     
      <updateDatabase
           changeLogFile=“ora/update.xml”
           driver=“oracle.jdbc.OracleDriver”
           url="${sqlj.url}"
           username="${sqlj.user}"
           password="${sqlj.password}"
           promptOnNonLocalDatabase=“true”
           dropFirst=“false”
           contexts=“dev”
           classpathref=“liquibase.classpath”
      />
 

It works best if you include the directory containing your changelog folders in the classpath passed to updateDatabase.  In your example, if you add “.” to liquibase.classpath liquibase should find ora/update.xml regardless of where you run ant from.

Nathan