Liquibase给出了Ant和命令行的不同结果

时间:2015-02-19 12:17:14

标签: ant liquibase

当我从命令行运行Liquibase时,它会填充FILENAME DATABASECHANGELOG列的<project name="Database Build" default="build" basedir="." xmlns:liquibase="antlib:liquibase.integration.ant"> <path id="liquibase.lib.path"> <fileset dir="liquibase/lib"> <include name="**/*.jar" /> </fileset> <fileset dir="liquibase"> <include name="liquibase.jar" /> </fileset> </path> <path id="driver.classpath"> <filelist files="${classpath}" /> </path> <path id="main.classpath"> <pathelement location="." /> <path refid="driver.classpath" /> </path> <taskdef resource="liquibase/integration/ant/antlib.xml" uri="antlib:liquibase.integration.ant"> <classpath refid="liquibase.lib.path" /> </taskdef> <liquibase:database id="main-schema" driver="${driver}" url="${url}" user="${username}" password="${password}" defaultSchemaName="${defaultSchemaName}" /> <target name="build" description="Builds the database based on values set in the properties file"> <echo message="Building DB..." /> <liquibase:updateDatabase databaseref="main-schema" changelogfile="${changeLogFile}" classpathref="main.classpath" logLevel="debug" > <!-- Here we're effectively passing the values set as Ant properties in as Liquibase parameters --> <liquibase:changeLogParameters> <liquibase:changeLogParameter name="main.schema" value="${defaultSchemaName}" /> <liquibase:changeLogParameter name="tablespace.data" value="${tablespace.data}" /> <liquibase:changeLogParameter name="tablespace.index" value="${tablespace.index}" /> <liquibase:changeLogParameter name="tablespace.long" value="${tablespace.long}" /> </liquibase:changeLogParameters> </liquibase:updateDatabase> </target> <target name="createSchema" description="Create a schema on the database" > <echo>${toString:main.classpath}</echo> <sql driver="${driver}" classpathref="main.classpath" url="${url}" userid="${username}" password="${password}" expandProperties="true" > <transaction> CREATE SCHEMA ${defaultSchemaName}; </transaction> </sql> </target> <target name="createOracleUsers" description="Create a user in Oracle" > <sql rdbms="oracle" print="true" driver="${driver}" classpathref="main.classpath" url="${url}" userid="${username}" password="${password}" expandProperties="true" > <transaction> CREATE USER ${defaultSchemaName} IDENTIFIED BY ${defaultSchemaName} default tablespace ${tablespace.data} temporary tablespace TEMP quota unlimited on ${tablespace.data} quota unlimited on ${tablespace.index}; GRANT create session, alter session, create sequence, create table, create view to ${defaultSchemaName}; </transaction> </sql> </target> </project> 列,其中包含更改日志文件的相对路径,正如您所希望的那样。但是当我使用Ant在完全相同的目录中运行完全相同的更改日志时,它会使用绝对路径填充列。

除此之外,这意味着Ant和命令行版本对我来说无法互操作。

但我找不到其他人报告此问题,所以我确定这是我正在做的事情;我没有正确设置的东西。我已经看到一些建议,即更改日志的根目录需要在类路径中,所以我已将它包含在Ant类路径中,但它没有任何区别。

这是我的Ant构建文件:

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog 
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.3.xsd 
                    http://www.liquibase.org/xml/ns/dbchangelog-ext 
                    http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

    <include file="changes/sequences/sequences.xml" relativeToChangelogFile="true" />   
    <include file="changes/baseobjects/db-511.xml" relativeToChangelogFile="true" />
    <include file="changes/data/data-511.xml" relativeToChangelogFile="true" />

</databaseChangeLog>

编辑添加一些更改日志文件。

这是根更改日志文件:

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog 
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.3.xsd 
                    http://www.liquibase.org/xml/ns/dbchangelog-ext 
                    http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

    <changeSet dbms="oracle,db2,db2i" author="mccallim (generated)" id="1419011907193-1">
        <createSequence schemaName="${main.schema}" cacheSize="100" cycle="false" incrementBy="1" minValue="1" sequenceName="SEQ_ALLOWEDCURRENCIES" startValue="1"/>
    </changeSet>
...
</databaseChangeLog>

第一个包含的内容如下:

{{1}}

它有很多其他序列。下一个表格,索引和视图,就像你期望的那样。

1 个答案:

答案 0 :(得分:0)

它看起来像一个bug。我创建了https://liquibase.jira.com/browse/CORE-2290来跟踪3.3.3的修复程序