title: Include and read a json file into a generated maven .jar file
body: <p>I'm using the <code>maven-assembly-plugin</code> to generate a single jar file with all dependencies using the command line:</p>
  
  <pre class="lang-sh prettyprint-override"><code>mvn clean compile assembly:single
  </code></pre>
  
  <p>It compile all <code>.java</code> files from the directory <code>src/main/java/</code> to a <code>.jar</code> file in <code>target/</code>.</p>
  
  <p>I have a class inside of my <code>src/main/java/</code> directory that read a <code>.json</code> file which is located next to him using this code:</p>
  
  <pre class="lang-java prettyprint-override"><code>File file = new File("src/main/java/path/to/test.json");
  content = FileUtils.readFileToString(file, "UTF-8");
  </code></pre>
  
  <p>So I will need to have access to this <code>.json</code> file in my generated <code>.jar</code>.</p>
  
  <p>I include this <code>.json</code> in maven using this config in <code>&lt;build&gt;</code>:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;resources&gt;
      &lt;resource&gt;
          &lt;directory&gt;src/main/java&lt;/directory&gt;
          &lt;includes&gt;
              &lt;include&gt;src/main/java/path/to/test.json&lt;/include&gt;
          &lt;/includes&gt;
      &lt;/resource&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>Everything compile successfully and when I tried to run my <code>.jar</code> file in <code>target/</code> directory using <code>java -jar ./target/my-jar-file.jar</code> it's work great.</p>
  
  <p>Problem is that now I want to be able to move my <code>.jar</code> file wherever I want. But when I execute it in another place I get the error message:</p>
  
  <blockquote>
    <p>java.io.FileNotFoundException: File 'src/main/java/path/to/test.json' does not exist</p>
  </blockquote>
  
  <p>So obviously the <code>.json</code> file has not been included in my generated <code>.jar</code>. </p>
  
  <p>Has somebody an idea what I have missed ?</p>