Can't add dynamic property to Maven's resource located at build path
<p>I'm trying to setup properties in my <code>config.ini</code> which located in <code>src/main/config</code> by using <code>pom.xml</code> as described in <a href="https://stackoverflow.com/a/11740748/947111">this answer</a>, but it doesn't work.</p>

<p>I've placed to <code>src/main/config</code> file <code>config.ini</code> where the following line is present: <code>runtime_mode=${runtime.mode}</code> when I try to access at runtime <code>runtime_mode</code> key I get string <code>${runtime.mode}</code> instead of <strong>DEBUG</strong> or <strong>PRODUCTION</strong> as defined in <code>pom.xml</code>. When I use <code>${runtime.mode}</code> in <code>*.html</code> file it's being replaced by appropriate value as expected. </p>

<p>So, it doesn't work only when resource located at build path.</p>

<p>I suspect that I define resource in a wrong way, but can't realize what's wrong. </p>

<p>This is build part of my <code>pom.xml</code>:</p>

<pre><code>&lt;project&gt;
    &lt;properties&gt;
        &lt;runtime.mode&gt;DEBUG&lt;/runtime.mode&gt;
    &lt;/properties&gt;

    &lt;build&gt;
        &lt;finalName&gt;${project.name}&lt;/finalName&gt;
        &lt;resources&gt;
          &lt;resource&gt;
            &lt;directory&gt;src/main/config&lt;/directory&gt;
            &lt;filtering&gt;true&lt;/filtering&gt;
         &lt;/resource&gt;
        &lt;/resources&gt;

        &lt;plugins&gt;
            &lt;plugin&gt;
                &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                &lt;version&gt;2.1.1&lt;/version&gt;
                &lt;configuration&gt;
                    &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
                    &lt;webResources&gt;
                        &lt;resource&gt;
                          &lt;!-- this is relative to the pom.xml directory --&gt;
                          &lt;directory&gt;src/main/webapp&lt;/directory&gt;
                          &lt;filtering&gt;true&lt;/filtering&gt;
                          &lt;includes&gt;
                              &lt;include&gt;bower.json&lt;/include&gt;
                              &lt;include&gt;index.html&lt;/include&gt;
                          &lt;/includes&gt;
                        &lt;/resource&gt;
                    &lt;/webResources&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                &lt;version&gt;2.0.2&lt;/version&gt;
                &lt;configuration&gt;
                    &lt;source&gt;1.7&lt;/source&gt;
                    &lt;target&gt;1.7&lt;/target&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;
        &lt;/plugins&gt;
    &lt;/build&gt;
&lt;/project&gt;
</code></pre>

<p>My app is a <code>war</code> project created by using the following archetype:</p>

<pre><code>&lt;archetype&gt;
      &lt;groupId&gt;com.ibm.tools.archetype&lt;/groupId&gt;
      &lt;artifactId&gt;webapp-jee7-liberty&lt;/artifactId&gt;
      &lt;version&gt;1.0&lt;/version&gt;
      &lt;description&gt;JEE7 web application targeting WebSphere Liberty archetype&lt;/description&gt;
&lt;/archetype&gt;
</code></pre>

<p><strong>UPDATE</strong>:
Moved my <code>config.ini</code> to <code>src\main\resources</code> and changed my <code>&lt;resource&gt;</code> tag as following:</p>

<pre><code>&lt;resources&gt;
        &lt;resource&gt;
            &lt;directory&gt;src/main/resources&lt;/directory&gt;
            &lt;filtering&gt;true&lt;/filtering&gt;
            &lt;includes&gt;
                &lt;include&gt;config.ini&lt;/include&gt;
            &lt;/includes&gt;
        &lt;/resource&gt;
    &lt;/resources&gt;
</code></pre>

<p>But now I can't read any resource located in <code>src/main/resources</code> from code, for example I put there <code>sql.xml</code> where all my sql queries.</p>

<p>Trying read by following code: </p>

<pre><code>private static Properties readProperties(String xmlFileName) throws Exception {
         Properties properties = new Properties();
         InputStream is = SQLProvider.class.getClassLoader().getResourceAsStream(xmlFileName);
         properties.loadFromXML(is);
         return properties;
    }
</code></pre>

<p>But it throws an error:</p>

<pre><code>java.lang.NullPointerException
    at java.util.Objects.requireNonNull(Objects.java:203) ~[?:1.8.0_45]
    at java.util.Properties.loadFromXML(Properties.java:881) ~[?:1.8.0_45]
    at ***.SQLProvider.readProperties(SQLProvider.java:26) ~[classes/:?]
</code></pre>