title: Handling resources across local vs sandboxed maven test environments
body: <p>The standard maven directory structure includes <code>resources</code> as follows:</p>
  
  <pre><code>  src/main/resources
    src/test/resources
  </code></pre>
  
  <p>When a maven build is initiated on a sandboxed environment - e.g. <code>jenkins</code> then all of the artifacts in those directories become available at the sandboxed "current" directory - and without resorting to any paths - either relative or absolute.</p>
  
  <p>But when running <code>mvn test</code> <em>locally</em> the sandboxed environment is not in play: instead it is just the root directory of the project. In this case those resources would seem to need to be accessed via <code>src/main[test]/resources</code>.</p>
  
  <p>Specifically: in a <code>sandboxed</code> environment all of the classes to be run are unpacked into a temporary directory *along with the resources under src/[test|main]/resources<code>*.  Therefore: the files/artifacts under</code>src/[test|main]/resources` are present in the <em>current</em> directory. The "relative" path to those resources is thus</p>
  
  <pre><code>    ./
  </code></pre>
  
  <p>But in the <code>local</code> environment - e.g. running <code>mvn test</code> at the root directory of a local <code>git</code> clone - then the <em>current</em> directory is the git repo root dir. The "relative" path to the artifacts is thus </p>
  
  <pre><code>./src/[test|main]/resources
  </code></pre>
  
  <p>While I realize the artifacts can <em>also</em> be accessed via <code>classLoader.getResourceAsStream</code> I have apis' that require <code>File</code> access.  We use api's like <code>listFiles()</code> and there is also the need to generate files in the given directories using <code>file://</code> uri as well as literal paths. so we do need file paths.</p>
  
  <p>What can be done here to normalize the paths across these different use cases/environments?</p>