title: Maven: Missing dependency when using test-jar at runtime
body: <p>My Maven project <code>foo.web</code> has its source files in <code>src/main</code> and the test sources in <code>src/test</code>. Of course, the test classes make use of the "main" classes. Now I want to use the test classes in another project during runtime, so I followed <a href="http://maven.apache.org/plugins/maven-jar-plugin/usage.html#How_to_create_a_jar_containing_test_classes" rel="nofollow">these instructions</a> on how to create a test-jar.</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;2.4&lt;/version&gt;
      &lt;executions&gt;
          &lt;execution&gt;
              &lt;goals&gt; 
                  &lt;goal&gt;test-jar&lt;/goal&gt;
              &lt;/goals&gt;
          &lt;/execution&gt;
      &lt;/executions&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>This works perfectly well, a jar like <code>web-SNAPSHOT-tests.jar</code> is created and I can include it in my other project.</p>
  
  <pre><code>&lt;dependency&gt;
          &lt;groupId&gt;foo&lt;/groupId&gt;
          &lt;artifactId&gt;web&lt;/artifactId&gt;
          &lt;version&gt;SNAPSHOT&lt;/version&gt;
          &lt;type&gt;test-jar&lt;/type&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>But it seems like the dependency to <code>web-SNAPSHOT</code> is not correctly set, because at runtime I receive NoClassDefFoundErrors of classes which are available in <code>foo.web</code>. So I added another dependency:</p>
  
  <pre><code>&lt;dependency&gt;
          &lt;groupId&gt;foo&lt;/groupId&gt;
          &lt;artifactId&gt;web&lt;/artifactId&gt;
          &lt;version&gt;SNAPSHOT&lt;/version&gt;
          &lt;type&gt;war&lt;/type&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Unfortunately, this changes nothing. Does anyone know what is wrong here?</p>