title: How do I add a file to the artifact (jar or war) created by maven?
body: <p>I have an antrun task (goal <code>run</code> on phase <code>prepare-package</code>) set up that creates a file and saves it in <code>/target/foo.bar</code>. How do I add that to the artifact that gets created by maven (depending on module, it could be a <code>jar</code> or a <code>war</code> file)?</p>
  
  <p>I have tried it with resources, with the builder-helper plugin, and the jar plugin - no luck:</p>
  
  <pre><code>&lt;resources&gt;
    &lt;resource&gt;
      &lt;directory&gt;target&lt;/directory&gt;
      &lt;includes&gt;
        &lt;include&gt;**/foo.bar&lt;/include&gt;
      &lt;/includes&gt;
    &lt;/resource&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>That doesn't seem to do anything.</p>
  
  <pre><code>&lt;plugin&gt;
    &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
    &lt;artifactId&gt;build-helper-maven-plugin&lt;/artifactId&gt;
    &lt;version&gt;3.0.0&lt;/version&gt;
    &lt;executions&gt;
      &lt;execution&gt;
        &lt;id&gt;attach-artifacts&lt;/id&gt;
        &lt;phase&gt;package&lt;/phase&gt;
        &lt;goals&gt;
          &lt;goal&gt;attach-artifact&lt;/goal&gt;
        &lt;/goals&gt;
        &lt;configuration&gt;
          &lt;artifacts&gt;
            &lt;artifact&gt;
              &lt;file&gt;${project.build.directory}/foo.bar&lt;/file&gt;
              &lt;type&gt;bar&lt;/type&gt;
            &lt;/artifact&gt;
         &lt;/artifacts&gt;
       &lt;/configuration&gt;
     &lt;/execution&gt;
   &lt;/executions&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>According to debug output, this seems to install something extra in the repo, but doesn't add <code>foo.bar</code> to the artefact.</p>
  
  <pre><code>&lt;plugin&gt;
    &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
    &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
    &lt;version&gt;3.0.2&lt;/version&gt;
    &lt;configuration&gt;
      &lt;includes&gt;
         &lt;include&gt;../foo.bar&lt;/include&gt;
      &lt;/includes&gt;
    &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>No observable effect, either. :(</p>
  
  <p>(I assume <a href="https://stackoverflow.com/a/2415670/2018047">this</a> might work for the <code>war</code> file, but I'd prefer one way to do it for both artifact types, if possible - plus I really need this to work for the <code>jar</code>s, too...)</p>
  
  <p>Is there a way to do what I want to do?<br>
  (I'd prefer not saving my file in src/main/resources first; I thought the packaging processes would pick files up from the build directory after they were placed there anyway, but I suppose I misunderstood something...)</p>