title: Maven - Reading a property from an external properties file
body: <p>I have a property file with the following</p>
  
  <pre><code>junit.version=3.8.1
  dbcp.version=5.5.27
  oracle.jdbc.version=10.2.0.2.0
  </code></pre>
  
  <p>I try to read those properties from my pom file as shown below</p>
  
  <pre><code>&lt;dependency&gt;
    &lt;groupId&gt;junit&lt;/groupId&gt;
    &lt;artifactId&gt;junit&lt;/artifactId&gt;
    &lt;version&gt;${junit.version}&lt;/version&gt;
    &lt;scope&gt;test&lt;/scope&gt;
  &lt;/dependency&gt;
  
  
  &lt;dependency&gt;
      &lt;groupId&gt;dbcp&lt;/groupId&gt;
      &lt;artifactId&gt;dbcp&lt;/artifactId&gt;
      &lt;version&gt;${dbcp.version}&lt;/version&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;com.oracle&lt;/groupId&gt;
    &lt;artifactId&gt;ojdbc14&lt;/artifactId&gt;
    &lt;version&gt;${oracle.jdbc.version}&lt;/version&gt;
    &lt;scope&gt;provided&lt;/scope&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>and the plugin configuration</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;executions&gt;
             &lt;!-- Associate the read-project-properties goal with the initialize phase, to read the properties file. --&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;../live.properties&lt;/file&gt;
                &lt;/files&gt;
              &lt;/configuration&gt;
            &lt;/execution&gt;
          &lt;/executions&gt;
        &lt;/plugin&gt;
  </code></pre>
  
  <p>I find that when i run mvn clean install it does not find the properties, instead it comes up with the following errors:</p>
  
  <pre><code>'dependencies.dependency.version' for junit:junit:jar must be a valid version but is '${junit.version}'. @ line 23, column 16
  'dependencies.dependency.version' for dbcp:dbcp:jar must be a valid version but is '${dbcp.version}'. @ line 31, column 12
  'dependencies.dependency.version' for com.oracle:ojdbc14:jar must be a valid version but is '${oracle.jdbc.version}'. @ line 37, column 13
  </code></pre>
  
  <p>The above failures appear to be in situations where i refer to the property when i declare the dependency. I found that in some other situations the property is read from the file. 
  For example it works if i use a property on the project version tag (not dependency version) </p>
  
  <p>It seems that the property is not read from the file if it is referred to from the dependency declaration but is read if referred to from anywhere else.  Any ideas?</p>