Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It is not actually possible to load properties from a file using the instructions in the accepted answer as these properties are not available in the pom file though they can be used for filtering. Minimal counter example:</p> <p>In pom.xml:</p> <pre><code>&lt;build&gt; &lt;plugins&gt; &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;!-- Associate the read-project-properties goal with the initialize phase, to read the properties file. --&gt; &lt;execution&gt; &lt;!-- Apart from this test, the phase must be initialize --&gt; &lt;phase&gt;validate&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;dev.properties&lt;/file&gt; &lt;/files&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt; &lt;version&gt;1.6&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;phase&gt;validate&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;run&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;target&gt; &lt;echo&gt;Displaying value of properties&lt;/echo&gt; &lt;echo&gt;[foo] ${foo}&lt;/echo&gt; &lt;/target&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; </code></pre> <p>Having in <code>dev.properties</code>:</p> <pre><code>foo=bar </code></pre> <p>Then runnin the command <code>mvn validate</code> produces output:</p> <pre><code> [echo] Displaying value of properties [echo] [foo] bar </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload