Question

Somebody who's a more seasoned maven user can probably help me out here:

how do I pass in "optional parameters" to liquibase when running it as a maven goal?

I want to pass in "changesToApply", see http://www.liquibase.org/manual/maven_updatesql

But what's the syntax? Something like this, but not quite:

mvn liquibase:updateSQL -DchangesToApply=2
Was it helpful?

Solution

Short answer:

mvn liquibase:updateSQL -Dliquibase.changesToApply=2

Long answer

Go to the parameter you're interested and look for it's expression. http://www.liquibase.org/manual/maven_updatesql#changesToApply

Look for

changesToApply:

The number of changes to apply to the database. By default this value is 0, which will result in all changes (not already applied to the database) being applied.
Type: int
Required: No
Expression: ${liquibase.changesToApply}
Default: 0

From this, you can see the expression is ${liquibase.changesToApply}

Expression: ${liquibase.changesToApply}

That's what you should use

OTHER TIPS

From Maven Liquibase plugin manual

All the parameters for executing the Maven Liquibase plugin can also be specified in <configuration> section of the plugin. Below is an example of this:

[...]
<plugin>
  <groupId>org.liquibase</groupId>
  <artifactId>liquibase-maven-plugin</artifactId>
  <version>2.0.1</version>
  <executions>
    <execution>
      <phase>process-resources</phase>
      <configuration>
        <changeLogFile>src/main/resources/org/liquiabse/business_table.xml</changeLogFile>
        <driver>oracle.jdbc.driver.OracleDriver</driver>
        <url>jdbc:oracle:thin:@tf-appserv-linux:1521:xe</url>
        <username>liquibaseTest</username>
        <password>pass</password>
      </configuration>
      <goals>
        <goal>update</goal>
      </goals>
    </execution>
  </executions>
</plugin>
[...]

Here is how I do it: mvn liquibase:updateSQL -P mysql -DskipTests -Dliquibase.changeLogFile=create.xml

where my change log file is "create.xml" and "mysql" a pre-configured profile to populate my database properties file.

make sure though that the change log file is not hard coded in the liquibase.properties file and make sure that you rebuild the module because the maven goal will use the liquibase.properties in the target/classes directory of the module

For the version 3.5.5 should go outside <executions> like below:

<plugin>
      <groupId>org.liquibase</groupId>
      <artifactId>liquibase-maven-plugin</artifactId>
      <version>3.0.5</version>
      <configuration>
        <changeLogFile>src/main/resources/org/liquibase/business_table.xml</changeLogFile>
          <driver>oracle.jdbc.driver.OracleDriver</driver>
          <url>jdbc:oracle:thin:@tf-appserv-linux:1521:xe</url>
          <username>liquibaseTest</username>
          <password>pass</password>
        </configuration>
      <executions>
        <execution>
          <phase>process-resources</phase>
          <goals>
            <goal>update</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top