title: Sharing src/test classes between modules in a multi-module maven project
body: <p>I have a multi-module Maven project.  For the sake of this example, consider two modules:</p>
  
  <ul>
  <li><code>data</code></li>
  <li><code>consumer</code></li>
  </ul>
  
  <p>Module <code>consumer</code> has module <code>data</code> as a dependency.</p>
  
  <p>Module <code>data</code> declares a bunch of core classes.  There are tests under <code>src/test</code> that use them.  These tests require some long-winded object creation, so I have a class with some utility methods in it to create these objects.  This utility class (<code>SampleDataHelper</code>) is in the <code>src/test</code> hierarchy.</p>
  
  <p>I also have some tests in the <code>consumer</code> module that need to create some of these long-winded objects.  I want to use my <code>SampleDataHelper</code> class (defined in <code>data src/test</code>) in tests that reside in my <code>consumer src/test</code> tree.  Unfortunately, even though <code>data</code> is a dependency of <code>consumer</code>, <code>consumer</code> can't see the classes that exist under <code>data src/test</code>.</p>
  
  <p>To combat this, I thought I might create <em>another</em> module (<code>data-test</code>), and move <code>SampleDataHelper</code> to it under <strong><code>src/main</code></strong>.  Then I would include <code>data-test</code> as a <em>test scope</em> dependency of <code>data</code>.  Unfortunately, this introduces a circular dependency: <code>data</code> uses <code>data-test</code>, but <code>data-test</code> also requires <code>data</code>. </p>
  
  <p>The only solution I've come up with is to place <code>SampleDataHelper</code> under <code>data src/main</code> under a <code>test</code> package and hope that no real application code ever calls it.</p>
  
  <p>How can I share my <code>SampleDataHelper</code> class between modules <em>without</em> putting it under <code>src/main</code>?</p>