title: How to include jar with source code in war with Maven build
body: <p>I have a Maven multimodule project, then I want to pack source code of one of modules into jar and add it to war (same module or another one) in WEB-INF/lib path.</p>
  
  <p>Then, I tried to use Maven Source Plugin, like this:</p>
  
  <pre><code>    &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-source-plugin&lt;/artifactId&gt;
          &lt;version&gt;3.0.1&lt;/version&gt;
      &lt;configuration&gt;       
        &lt;attach&gt;true&lt;/attach&gt;
      &lt;/configuration&gt;
          &lt;executions&gt;
            &lt;execution&gt;
              &lt;id&gt;attach-sources&lt;/id&gt;
              &lt;goals&gt;
                &lt;goal&gt;jar&lt;/goal&gt;
              &lt;/goals&gt;
            &lt;/execution&gt;
          &lt;/executions&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
  </code></pre>
  
  <p>Then add it as normal dependency, like this:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;myModuleName&lt;/groupId&gt;
      &lt;artifactId&gt;myArtifactName&lt;/artifactId&gt;
      &lt;version&gt;1.0&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Problem is that, when I'm running build with simple command line </p>
  
  <blockquote>
    <p>mvn clean install</p>
  </blockquote>
  
  <p>I've got error with information that he cannot find my artifact with source code. It's looks like Maven first looks for dependency and later builds it.</p>
  
  <p>How to configure it in correct way?</p>