title: Loading resources in a maven project with exec-maven-plugin
body: <p>Having two issues here. I have a Maven project, with pom.xml specifying resources as</p>
  <pre><code>        &lt;resources&gt;
              &lt;resource&gt;
                  &lt;directory&gt;src/main/sql&lt;/directory&gt;
              &lt;/resource&gt;
              &lt;resource&gt;
                  &lt;directory&gt;src/main/resources&lt;/directory&gt;
              &lt;/resource&gt;
          &lt;/resources&gt;
  </code></pre>
  <p>And then I have an exec-maven-plugin section such as</p>
  <pre><code>&lt;plugin&gt;
    &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
    &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
    &lt;version&gt;3.0.0&lt;/version&gt;
    &lt;executions&gt;
      &lt;execution&gt;
        &lt;id&gt;RunMyTest&lt;/id&gt;
          &lt;goals&gt;
            &lt;goal&gt;java&lt;/goal&gt;
          &lt;/goals&gt;
          &lt;configuration&gt;
            &lt;mainClass&gt;com.foo.RunMyTest&lt;/mainClass&gt;
            &lt;classpathScope&gt;test&lt;/classpathScope&gt;
            &lt;addResourcesToClassPath&gt;true&lt;/addResourcesToClassPath&gt;
          &lt;/configuration&gt;
      &lt;/execution&gt;
    &lt;/executions&gt;
  &lt;/plugin&gt;
  </code></pre>
  <p>(Here, <code>com/foo/RunMyTest.java</code> lives in <code>src/test/java</code>).</p>
  <p>Now, I have two issues. First, somewhat minor: if I run this with</p>
  <p><code>mvn -X exec:java@RunMyTest</code></p>
  <p>I see in the output <code>[DEBUG]   (f) addResourcesToClasspath = false</code>. Does <code>&lt;addResourcesToClassPath&gt;true&lt;/addResourcesToClassPath&gt;</code> not have any effect?</p>
  <p>But that can be for now overridden with running</p>
  <pre><code>mvn  exec:java@RunMyTest -DaddResourcesToClasspath=true
  </code></pre>
  <p>Now I see <code>[DEBUG]   (f) addResourcesToClasspath = true</code>. BUT! The problem is, in my code I call code from a dependency, which in turn uses  <code>ClassLoader.getSystemClassLoader().getResource(&quot;foo.txt&quot;);</code> where <code>foo.txt</code> is under <code>src/main/sql</code> -- and this returns <code>null</code>. Testing in my code by doing <code>RunMyTest.class.getClassLoader().getResource(&quot;foo.txt&quot;)</code>, however, works. It appears that the system classloader does not see the resources path. Is there any nice way around it?</p>