title: why is "test-jar" dependency required for "mvn compile"
body: <p>I'm having trouble using <code>test-jar</code> dependencies in a multi-module project. For example, when I declare that the <code>cleartk-syntax</code> module depends on the <code>cleartk-token</code> module's <code>test-jar</code> like this (the full code is <a href="https://cleartk.googlecode.com/svn/trunk/">here</a>):</p>
  
  <pre><code>&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;org.cleartk&lt;/groupId&gt;
  &lt;artifactId&gt;cleartk-syntax&lt;/artifactId&gt;
  &lt;version&gt;0.5.0-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;cleartk-syntax&lt;/name&gt;
  ...
  &lt;dependencies&gt;
      ...
      &lt;dependency&gt;
          &lt;groupId&gt;org.cleartk&lt;/groupId&gt;
          &lt;artifactId&gt;cleartk-token&lt;/artifactId&gt;
          &lt;version&gt;0.7.0-SNAPSHOT&lt;/version&gt;
          &lt;type&gt;test-jar&lt;/type&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>I get the following error if I run <code>mvn compile</code> using maven 2:</p>
  
  <pre><code>[INFO] ------------------------------------------------------------------------
  [ERROR] BUILD ERROR
  [INFO] ------------------------------------------------------------------------
  [INFO] Failed to resolve artifact.
  
  Missing:
  ----------
  1) org.cleartk:cleartk-token:test-jar:tests:0.7.0-SNAPSHOT
  </code></pre>
  
  <p>If I use maven 3 I get the error:</p>
  
  <pre><code>[INFO] ------------------------------------------------------------------------
  [INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 4.654s
  [INFO] Finished at: Mon Jan 24 21:19:17 CET 2011
  [INFO] Final Memory: 16M/81M
  [INFO] ------------------------------------------------------------------------
  [ERROR] Failed to execute goal on project cleartk-syntax: Could not resolve
  dependencies for project org.cleartk:cleartk-syntax:jar:0.5.0-SNAPSHOT: Could
  not find artifact org.cleartk:cleartk-token:jar:tests:0.7.0-SNAPSHOT
  </code></pre>
  
  <p>In the latter case, I'm particularly confused because I would have thought it should be looking for an artifact of type <code>test-jar</code> not of type <code>jar</code>.</p>
  
  <p>With maven 2 or maven 3, I can get it to compile by running <code>mvn compile package -DskipTests</code>. With maven 3, I can also get it to compile by running <code>mvn compile test-compile</code>.</p>
  
  <p>But why is either maven 2 or maven 3 looking for a <code>test-jar</code> dependency during the <code>compile</code> phase? Shouldn't it wait until the <code>test-compile</code> phase to look for such dependencies?</p>
  
  <p><strong>Update:</strong> The answer was that the maven-exec-plugin, used during my compile phase, <a href="http://mojo.codehaus.org/exec-maven-plugin/java-mojo.html">requires dependency resolution of artifacts in scope:test</a>. I've created <a href="http://jira.codehaus.org/browse/MEXEC-91">a feature request to remove the scope:test dependency</a>.</p>