title: Loading data from properties file to be used by Liquibase in Maven build
body: <p>I can run Liquibase changelog through maven build (<code>liquibase:update</code> goal) without any problems. Now I'd like Liquibase to use database credentials and URL loaded from a properties file (<em>db.properties</em>) depending on the selected Maven profile:</p>
  
  <pre><code>|-- pom.xml
  `-- src
      `-- main
          `-- resources
              |-- local
              |   `-- db.properties
              |-- dev
              |   `-- db.properties
              |-- prod
              |   `-- db.properties
              `-- db-changelog-master.xml
              `-- db-changelog-1.0.xml
  </code></pre>
  
  <p>Each of the 3 properties files would look like the following:</p>
  
  <pre><code>database.driver = oracle.jdbc.driver.OracleDriver
  database.url = jdbc:oracle:thin:@&lt;host_name&gt;:&lt;port_number&gt;/instance
  database.username = user
  database.password = password123
  </code></pre>
  
  <p>Now, instead of these properties being defined in the POM file itself (as explained in the accepted answer of this question <a href="https://stackoverflow.com/questions/9606585/liquibase-using-maven-with-two-databases-does-not-work">liquibase using maven with two databases does not work</a>), I'd like them to be loaded from the external properties file. I have tried different approaches to no avail:</p>
  
  <p><strong>1. I used Maven's <code>resource</code> element in the POM file:</strong></p>
  
  <pre><code>&lt;build&gt;
        &lt;pluginManagement&gt;
           &lt;plugins&gt;
              &lt;plugin&gt;
                 &lt;groupId&gt;org.liquibase&lt;/groupId&gt;
                 &lt;artifactId&gt;liquibase-maven-plugin&lt;/artifactId&gt;
                 &lt;version&gt;3.1.0&lt;/version&gt;
                 &lt;configuration&gt;
                    &lt;changeLogFile&gt;db.changelog-master.xml&lt;/changeLogFile&gt;
                    &lt;verbose&gt;true&lt;/verbose&gt;
                 &lt;/configuration&gt;
              &lt;/plugin&gt;
           &lt;/plugins&gt;
        &lt;/pluginManagement&gt;
     &lt;/build&gt;
  
  
  &lt;profiles&gt;
      &lt;profile&gt;
          &lt;id&gt;local&lt;/id&gt;
          &lt;activation&gt;
              &lt;activeByDefault&gt;true&lt;/activeByDefault&gt;
          &lt;/activation&gt;
          &lt;build&gt;
              &lt;resources&gt;
                  &lt;resource&gt;
                      &lt;directory&gt;src/main/resources/local&lt;/directory&gt;
                  &lt;/resource&gt;
              &lt;/resources&gt;
          &lt;/build&gt;
          &lt;properties&gt;
              &lt;liquibase.url&gt;${database.url}&lt;/liquibase.url&gt;
              &lt;liquibase.driver&gt;${database.driver}&lt;/liquibase.driver&gt;
              &lt;liquibase.username&gt;${database.username}&lt;/liquibase.username&gt;
              &lt;liquibase.password&gt;${database.password}&lt;/liquibase.password&gt;
          &lt;/properties&gt;
      &lt;/profile&gt;
      &lt;profile&gt;
          &lt;id&gt;dev&lt;/id&gt;
          &lt;build&gt;
              &lt;resources&gt;
                  &lt;resource&gt;
                      &lt;directory&gt;src/main/resources/dev&lt;/directory&gt;
                  &lt;/resource&gt;
              &lt;/resources&gt;
          &lt;/build&gt;
          &lt;properties&gt;
              &lt;liquibase.url&gt;${database.url}&lt;/liquibase.url&gt;
              &lt;liquibase.driver&gt;${database.driver}&lt;/liquibase.driver&gt;
              &lt;liquibase.username&gt;${database.username}&lt;/liquibase.username&gt;
              &lt;liquibase.password&gt;${database.password}&lt;/liquibase.password&gt;
          &lt;/properties&gt;
      &lt;/profile&gt;
  &lt;/profiles&gt;
  </code></pre>
  
  <p><strong>2. I tried using the Properties Maven plugin:</strong></p>
  
  <pre><code>   &lt;plugin&gt;
        &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
        &lt;artifactId&gt;properties-maven-plugin&lt;/artifactId&gt;
        &lt;version&gt;1.0-alpha-2&lt;/version&gt;
        &lt;executions&gt;
           &lt;execution&gt;
              &lt;phase&gt;initialize&lt;/phase&gt;
              &lt;goals&gt;
                 &lt;goal&gt;read-project-properties&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                 &lt;files&gt;
                    &lt;file&gt;src/main/resources/local/db.properties&lt;/file&gt;
                 &lt;/files&gt;
              &lt;/configuration&gt;
           &lt;/execution&gt;
        &lt;/executions&gt;
     &lt;/plugin&gt;
  </code></pre>
  
  <p>When I run the liquibase:update maven goal, I get this this error:</p>
  
  <pre><code>[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.1.0:update (default-cli) on project my-project: The driver has not been specified either as a parameter or in a properties file
  </code></pre>
  
  <p>It seems that the database properties referred to in the POM file couldn't be resolved.</p>
  
  <p>Any idea how this can be achieved ?</p>